diff --git a/CHANGELOG.md b/CHANGELOG.md index 0587952..3b20d39 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ * `Kotlin`: `1.3.72` -> `1.4.0` * `Coroutines`: `1.3.8` -> `1.3.9` * `Klock`: `1.11.14` -> `1.12.0` +* Typealias `KrontabTemplate` was added +* Extension `KrontabTemplate#toSchedule` was added ## 0.2.0 diff --git a/src/commonMain/kotlin/com/insanusmokrassar/krontab/StringParser.kt b/src/commonMain/kotlin/com/insanusmokrassar/krontab/StringParser.kt index b8b41ee..24a53cd 100644 --- a/src/commonMain/kotlin/com/insanusmokrassar/krontab/StringParser.kt +++ b/src/commonMain/kotlin/com/insanusmokrassar/krontab/StringParser.kt @@ -2,6 +2,12 @@ package com.insanusmokrassar.krontab 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: * @@ -38,7 +44,7 @@ import com.insanusmokrassar.krontab.internal.* * * @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 secondsParsed = parseSeconds(secondsSource) @@ -55,4 +61,9 @@ fun createSimpleScheduler(incoming: String): KronScheduler { /** * Shortcut for [createSimpleScheduler] */ -fun buildSchedule(incoming: String): KronScheduler = createSimpleScheduler(incoming) \ No newline at end of file +fun buildSchedule(incoming: KrontabTemplate): KronScheduler = createSimpleScheduler(incoming) + +/** + * Shortcut for [buildSchedule] + */ +fun KrontabTemplate.toSchedule(): KronScheduler = buildSchedule(this) \ No newline at end of file