minor API update

This commit is contained in:
Alexander Nozik 2022-06-22 20:00:27 +03:00
parent b8869570ce
commit 0b68c1edae
No known key found for this signature in database
GPG Key ID: F7FCF2DD25C71357
6 changed files with 43 additions and 2 deletions

View File

@ -6,7 +6,7 @@ plugins {
allprojects { allprojects {
group = "space.kscience" group = "space.kscience"
version = "0.6.0-dev-9" version = "0.6.0-dev-10"
} }
subprojects { subprojects {

View File

@ -6,6 +6,7 @@ import space.kscience.dataforge.names.*
import kotlin.collections.component1 import kotlin.collections.component1
import kotlin.collections.component2 import kotlin.collections.component2
import kotlin.reflect.KType import kotlin.reflect.KType
import kotlin.reflect.typeOf
public sealed class DataTreeItem<out T : Any> { public sealed class DataTreeItem<out T : Any> {
@ -63,6 +64,12 @@ public interface DataTree<out T : Any> : DataSet<T> {
* A name token used to designate tree node meta * A name token used to designate tree node meta
*/ */
public val META_ITEM_NAME_TOKEN: NameToken = NameToken("@meta") public val META_ITEM_NAME_TOKEN: NameToken = NameToken("@meta")
public inline fun <reified T : Any> empty(meta: Meta = Meta.EMPTY): DataTree<T> = object : DataTree<T> {
override val items: Map<NameToken, DataTreeItem<T>> get() = emptyMap()
override val dataType: KType get() = typeOf<T>()
override val meta: Meta get() = meta
}
} }
} }

View File

@ -68,6 +68,8 @@ public class IOPlugin(meta: Meta) : AbstractPlugin(meta) {
override val type: KClass<out IOPlugin> = IOPlugin::class override val type: KClass<out IOPlugin> = IOPlugin::class
override fun build(context: Context, meta: Meta): IOPlugin = IOPlugin(meta) override fun build(context: Context, meta: Meta): IOPlugin = IOPlugin(meta)
public val WORK_DIRECTORY_KEY: Name = Name.of("io", "workDirectory")
} }
} }

View File

@ -0,0 +1,28 @@
package space.kscience.dataforge.io
import space.kscience.dataforge.context.ContextBuilder
import space.kscience.dataforge.meta.get
import space.kscience.dataforge.meta.set
import space.kscience.dataforge.meta.string
import java.nio.file.Path
import kotlin.io.path.Path
public val IOPlugin.workDirectory: Path
get() {
val workDirectoryPath = meta[IOPlugin.WORK_DIRECTORY_KEY].string
?: context.properties[IOPlugin.WORK_DIRECTORY_KEY].string
?: ".dataforge"
return Path(workDirectoryPath)
}
public fun ContextBuilder.workDirectory(path: String) {
properties {
set(IOPlugin.WORK_DIRECTORY_KEY, path)
}
}
public fun ContextBuilder.workDirectory(path: Path){
workDirectory(path.toAbsolutePath().toString())
}

View File

@ -3,6 +3,10 @@ plugins {
id("ru.mipt.npm.gradle.native") id("ru.mipt.npm.gradle.native")
} }
kscience{
useCoroutines()
}
kotlin { kotlin {
sourceSets { sourceSets {
commonMain{ commonMain{

View File

@ -5,4 +5,4 @@ kotlin.code.style=official
kotlin.mpp.stability.nowarn=true kotlin.mpp.stability.nowarn=true
#kotlin.incremental.js.ir=true #kotlin.incremental.js.ir=true
toolsVersion=0.11.5-kotlin-1.6.21 toolsVersion=0.11.7-kotlin-1.7.0