mirror of
https://github.com/InsanusMokrassar/krontab.git
synced 2024-11-22 16:23:55 +00:00
publish fixes
This commit is contained in:
parent
4d5245b1de
commit
990aad024f
@ -17,7 +17,7 @@ bintray {
|
|||||||
rename "(.*)jvm8-(.*)", "\$1\$2"
|
rename "(.*)jvm8-(.*)", "\$1\$2"
|
||||||
}
|
}
|
||||||
pkg {
|
pkg {
|
||||||
repo = 'StandardRepository'
|
repo = 'InsanusMokrassar'
|
||||||
name = "${project.name}"
|
name = "${project.name}"
|
||||||
vcsUrl = "${project_vcs_base}/${project.name}"
|
vcsUrl = "${project_vcs_base}/${project.name}"
|
||||||
licenses = ['Apache-2.0']
|
licenses = ['Apache-2.0']
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package com.insanusmokrassar.krontab.builder
|
package com.insanusmokrassar.krontab.builder
|
||||||
|
|
||||||
import com.github.insanusmokrassar.krontab.*
|
import com.github.insanusmokrassar.krontab.*
|
||||||
import com.github.insanusmokrassar.krontab.minutesRange
|
import com.insanusmokrassar.krontab.internal.*
|
||||||
import com.github.insanusmokrassar.krontab.monthRange
|
import com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||||
import com.github.insanusmokrassar.krontab.secondsRange
|
import com.insanusmokrassar.krontab.internal.hoursRange
|
||||||
|
import com.insanusmokrassar.krontab.internal.minutesRange
|
||||||
|
import com.insanusmokrassar.krontab.internal.monthRange
|
||||||
|
import com.insanusmokrassar.krontab.internal.secondsRange
|
||||||
import com.insanusmokrassar.krontab.utils.clamp
|
import com.insanusmokrassar.krontab.utils.clamp
|
||||||
|
|
||||||
sealed class TimeBuilder (
|
sealed class TimeBuilder (
|
||||||
@ -49,6 +52,6 @@ sealed class TimeBuilder (
|
|||||||
|
|
||||||
class SecondsBuilder : TimeBuilder(secondsRange)
|
class SecondsBuilder : TimeBuilder(secondsRange)
|
||||||
class MinutesBuilder : TimeBuilder(minutesRange)
|
class MinutesBuilder : TimeBuilder(minutesRange)
|
||||||
class HoursBuilder : TimeBuilder(hoursRange)
|
class HoursBuilder : TimeBuilder(com.insanusmokrassar.krontab.internal.hoursRange)
|
||||||
class DaysOfMonthBuilder : TimeBuilder(dayOfMonthRange)
|
class DaysOfMonthBuilder : TimeBuilder(com.insanusmokrassar.krontab.internal.dayOfMonthRange)
|
||||||
class MonthsBuilder : TimeBuilder(monthRange)
|
class MonthsBuilder : TimeBuilder(monthRange)
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.insanusmokrassar.krontab.internal
|
package com.insanusmokrassar.krontab.internal
|
||||||
|
|
||||||
import com.github.insanusmokrassar.krontab.dayOfMonthRange
|
import com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||||
import com.github.insanusmokrassar.krontab.hoursRange
|
import com.insanusmokrassar.krontab.internal.hoursRange
|
||||||
import com.github.insanusmokrassar.krontab.minutesRange
|
import com.insanusmokrassar.krontab.internal.minutesRange
|
||||||
import com.github.insanusmokrassar.krontab.monthRange
|
import com.insanusmokrassar.krontab.internal.monthRange
|
||||||
import com.github.insanusmokrassar.krontab.secondsRange
|
import com.insanusmokrassar.krontab.internal.secondsRange
|
||||||
import com.insanusmokrassar.krontab.utils.clamp
|
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
|
||||||
@ -24,11 +24,11 @@ internal data class CronDateTime(
|
|||||||
val seconds: Byte? = null
|
val seconds: Byte? = null
|
||||||
) {
|
) {
|
||||||
init {
|
init {
|
||||||
check(month ?.let { it in monthRange } ?: true)
|
check(month ?.let { it in com.insanusmokrassar.krontab.internal.monthRange } ?: true)
|
||||||
check(dayOfMonth ?.let { it in dayOfMonthRange } ?: true)
|
check(dayOfMonth ?.let { it in com.insanusmokrassar.krontab.internal.dayOfMonthRange } ?: true)
|
||||||
check(hours?.let { it in hoursRange } ?: true)
|
check(hours?.let { it in com.insanusmokrassar.krontab.internal.hoursRange } ?: true)
|
||||||
check(minutes?.let { it in minutesRange } ?: true)
|
check(minutes?.let { it in com.insanusmokrassar.krontab.internal.minutesRange } ?: true)
|
||||||
check(seconds?.let { it in secondsRange } ?: true)
|
check(seconds?.let { it in com.insanusmokrassar.krontab.internal.secondsRange } ?: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
||||||
@ -41,11 +41,11 @@ internal data class CronDateTime(
|
|||||||
minutes: Int? = null,
|
minutes: Int? = null,
|
||||||
seconds: Int? = null
|
seconds: Int? = null
|
||||||
) = CronDateTime(
|
) = CronDateTime(
|
||||||
month ?.clamp(monthRange) ?.toByte(),
|
month ?.clamp(com.insanusmokrassar.krontab.internal.monthRange) ?.toByte(),
|
||||||
dayOfMonth ?.clamp(dayOfMonthRange) ?.toByte(),
|
dayOfMonth ?.clamp(com.insanusmokrassar.krontab.internal.dayOfMonthRange) ?.toByte(),
|
||||||
hours ?.clamp(hoursRange) ?.toByte(),
|
hours ?.clamp(com.insanusmokrassar.krontab.internal.hoursRange) ?.toByte(),
|
||||||
minutes ?.clamp(minutesRange) ?.toByte(),
|
minutes ?.clamp(com.insanusmokrassar.krontab.internal.minutesRange) ?.toByte(),
|
||||||
seconds ?.clamp(secondsRange) ?.toByte()
|
seconds ?.clamp(com.insanusmokrassar.krontab.internal.secondsRange) ?.toByte()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package com.insanusmokrassar.krontab.internal
|
package com.insanusmokrassar.krontab.internal
|
||||||
|
|
||||||
import com.github.insanusmokrassar.krontab.dayOfMonthRange
|
import com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||||
import com.github.insanusmokrassar.krontab.hoursRange
|
import com.insanusmokrassar.krontab.internal.hoursRange
|
||||||
import com.github.insanusmokrassar.krontab.minutesRange
|
import com.insanusmokrassar.krontab.internal.minutesRange
|
||||||
import com.github.insanusmokrassar.krontab.monthRange
|
import com.insanusmokrassar.krontab.internal.monthRange
|
||||||
import com.github.insanusmokrassar.krontab.secondsRange
|
import com.insanusmokrassar.krontab.internal.secondsRange
|
||||||
import com.insanusmokrassar.krontab.utils.clamp
|
import com.insanusmokrassar.krontab.utils.clamp
|
||||||
|
|
||||||
private fun createCronDateTimeScheduler(from: String, dataRange: IntRange): Array<Byte>? {
|
private fun createCronDateTimeScheduler(from: String, dataRange: IntRange): Array<Byte>? {
|
||||||
@ -30,11 +30,21 @@ private fun createCronDateTimeScheduler(from: String, dataRange: IntRange): Arra
|
|||||||
return results.map { it.toByte() }.toTypedArray()
|
return results.map { it.toByte() }.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun parseMonths(from: String) = createCronDateTimeScheduler(from, monthRange)
|
internal fun parseMonths(from: String) = createCronDateTimeScheduler(from,
|
||||||
internal fun parseDaysOfMonth(from: String) = createCronDateTimeScheduler(from, dayOfMonthRange)
|
com.insanusmokrassar.krontab.internal.monthRange
|
||||||
internal fun parseHours(from: String) = createCronDateTimeScheduler(from, hoursRange)
|
)
|
||||||
internal fun parseMinutes(from: String) = createCronDateTimeScheduler(from, minutesRange)
|
internal fun parseDaysOfMonth(from: String) = createCronDateTimeScheduler(from,
|
||||||
internal fun parseSeconds(from: String) = createCronDateTimeScheduler(from, secondsRange)
|
com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||||
|
)
|
||||||
|
internal fun parseHours(from: String) = createCronDateTimeScheduler(from,
|
||||||
|
com.insanusmokrassar.krontab.internal.hoursRange
|
||||||
|
)
|
||||||
|
internal fun parseMinutes(from: String) = createCronDateTimeScheduler(from,
|
||||||
|
com.insanusmokrassar.krontab.internal.minutesRange
|
||||||
|
)
|
||||||
|
internal fun parseSeconds(from: String) = createCronDateTimeScheduler(from,
|
||||||
|
com.insanusmokrassar.krontab.internal.secondsRange
|
||||||
|
)
|
||||||
|
|
||||||
internal fun Array<Byte>.fillWith(
|
internal fun Array<Byte>.fillWith(
|
||||||
whereToPut: MutableList<CronDateTime>,
|
whereToPut: MutableList<CronDateTime>,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.github.insanusmokrassar.krontab
|
package com.insanusmokrassar.krontab.internal
|
||||||
|
|
||||||
internal val monthRange = 0 .. 11
|
internal val monthRange = 0 .. 11
|
||||||
internal val dayOfMonthRange = 0 .. 30
|
internal val dayOfMonthRange = 0 .. 30
|
||||||
|
23
src/jvm8Main/kotlin/TempMain.kt
Normal file
23
src/jvm8Main/kotlin/TempMain.kt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import com.insanusmokrassar.krontab.builder.buildSchedule
|
||||||
|
import com.insanusmokrassar.krontab.executeOnce
|
||||||
|
import com.soywiz.klock.DateTime
|
||||||
|
import kotlinx.coroutines.runBlocking
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
runBlocking {
|
||||||
|
buildSchedule {
|
||||||
|
seconds {
|
||||||
|
from(5) every 10
|
||||||
|
from(0) upTo 5
|
||||||
|
}
|
||||||
|
minutes {
|
||||||
|
at(30)
|
||||||
|
at(59)
|
||||||
|
}
|
||||||
|
}.also {
|
||||||
|
println(it)
|
||||||
|
}.executeOnce {
|
||||||
|
println("Done: ${DateTime.now()}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user