KrontabTemplate typealias

This commit is contained in:
InsanusMokrassar 2020-08-22 21:42:47 +06:00
parent cdeea96c54
commit 241fb2ee51
2 changed files with 15 additions and 2 deletions

View File

@ -6,6 +6,8 @@
* `Kotlin`: `1.3.72` -> `1.4.0` * `Kotlin`: `1.3.72` -> `1.4.0`
* `Coroutines`: `1.3.8` -> `1.3.9` * `Coroutines`: `1.3.8` -> `1.3.9`
* `Klock`: `1.11.14` -> `1.12.0` * `Klock`: `1.11.14` -> `1.12.0`
* Typealias `KrontabTemplate` was added
* Extension `KrontabTemplate#toSchedule` was added
## 0.2.0 ## 0.2.0

View File

@ -2,6 +2,12 @@ package com.insanusmokrassar.krontab
import com.insanusmokrassar.krontab.internal.* import com.insanusmokrassar.krontab.internal.*
/**
* @see createSimpleScheduler
* @see buildSchedule
*/
typealias KrontabTemplate = String
/** /**
* Parse [incoming] string and adapt according to next format: "* * * * *" where order of things: * Parse [incoming] string and adapt according to next format: "* * * * *" where order of things:
* *
@ -38,7 +44,7 @@ import com.insanusmokrassar.krontab.internal.*
* *
* @see com.insanusmokrassar.krontab.internal.createKronScheduler * @see com.insanusmokrassar.krontab.internal.createKronScheduler
*/ */
fun createSimpleScheduler(incoming: String): KronScheduler { fun createSimpleScheduler(incoming: KrontabTemplate): KronScheduler {
val (secondsSource, minutesSource, hoursSource, dayOfMonthSource, monthSource) = incoming.split(" ") val (secondsSource, minutesSource, hoursSource, dayOfMonthSource, monthSource) = incoming.split(" ")
val secondsParsed = parseSeconds(secondsSource) val secondsParsed = parseSeconds(secondsSource)
@ -55,4 +61,9 @@ fun createSimpleScheduler(incoming: String): KronScheduler {
/** /**
* Shortcut for [createSimpleScheduler] * Shortcut for [createSimpleScheduler]
*/ */
fun buildSchedule(incoming: String): KronScheduler = createSimpleScheduler(incoming) fun buildSchedule(incoming: KrontabTemplate): KronScheduler = createSimpleScheduler(incoming)
/**
* Shortcut for [buildSchedule]
*/
fun KrontabTemplate.toSchedule(): KronScheduler = buildSchedule(this)