0.1.8-dev-2
This commit is contained in:
parent
453a1bc755
commit
fb559f4562
@ -1,9 +1,10 @@
|
|||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
val toolsVersion = "0.4.2"
|
val toolsVersion = "0.5.5"
|
||||||
id("scientifik.mpp") version toolsVersion apply false
|
id("scientifik.mpp") version toolsVersion apply false
|
||||||
id("scientifik.jvm") version toolsVersion apply false
|
id("scientifik.jvm") version toolsVersion apply false
|
||||||
id("scientifik.publish") version toolsVersion apply false
|
id("scientifik.publish") version toolsVersion apply false
|
||||||
|
id("org.jetbrains.dokka") version "0.10.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
val dataforgeVersion by extra("0.1.8-dev-2")
|
val dataforgeVersion by extra("0.1.8-dev-2")
|
||||||
@ -22,4 +23,5 @@ allprojects {
|
|||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
apply(plugin = "scientifik.publish")
|
apply(plugin = "scientifik.publish")
|
||||||
|
apply(plugin = "org.jetbrains.dokka")
|
||||||
}
|
}
|
@ -13,19 +13,19 @@ kotlin {
|
|||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
api(project(":dataforge-meta"))
|
api(project(":dataforge-meta"))
|
||||||
api("io.github.microutils:kotlin-logging-common:1.7.8")
|
api("io.github.microutils:kotlin-logging-common:1.7.9")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jvmMain by getting {
|
val jvmMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
api(kotlin("reflect"))
|
api(kotlin("reflect"))
|
||||||
api("io.github.microutils:kotlin-logging:1.7.8")
|
api("io.github.microutils:kotlin-logging:1.7.9")
|
||||||
api("ch.qos.logback:logback-classic:1.2.3")
|
api("ch.qos.logback:logback-classic:1.2.3")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jsMain by getting {
|
val jsMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
api("io.github.microutils:kotlin-logging-js:1.7.8")
|
api("io.github.microutils:kotlin-logging-js:1.7.9")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,13 @@ interface Configurable : Described {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reset the property to its default value
|
||||||
|
*/
|
||||||
|
fun Configurable.resetProperty(name: Name) {
|
||||||
|
setProperty(name, null)
|
||||||
|
}
|
||||||
|
|
||||||
fun Configurable.getProperty(key: String) = getProperty(key.toName())
|
fun Configurable.getProperty(key: String) = getProperty(key.toName())
|
||||||
|
|
||||||
fun Configurable.setProperty(name: Name, value: Value?) = setProperty(name, value?.let { MetaItem.ValueItem(value) })
|
fun Configurable.setProperty(name: Name, value: Value?) = setProperty(name, value?.let { MetaItem.ValueItem(value) })
|
||||||
|
@ -201,8 +201,8 @@ fun Configurable.doubleArray(vararg doubles: Double, key: Name? = null): ReadWri
|
|||||||
|
|
||||||
/* Node delegates */
|
/* Node delegates */
|
||||||
|
|
||||||
fun Configurable.config(key: Name? = null): ReadWriteProperty<Any?, Config?> =
|
fun Configurable.config(default: Config? = null, key: Name? = null): ReadWriteProperty<Any?, Config?> =
|
||||||
config.node(key)
|
config.node(default,key)
|
||||||
|
|
||||||
fun Configurable.node(key: Name? = null): ReadWriteProperty<Any?, Meta?> = item(key).map(
|
fun Configurable.node(key: Name? = null): ReadWriteProperty<Any?, Meta?> = item(key).map(
|
||||||
reader = { it.node },
|
reader = { it.node },
|
||||||
|
@ -84,8 +84,8 @@ fun <M : MutableMeta<M>> M.boolean(default: Boolean? = null, key: Name? = null):
|
|||||||
fun <M : MutableMeta<M>> M.number(default: Number? = null, key: Name? = null): ReadWriteProperty<Any?, Number?> =
|
fun <M : MutableMeta<M>> M.number(default: Number? = null, key: Name? = null): ReadWriteProperty<Any?, Number?> =
|
||||||
item(default, key).transform { it.number }
|
item(default, key).transform { it.number }
|
||||||
|
|
||||||
inline fun <reified M : MutableMeta<M>> M.node(key: Name? = null) =
|
inline fun <reified M : MutableMeta<M>> M.node(default: M? = null, key: Name? = null) =
|
||||||
item(this, key).transform { it.node as? M }
|
item(default, key = key).transform { it.node as? M }
|
||||||
|
|
||||||
@JvmName("safeString")
|
@JvmName("safeString")
|
||||||
fun <M : MutableMeta<M>> M.string(default: String, key: Name? = null) =
|
fun <M : MutableMeta<M>> M.string(default: String, key: Name? = null) =
|
||||||
|
@ -47,10 +47,20 @@ fun ItemDescriptor.attributes(block: Config.() -> Unit) {
|
|||||||
(attributes ?: Config().also { this.attributes = it }).apply(block)
|
(attributes ?: Config().also { this.attributes = it }).apply(block)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set specific attribute in the descriptor
|
||||||
|
*/
|
||||||
|
fun ItemDescriptor.setAttribute(name: Name, value: Any?) {
|
||||||
|
attributes {
|
||||||
|
set(name, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if given item suits the descriptor
|
* Check if given item suits the descriptor
|
||||||
*/
|
*/
|
||||||
fun ItemDescriptor.validateItem(item: MetaItem<*>?): Boolean {
|
fun ItemDescriptor.validateItem(item: MetaItem<*>?): Boolean {
|
||||||
|
if (item == null) return !required
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is ValueDescriptor -> isAllowedValue(item.value ?: return false)
|
is ValueDescriptor -> isAllowedValue(item.value ?: return false)
|
||||||
is NodeDescriptor -> items.all { (key, d) ->
|
is NodeDescriptor -> items.all { (key, d) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user