mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 16:23:55 +00:00
commit
9d8cb20d10
@ -1,5 +1,14 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 0.4.1
|
||||||
|
|
||||||
|
* Versions:
|
||||||
|
* `Coroutines`: `1.4.1` -> `1.4.2`
|
||||||
|
* `Klock`: `2.0.0` -> `2.0.1`
|
||||||
|
* `CronDateTimeScheduler` now is public
|
||||||
|
* New functions for `CronDateTimeScheduler`
|
||||||
|
* Add `CollectionKronScheduler`. It will give opportunity to unite several schedulers in one
|
||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
**BREAKING CHANGES**
|
**BREAKING CHANGES**
|
||||||
|
@ -16,7 +16,7 @@ plugins {
|
|||||||
id "org.jetbrains.dokka" version "$dokka_version"
|
id "org.jetbrains.dokka" version "$dokka_version"
|
||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.4.0"
|
project.version = "0.4.1"
|
||||||
project.group = "dev.inmo"
|
project.group = "dev.inmo"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
|
43
dokka.gradle
43
dokka.gradle
@ -1,6 +1,4 @@
|
|||||||
dokka {
|
dokkaHtml {
|
||||||
outputFormat = 'html'
|
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case project.hasProperty("DOKKA_PATH"):
|
case project.hasProperty("DOKKA_PATH"):
|
||||||
outputDirectory = project.property("DOKKA_PATH").toString()
|
outputDirectory = project.property("DOKKA_PATH").toString()
|
||||||
@ -10,33 +8,30 @@ dokka {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
multiplatform {
|
dokkaSourceSets {
|
||||||
global {
|
configureEach {
|
||||||
perPackageOption {
|
skipDeprecated.set(true)
|
||||||
prefix = "dev.inmo"
|
includeNonPublic.set(true)
|
||||||
skipDeprecated = true
|
reportUndocumented.set(true)
|
||||||
includeNonPublic = true
|
|
||||||
reportUndocumented = true
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceLink {
|
sourceLink {
|
||||||
path = "./"
|
localDirectory.set(file("./"))
|
||||||
url = "https://github.com/InsanusMokrassar/krontab/blob/master/"
|
remoteUrl.set(new URL("https://github.com/InsanusMokrassar/krontab/blob/master/"))
|
||||||
lineSuffix = "#L"
|
remoteLineSuffix.set("#L")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
common {
|
named("commonMain") {
|
||||||
targets = ["JVM", "JS"]
|
|
||||||
sourceRoot { path = "src/commonMain" }
|
sourceRoot { path = "src/commonMain" }
|
||||||
}
|
}
|
||||||
js {
|
|
||||||
targets = ["JS"]
|
//
|
||||||
sourceRoot { path = "src/jsMain" }
|
// named("jsMain") {
|
||||||
}
|
// sourceRoot { path = "src/jsMain" }
|
||||||
jvm {
|
// }
|
||||||
targets = ["JVM"]
|
//
|
||||||
sourceRoot { path = "src/jvmMain" }
|
// named("jvmMain") {
|
||||||
}
|
// sourceRoot { path = "src/jvmMain" }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,15 @@ org.gradle.parallel=true
|
|||||||
kotlin.js.generate.externals=true
|
kotlin.js.generate.externals=true
|
||||||
kotlin.incremental=true
|
kotlin.incremental=true
|
||||||
kotlin.incremental.js=true
|
kotlin.incremental.js=true
|
||||||
|
kotlin.incremental.multiplatform=true
|
||||||
|
|
||||||
|
|
||||||
kotlin_version=1.4.20
|
kotlin_version=1.4.20
|
||||||
kotlin_coroutines_version=1.4.1
|
kotlin_coroutines_version=1.4.2
|
||||||
|
|
||||||
dokka_version=0.10.1
|
dokka_version=1.4.20
|
||||||
|
|
||||||
klockVersion=2.0.0
|
klockVersion=2.0.1
|
||||||
|
|
||||||
github_release_plugin_version=2.2.12
|
github_release_plugin_version=2.2.12
|
||||||
|
|
||||||
kotlin.incremental.multiplatform=true
|
|
||||||
|
@ -0,0 +1,25 @@
|
|||||||
|
package dev.inmo.krontab.collection
|
||||||
|
|
||||||
|
import dev.inmo.krontab.KronScheduler
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun CollectionKronScheduler.includeAll(kronSchedulers: List<KronScheduler>) {
|
||||||
|
kronSchedulers.forEach {
|
||||||
|
include(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun CollectionKronScheduler.includeAll(vararg kronSchedulers: KronScheduler) {
|
||||||
|
includeAll(kronSchedulers.toList())
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun KronScheduler.plus(kronScheduler: KronScheduler): CollectionKronScheduler {
|
||||||
|
return CollectionKronScheduler().apply {
|
||||||
|
includeAll(this, kronScheduler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
operator fun CollectionKronScheduler.plusAssign(kronScheduler: KronScheduler) {
|
||||||
|
include(kronScheduler)
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package dev.inmo.krontab.collection
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.krontab.KronScheduler
|
||||||
|
import dev.inmo.krontab.anyCronDateTime
|
||||||
|
import dev.inmo.krontab.internal.*
|
||||||
|
import dev.inmo.krontab.internal.CronDateTimeScheduler
|
||||||
|
import dev.inmo.krontab.internal.merge
|
||||||
|
import dev.inmo.krontab.internal.toNearDateTime
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This scheduler will be useful in case you want to unite several different [KronScheduler]s
|
||||||
|
*/
|
||||||
|
data class CollectionKronScheduler internal constructor(
|
||||||
|
internal val schedulers: MutableList<KronScheduler>
|
||||||
|
) : KronScheduler {
|
||||||
|
internal constructor() : this(mutableListOf())
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add [kronScheduler] into its [schedulers] list
|
||||||
|
*
|
||||||
|
* * When [kronScheduler] is [CronDateTimeScheduler] it will merge all [CronDateTimeScheduler]s from [schedulers] list
|
||||||
|
* and this [kronScheduler] using [merge] function
|
||||||
|
* * When [kronScheduler] is [CollectionKronScheduler] it this instance will include all [kronScheduler]
|
||||||
|
* [schedulers]
|
||||||
|
* * Otherwise [kronScheduler] will be added to [schedulers] list
|
||||||
|
*/
|
||||||
|
fun include(kronScheduler: KronScheduler) {
|
||||||
|
when (kronScheduler) {
|
||||||
|
is CronDateTimeScheduler -> {
|
||||||
|
val resultCronDateTimes = mutableListOf(kronScheduler)
|
||||||
|
schedulers.removeAll {
|
||||||
|
if (it is CronDateTimeScheduler) {
|
||||||
|
resultCronDateTimes.add(it)
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
schedulers.add(
|
||||||
|
merge(resultCronDateTimes)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
is CollectionKronScheduler -> kronScheduler.schedulers.forEach {
|
||||||
|
include(it)
|
||||||
|
}
|
||||||
|
else -> schedulers.add(kronScheduler)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override suspend fun next(relatively: DateTime): DateTime {
|
||||||
|
return schedulers.minOfOrNull { it.next(relatively) } ?: anyCronDateTime.toNearDateTime(relatively)
|
||||||
|
}
|
||||||
|
}
|
@ -17,7 +17,7 @@ import dev.inmo.krontab.anyCronDateTime
|
|||||||
* @see dev.inmo.krontab.builder.buildSchedule
|
* @see dev.inmo.krontab.builder.buildSchedule
|
||||||
* @see dev.inmo.krontab.builder.SchedulerBuilder
|
* @see dev.inmo.krontab.builder.SchedulerBuilder
|
||||||
*/
|
*/
|
||||||
internal data class CronDateTimeScheduler internal constructor(
|
data class CronDateTimeScheduler internal constructor(
|
||||||
internal val cronDateTimes: List<CronDateTime>
|
internal val cronDateTimes: List<CronDateTime>
|
||||||
) : KronScheduler {
|
) : KronScheduler {
|
||||||
/**
|
/**
|
||||||
@ -30,3 +30,22 @@ internal data class CronDateTimeScheduler internal constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return New instance of [CronDateTimeScheduler] with all unique [CronDateTimeScheduler.cronDateTimes] of
|
||||||
|
* [kronDateTimeSchedulers] included
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
fun merge(kronDateTimeSchedulers: List<CronDateTimeScheduler>) = CronDateTimeScheduler(
|
||||||
|
kronDateTimeSchedulers.flatMap { it.cronDateTimes }.distinct()
|
||||||
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Vararg shortcyut for [merge]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun merge(vararg kronDateTimeSchedulers: CronDateTimeScheduler) = merge(kronDateTimeSchedulers.toList())
|
||||||
|
/**
|
||||||
|
* Use [merge] operation to internalcreate new [CronDateTimeScheduler] with all [CronDateTimeScheduler.cronDateTimes]
|
||||||
|
*/
|
||||||
|
@Suppress("NOTHING_TO_INLINE")
|
||||||
|
inline fun CronDateTimeScheduler.plus(other: CronDateTimeScheduler) = merge(this, other)
|
||||||
|
Loading…
Reference in New Issue
Block a user