change package

This commit is contained in:
InsanusMokrassar 2020-11-21 14:58:19 +06:00
parent c1d912f170
commit 104e9b1c87
21 changed files with 76 additions and 79 deletions

View File

@ -2,6 +2,12 @@
## 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
* Versions:

View File

@ -18,7 +18,7 @@ plugins {
}
project.version = "0.4.0"
project.group = "com.insanusmokrassar"
project.group = "dev.inmo"
apply from: "publish.gradle"
apply from: "github_release.gradle"

View File

@ -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)
}
}

View File

@ -1,7 +1,6 @@
package com.insanusmokrassar.krontab
package dev.inmo.krontab
import com.soywiz.klock.DateTime
import kotlinx.coroutines.Deferred
import kotlinx.coroutines.delay
/**

View File

@ -1,21 +1,21 @@
package com.insanusmokrassar.krontab
package dev.inmo.krontab
import com.soywiz.klock.DateTime
/**
* 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
* users activity or something like this
*
* @see com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
* @see dev.inmo.krontab.internal.CronDateTimeScheduler
*/
interface KronScheduler {
/**
* @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
}

View File

@ -1,8 +1,8 @@
package com.insanusmokrassar.krontab
package dev.inmo.krontab
import com.insanusmokrassar.krontab.builder.buildSchedule
import com.insanusmokrassar.krontab.internal.CronDateTime
import com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
import dev.inmo.krontab.builder.buildSchedule
import dev.inmo.krontab.internal.CronDateTime
import dev.inmo.krontab.internal.CronDateTimeScheduler
internal val anyCronDateTime by lazy {
CronDateTime()

View File

@ -1,6 +1,6 @@
package com.insanusmokrassar.krontab
package dev.inmo.krontab
import com.insanusmokrassar.krontab.internal.*
import dev.inmo.krontab.internal.*
/**
* @see createSimpleScheduler
@ -45,7 +45,7 @@ typealias KrontabTemplate = String
* * "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
*
* @see com.insanusmokrassar.krontab.internal.createKronScheduler
* @see dev.inmo.krontab.internal.createKronScheduler
*/
fun createSimpleScheduler(incoming: KrontabTemplate): KronScheduler {
val (secondsSource, minutesSource, hoursSource, dayOfMonthSource, monthSource) = incoming.split(" ")

View File

@ -1,15 +1,12 @@
package com.insanusmokrassar.krontab.builder
package dev.inmo.krontab.builder
import com.insanusmokrassar.krontab.KronScheduler
import com.insanusmokrassar.krontab.internal.*
import com.insanusmokrassar.krontab.internal.CronDateTime
import com.insanusmokrassar.krontab.internal.CronDateTimeScheduler
import com.insanusmokrassar.krontab.internal.fillWith
import dev.inmo.krontab.KronScheduler
import dev.inmo.krontab.internal.createKronScheduler
/**
* Will help to create an instance of [KronScheduler]
*
* @see com.insanusmokrassar.krontab.createSimpleScheduler
* @see dev.inmo.krontab.createSimpleScheduler
*/
fun buildSchedule(settingsBlock: SchedulerBuilder.() -> Unit): KronScheduler {
val builder = SchedulerBuilder()
@ -100,8 +97,8 @@ class SchedulerBuilder(
/**
* @return Completely built and independent [KronScheduler]
*
* @see com.insanusmokrassar.krontab.createSimpleScheduler
* @see com.insanusmokrassar.krontab.internal.createKronScheduler
* @see dev.inmo.krontab.createSimpleScheduler
* @see dev.inmo.krontab.internal.createKronScheduler
*/
fun build(): KronScheduler = createKronScheduler(seconds, minutes, hours, dayOfMonth, month)
}

View File

@ -1,7 +1,7 @@
package com.insanusmokrassar.krontab.builder
package dev.inmo.krontab.builder
import com.insanusmokrassar.krontab.internal.*
import com.insanusmokrassar.krontab.utils.clamp
import dev.inmo.krontab.internal.*
import dev.inmo.krontab.utils.clamp
/**
* This class was created for incapsulation of builder work with specified [restrictionsRange]. For example,

View File

@ -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.DateTimeSpan
import dev.inmo.krontab.KronScheduler
/**
* @param month 0-11

View File

@ -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)
}
}

View File

@ -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>? {
val things = from.split(",")

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.krontab.internal
package dev.inmo.krontab.internal
internal val monthRange = 0 .. 11
internal val dayOfMonthRange = 0 .. 30

View File

@ -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]

View File

@ -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 dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.FlowPreview
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.krontab.utils
package dev.inmo.krontab.utils
import kotlinx.coroutines.*

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.krontab.utils
package dev.inmo.krontab.utils
import kotlinx.coroutines.CoroutineScope

View File

@ -1,7 +1,6 @@
package com.insanusmokrassar.krontab.utils
package dev.inmo.krontab.utils
import com.insanusmokrassar.krontab.builder.buildSchedule
import com.soywiz.klock.DateTime
import dev.inmo.krontab.builder.buildSchedule
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.takeWhile

View File

@ -1,12 +1,9 @@
package com.insanusmokrassar.krontab.utils
package dev.inmo.krontab.utils
import com.insanusmokrassar.krontab.buildSchedule
import com.soywiz.klock.DateTime
import dev.inmo.krontab.buildSchedule
import kotlinx.coroutines.*
import kotlinx.coroutines.flow.collect
import kotlinx.coroutines.flow.takeWhile
import kotlin.math.max
import kotlin.math.min
import kotlin.test.Test
import kotlin.test.assertEquals

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.krontab.utils
package dev.inmo.krontab.utils
import kotlinx.coroutines.*

View File

@ -1,4 +1,4 @@
package com.insanusmokrassar.krontab.utils
package dev.inmo.krontab.utils
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.runBlocking