mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 16:23:55 +00:00
change package
This commit is contained in:
parent
c1d912f170
commit
104e9b1c87
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
## 0.4.0
|
## 0.4.0
|
||||||
|
|
||||||
|
**BREAKING CHANGES**
|
||||||
|
Package of project has been changed. Migration:
|
||||||
|
|
||||||
|
* Replace in your dependencies `com.insanusmokrassar:krontab` by `dev.inmo:krontab`
|
||||||
|
* Replace in your project all imports `com.insanusmokrassar.krontab` by `dev.inmo.krontab`
|
||||||
|
|
||||||
## 0.3.3
|
## 0.3.3
|
||||||
|
|
||||||
* Versions:
|
* Versions:
|
||||||
|
@ -18,7 +18,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
project.version = "0.4.0"
|
project.version = "0.4.0"
|
||||||
project.group = "com.insanusmokrassar"
|
project.group = "dev.inmo"
|
||||||
|
|
||||||
apply from: "publish.gradle"
|
apply from: "publish.gradle"
|
||||||
apply from: "github_release.gradle"
|
apply from: "github_release.gradle"
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
package com.insanusmokrassar.krontab.internal
|
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.KronScheduler
|
|
||||||
import com.insanusmokrassar.krontab.anyCronDateTime
|
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cron-oriented realisation of [KronScheduler]
|
|
||||||
*
|
|
||||||
* @see com.insanusmokrassar.krontab.AnyTimeScheduler
|
|
||||||
* @see com.insanusmokrassar.krontab.EverySecondScheduler
|
|
||||||
* @see com.insanusmokrassar.krontab.EveryMinuteScheduler
|
|
||||||
* @see com.insanusmokrassar.krontab.EveryHourScheduler
|
|
||||||
* @see com.insanusmokrassar.krontab.EveryDayOfMonthScheduler
|
|
||||||
* @see com.insanusmokrassar.krontab.EveryMonthScheduler
|
|
||||||
*
|
|
||||||
* @see com.insanusmokrassar.krontab.builder.buildSchedule
|
|
||||||
* @see com.insanusmokrassar.krontab.builder.SchedulerBuilder
|
|
||||||
*/
|
|
||||||
internal data class CronDateTimeScheduler internal constructor(
|
|
||||||
internal val cronDateTimes: List<CronDateTime>
|
|
||||||
) : KronScheduler {
|
|
||||||
/**
|
|
||||||
* @return Near date using [cronDateTimes] list and getting the [Iterable.min] one
|
|
||||||
*
|
|
||||||
* @see toNearDateTime
|
|
||||||
*/
|
|
||||||
override suspend fun next(relatively: DateTime): DateTime {
|
|
||||||
return cronDateTimes.map { it.toNearDateTime(relatively) }.minOrNull() ?: anyCronDateTime.toNearDateTime(relatively)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
package com.insanusmokrassar.krontab
|
package dev.inmo.krontab
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
import kotlinx.coroutines.Deferred
|
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,21 +1,21 @@
|
|||||||
package com.insanusmokrassar.krontab
|
package dev.inmo.krontab
|
||||||
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface was created for abstraction of [next] operation. Currently, there is only
|
* This interface was created for abstraction of [next] operation. Currently, there is only
|
||||||
* [com.insanusmokrassar.krontab.internal.CronDateTimeScheduler] realisation of this interface inside of this library,
|
* [dev.inmo.krontab.internal.CronDateTimeScheduler] realisation of this interface inside of this library,
|
||||||
* but you it is possible to create your own realisation of this interface for scheduling, for example, depending of
|
* but you it is possible to create your own realisation of this interface for scheduling, for example, depending of
|
||||||
* users activity or something like this
|
* users activity or something like this
|
||||||
*
|
*
|
||||||
* @see com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
|
* @see dev.inmo.krontab.internal.CronDateTimeScheduler
|
||||||
*/
|
*/
|
||||||
interface KronScheduler {
|
interface KronScheduler {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Next [DateTime] when some action must be triggered according to settings of this instance
|
* @return Next [DateTime] when some action must be triggered according to settings of this instance
|
||||||
*
|
*
|
||||||
* @see com.insanusmokrassar.krontab.internal.CronDateTimeScheduler.next
|
* @see dev.inmo.krontab.internal.CronDateTimeScheduler.next
|
||||||
*/
|
*/
|
||||||
suspend fun next(relatively: DateTime = DateTime.now()): DateTime
|
suspend fun next(relatively: DateTime = DateTime.now()): DateTime
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.insanusmokrassar.krontab
|
package dev.inmo.krontab
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.builder.buildSchedule
|
import dev.inmo.krontab.builder.buildSchedule
|
||||||
import com.insanusmokrassar.krontab.internal.CronDateTime
|
import dev.inmo.krontab.internal.CronDateTime
|
||||||
import com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
|
import dev.inmo.krontab.internal.CronDateTimeScheduler
|
||||||
|
|
||||||
internal val anyCronDateTime by lazy {
|
internal val anyCronDateTime by lazy {
|
||||||
CronDateTime()
|
CronDateTime()
|
@ -1,6 +1,6 @@
|
|||||||
package com.insanusmokrassar.krontab
|
package dev.inmo.krontab
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.internal.*
|
import dev.inmo.krontab.internal.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see createSimpleScheduler
|
* @see createSimpleScheduler
|
||||||
@ -45,7 +45,7 @@ typealias KrontabTemplate = String
|
|||||||
* * "0/15 30 * * *" for every 15th seconds in a half of each hour
|
* * "0/15 30 * * *" for every 15th seconds in a half of each hour
|
||||||
* * "1 2 3 F,4,L 5" for triggering in near first second of second minute of third hour of fourth day of may
|
* * "1 2 3 F,4,L 5" for triggering in near first second of second minute of third hour of fourth day of may
|
||||||
*
|
*
|
||||||
* @see com.insanusmokrassar.krontab.internal.createKronScheduler
|
* @see dev.inmo.krontab.internal.createKronScheduler
|
||||||
*/
|
*/
|
||||||
fun createSimpleScheduler(incoming: KrontabTemplate): KronScheduler {
|
fun createSimpleScheduler(incoming: KrontabTemplate): KronScheduler {
|
||||||
val (secondsSource, minutesSource, hoursSource, dayOfMonthSource, monthSource) = incoming.split(" ")
|
val (secondsSource, minutesSource, hoursSource, dayOfMonthSource, monthSource) = incoming.split(" ")
|
@ -1,15 +1,12 @@
|
|||||||
package com.insanusmokrassar.krontab.builder
|
package dev.inmo.krontab.builder
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.KronScheduler
|
import dev.inmo.krontab.KronScheduler
|
||||||
import com.insanusmokrassar.krontab.internal.*
|
import dev.inmo.krontab.internal.createKronScheduler
|
||||||
import com.insanusmokrassar.krontab.internal.CronDateTime
|
|
||||||
import com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
|
|
||||||
import com.insanusmokrassar.krontab.internal.fillWith
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will help to create an instance of [KronScheduler]
|
* Will help to create an instance of [KronScheduler]
|
||||||
*
|
*
|
||||||
* @see com.insanusmokrassar.krontab.createSimpleScheduler
|
* @see dev.inmo.krontab.createSimpleScheduler
|
||||||
*/
|
*/
|
||||||
fun buildSchedule(settingsBlock: SchedulerBuilder.() -> Unit): KronScheduler {
|
fun buildSchedule(settingsBlock: SchedulerBuilder.() -> Unit): KronScheduler {
|
||||||
val builder = SchedulerBuilder()
|
val builder = SchedulerBuilder()
|
||||||
@ -100,8 +97,8 @@ class SchedulerBuilder(
|
|||||||
/**
|
/**
|
||||||
* @return Completely built and independent [KronScheduler]
|
* @return Completely built and independent [KronScheduler]
|
||||||
*
|
*
|
||||||
* @see com.insanusmokrassar.krontab.createSimpleScheduler
|
* @see dev.inmo.krontab.createSimpleScheduler
|
||||||
* @see com.insanusmokrassar.krontab.internal.createKronScheduler
|
* @see dev.inmo.krontab.internal.createKronScheduler
|
||||||
*/
|
*/
|
||||||
fun build(): KronScheduler = createKronScheduler(seconds, minutes, hours, dayOfMonth, month)
|
fun build(): KronScheduler = createKronScheduler(seconds, minutes, hours, dayOfMonth, month)
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.insanusmokrassar.krontab.builder
|
package dev.inmo.krontab.builder
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.internal.*
|
import dev.inmo.krontab.internal.*
|
||||||
import com.insanusmokrassar.krontab.utils.clamp
|
import dev.inmo.krontab.utils.clamp
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class was created for incapsulation of builder work with specified [restrictionsRange]. For example,
|
* This class was created for incapsulation of builder work with specified [restrictionsRange]. For example,
|
@ -1,9 +1,8 @@
|
|||||||
package com.insanusmokrassar.krontab.internal
|
package dev.inmo.krontab.internal
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.KronScheduler
|
|
||||||
import com.insanusmokrassar.krontab.utils.clamp
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
import com.soywiz.klock.DateTimeSpan
|
import com.soywiz.klock.DateTimeSpan
|
||||||
|
import dev.inmo.krontab.KronScheduler
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param month 0-11
|
* @param month 0-11
|
@ -0,0 +1,32 @@
|
|||||||
|
package dev.inmo.krontab.internal
|
||||||
|
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.krontab.KronScheduler
|
||||||
|
import dev.inmo.krontab.anyCronDateTime
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cron-oriented realisation of [KronScheduler]
|
||||||
|
*
|
||||||
|
* @see dev.inmo.krontab.AnyTimeScheduler
|
||||||
|
* @see dev.inmo.krontab.EverySecondScheduler
|
||||||
|
* @see dev.inmo.krontab.EveryMinuteScheduler
|
||||||
|
* @see dev.inmo.krontab.EveryHourScheduler
|
||||||
|
* @see dev.inmo.krontab.EveryDayOfMonthScheduler
|
||||||
|
* @see dev.inmo.krontab.EveryMonthScheduler
|
||||||
|
*
|
||||||
|
* @see dev.inmo.krontab.builder.buildSchedule
|
||||||
|
* @see dev.inmo.krontab.builder.SchedulerBuilder
|
||||||
|
*/
|
||||||
|
internal data class CronDateTimeScheduler internal constructor(
|
||||||
|
internal val cronDateTimes: List<CronDateTime>
|
||||||
|
) : KronScheduler {
|
||||||
|
/**
|
||||||
|
* @return Near date using [cronDateTimes] list and getting the [Iterable.min] one
|
||||||
|
*
|
||||||
|
* @see toNearDateTime
|
||||||
|
*/
|
||||||
|
override suspend fun next(relatively: DateTime): DateTime {
|
||||||
|
return cronDateTimes.map { it.toNearDateTime(relatively) }.minOrNull() ?: anyCronDateTime.toNearDateTime(relatively)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
package com.insanusmokrassar.krontab.internal
|
package dev.inmo.krontab.internal
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.utils.clamp
|
import dev.inmo.krontab.utils.clamp
|
||||||
|
|
||||||
private fun createSimpleScheduler(from: String, dataRange: IntRange): Array<Byte>? {
|
private fun createSimpleScheduler(from: String, dataRange: IntRange): Array<Byte>? {
|
||||||
val things = from.split(",")
|
val things = from.split(",")
|
@ -1,4 +1,4 @@
|
|||||||
package com.insanusmokrassar.krontab.internal
|
package dev.inmo.krontab.internal
|
||||||
|
|
||||||
internal val monthRange = 0 .. 11
|
internal val monthRange = 0 .. 11
|
||||||
internal val dayOfMonthRange = 0 .. 30
|
internal val dayOfMonthRange = 0 .. 30
|
@ -1,4 +1,4 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return [min] in case if [this] less than [min]. Otherwise will check that [max] grant than [this] and return [this]
|
* @return [min] in case if [this] less than [min]. Otherwise will check that [max] grant than [this] and return [this]
|
@ -1,7 +1,7 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.KronScheduler
|
|
||||||
import com.soywiz.klock.DateTime
|
import com.soywiz.klock.DateTime
|
||||||
|
import dev.inmo.krontab.KronScheduler
|
||||||
import kotlinx.coroutines.FlowPreview
|
import kotlinx.coroutines.FlowPreview
|
||||||
import kotlinx.coroutines.delay
|
import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.flow.*
|
import kotlinx.coroutines.flow.*
|
@ -1,4 +1,4 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
|
|
@ -1,7 +1,6 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.builder.buildSchedule
|
import dev.inmo.krontab.builder.buildSchedule
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.coroutines.flow.takeWhile
|
import kotlinx.coroutines.flow.takeWhile
|
@ -1,12 +1,9 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import com.insanusmokrassar.krontab.buildSchedule
|
import dev.inmo.krontab.buildSchedule
|
||||||
import com.soywiz.klock.DateTime
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
import kotlinx.coroutines.flow.collect
|
import kotlinx.coroutines.flow.collect
|
||||||
import kotlinx.coroutines.flow.takeWhile
|
import kotlinx.coroutines.flow.takeWhile
|
||||||
import kotlin.math.max
|
|
||||||
import kotlin.math.min
|
|
||||||
import kotlin.test.Test
|
import kotlin.test.Test
|
||||||
import kotlin.test.assertEquals
|
import kotlin.test.assertEquals
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import kotlinx.coroutines.*
|
import kotlinx.coroutines.*
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.insanusmokrassar.krontab.utils
|
package dev.inmo.krontab.utils
|
||||||
|
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
Loading…
Reference in New Issue
Block a user