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"
|
||||
}
|
||||
pkg {
|
||||
repo = 'StandardRepository'
|
||||
repo = 'InsanusMokrassar'
|
||||
name = "${project.name}"
|
||||
vcsUrl = "${project_vcs_base}/${project.name}"
|
||||
licenses = ['Apache-2.0']
|
||||
|
@ -1,9 +1,12 @@
|
||||
package com.insanusmokrassar.krontab.builder
|
||||
|
||||
import com.github.insanusmokrassar.krontab.*
|
||||
import com.github.insanusmokrassar.krontab.minutesRange
|
||||
import com.github.insanusmokrassar.krontab.monthRange
|
||||
import com.github.insanusmokrassar.krontab.secondsRange
|
||||
import com.insanusmokrassar.krontab.internal.*
|
||||
import com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||
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
|
||||
|
||||
sealed class TimeBuilder (
|
||||
@ -49,6 +52,6 @@ sealed class TimeBuilder (
|
||||
|
||||
class SecondsBuilder : TimeBuilder(secondsRange)
|
||||
class MinutesBuilder : TimeBuilder(minutesRange)
|
||||
class HoursBuilder : TimeBuilder(hoursRange)
|
||||
class DaysOfMonthBuilder : TimeBuilder(dayOfMonthRange)
|
||||
class HoursBuilder : TimeBuilder(com.insanusmokrassar.krontab.internal.hoursRange)
|
||||
class DaysOfMonthBuilder : TimeBuilder(com.insanusmokrassar.krontab.internal.dayOfMonthRange)
|
||||
class MonthsBuilder : TimeBuilder(monthRange)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.insanusmokrassar.krontab.internal
|
||||
|
||||
import com.github.insanusmokrassar.krontab.dayOfMonthRange
|
||||
import com.github.insanusmokrassar.krontab.hoursRange
|
||||
import com.github.insanusmokrassar.krontab.minutesRange
|
||||
import com.github.insanusmokrassar.krontab.monthRange
|
||||
import com.github.insanusmokrassar.krontab.secondsRange
|
||||
import com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||
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.soywiz.klock.DateTime
|
||||
import com.soywiz.klock.DateTimeSpan
|
||||
@ -24,11 +24,11 @@ internal data class CronDateTime(
|
||||
val seconds: Byte? = null
|
||||
) {
|
||||
init {
|
||||
check(month ?.let { it in monthRange } ?: true)
|
||||
check(dayOfMonth ?.let { it in dayOfMonthRange } ?: true)
|
||||
check(hours?.let { it in hoursRange } ?: true)
|
||||
check(minutes?.let { it in minutesRange } ?: true)
|
||||
check(seconds?.let { it in secondsRange } ?: true)
|
||||
check(month ?.let { it in com.insanusmokrassar.krontab.internal.monthRange } ?: true)
|
||||
check(dayOfMonth ?.let { it in com.insanusmokrassar.krontab.internal.dayOfMonthRange } ?: true)
|
||||
check(hours?.let { it in com.insanusmokrassar.krontab.internal.hoursRange } ?: true)
|
||||
check(minutes?.let { it in com.insanusmokrassar.krontab.internal.minutesRange } ?: true)
|
||||
check(seconds?.let { it in com.insanusmokrassar.krontab.internal.secondsRange } ?: true)
|
||||
}
|
||||
|
||||
internal val klockDayOfMonth = dayOfMonth ?.plus(1)
|
||||
@ -41,11 +41,11 @@ internal data class CronDateTime(
|
||||
minutes: Int? = null,
|
||||
seconds: Int? = null
|
||||
) = CronDateTime(
|
||||
month ?.clamp(monthRange) ?.toByte(),
|
||||
dayOfMonth ?.clamp(dayOfMonthRange) ?.toByte(),
|
||||
hours ?.clamp(hoursRange) ?.toByte(),
|
||||
minutes ?.clamp(minutesRange) ?.toByte(),
|
||||
seconds ?.clamp(secondsRange) ?.toByte()
|
||||
month ?.clamp(com.insanusmokrassar.krontab.internal.monthRange) ?.toByte(),
|
||||
dayOfMonth ?.clamp(com.insanusmokrassar.krontab.internal.dayOfMonthRange) ?.toByte(),
|
||||
hours ?.clamp(com.insanusmokrassar.krontab.internal.hoursRange) ?.toByte(),
|
||||
minutes ?.clamp(com.insanusmokrassar.krontab.internal.minutesRange) ?.toByte(),
|
||||
seconds ?.clamp(com.insanusmokrassar.krontab.internal.secondsRange) ?.toByte()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.insanusmokrassar.krontab.internal
|
||||
|
||||
import com.github.insanusmokrassar.krontab.dayOfMonthRange
|
||||
import com.github.insanusmokrassar.krontab.hoursRange
|
||||
import com.github.insanusmokrassar.krontab.minutesRange
|
||||
import com.github.insanusmokrassar.krontab.monthRange
|
||||
import com.github.insanusmokrassar.krontab.secondsRange
|
||||
import com.insanusmokrassar.krontab.internal.dayOfMonthRange
|
||||
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
|
||||
|
||||
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()
|
||||
}
|
||||
|
||||
internal fun parseMonths(from: String) = createCronDateTimeScheduler(from, monthRange)
|
||||
internal fun parseDaysOfMonth(from: String) = createCronDateTimeScheduler(from, dayOfMonthRange)
|
||||
internal fun parseHours(from: String) = createCronDateTimeScheduler(from, hoursRange)
|
||||
internal fun parseMinutes(from: String) = createCronDateTimeScheduler(from, minutesRange)
|
||||
internal fun parseSeconds(from: String) = createCronDateTimeScheduler(from, secondsRange)
|
||||
internal fun parseMonths(from: String) = createCronDateTimeScheduler(from,
|
||||
com.insanusmokrassar.krontab.internal.monthRange
|
||||
)
|
||||
internal fun parseDaysOfMonth(from: String) = createCronDateTimeScheduler(from,
|
||||
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(
|
||||
whereToPut: MutableList<CronDateTime>,
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.github.insanusmokrassar.krontab
|
||||
package com.insanusmokrassar.krontab.internal
|
||||
|
||||
internal val monthRange = 0 .. 11
|
||||
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