Merge branch 'dev' into refactor/data-types

This commit is contained in:
Alexander Nozik 2021-02-07 12:46:28 +03:00
commit 03337f00f0
14 changed files with 51 additions and 27 deletions

View File

@ -2,7 +2,7 @@ plugins {
id("ru.mipt.npm.project") id("ru.mipt.npm.project")
} }
val dataforgeVersion by extra("0.3.0-dev-3") val dataforgeVersion by extra("0.3.0")
val bintrayRepo by extra("dataforge") val bintrayRepo by extra("dataforge")
val githubProject by extra("dataforge-core") val githubProject by extra("dataforge-core")
@ -13,10 +13,6 @@ allprojects {
version = dataforgeVersion version = dataforgeVersion
apply<org.jetbrains.dokka.gradle.DokkaPlugin>() apply<org.jetbrains.dokka.gradle.DokkaPlugin>()
repositories {
mavenLocal()
}
} }
apiValidation{ apiValidation{

View File

@ -29,3 +29,7 @@ kotlin {
} }
} }
} }
readme{
maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT
}

View File

@ -4,7 +4,7 @@ import hep.dataforge.meta.DFExperimental
import org.w3c.dom.HTMLInputElement import org.w3c.dom.HTMLInputElement
@DFExperimental @DFExperimental
fun HTMLInputElement.bindValue(property: Property<String>) { public fun HTMLInputElement.bindValue(property: Property<String>) {
if (this.onchange != null) error("Input element already bound") if (this.onchange != null) error("Input element already bound")
this.onchange = { this.onchange = {
property.value = this.value property.value = this.value
@ -18,7 +18,7 @@ fun HTMLInputElement.bindValue(property: Property<String>) {
} }
@DFExperimental @DFExperimental
fun HTMLInputElement.bindChecked(property: Property<Boolean>) { public fun HTMLInputElement.bindChecked(property: Property<Boolean>) {
if (this.onchange != null) error("Input element already bound") if (this.onchange != null) error("Input element already bound")
this.onchange = { this.onchange = {
property.value = this.checked property.value = this.checked

View File

@ -23,3 +23,7 @@ kotlin {
} }
} }
} }
readme{
maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
}

View File

@ -1,27 +1,33 @@
plugins { plugins {
id("ru.mipt.npm.mpp") id("ru.mipt.npm.mpp")
id("ru.mipt.npm.native") // id("ru.mipt.npm.native")
} }
description = "YAML meta IO" description = "YAML meta IO"
repositories{
jcenter()
}
kscience { kscience {
useSerialization{ useSerialization{
yamlKt() yamlKt("0.9.0-dev-1")
} }
} }
repositories{
maven("https://dl.bintray.com/mamoe/yamlkt")
}
kotlin { kotlin {
sourceSets { sourceSets {
commonMain{ commonMain{
dependencies { dependencies {
api(project(":dataforge-io")) api(project(":dataforge-io"))
// api("net.mamoe.yamlkt:yamlkt:${ru.mipt.npm.gradle.KScienceVersions.Serialization.yamlKtVersion}")
} }
} }
} }
} }
readme{
maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
description ="""
YAML meta converters and Front Matter envelope format
""".trimIndent()
}

View File

@ -17,8 +17,7 @@ public class FrontMatterEnvelopeFormat(
) : EnvelopeFormat { ) : EnvelopeFormat {
override fun readPartial(input: Input): PartialEnvelope { override fun readPartial(input: Input): PartialEnvelope {
@Suppress("VARIABLE_WITH_REDUNDANT_INITIALIZER") var line: String
var line = ""
var offset = 0u var offset = 0u
do { do {
line = input.readUtf8Line() //?: error("Input does not contain front matter separator") line = input.readUtf8Line() //?: error("Input does not contain front matter separator")
@ -44,7 +43,7 @@ public class FrontMatterEnvelopeFormat(
} }
override fun readObject(input: Input): Envelope { override fun readObject(input: Input): Envelope {
var line = "" var line: String
do { do {
line = input.readUtf8Line() //?: error("Input does not contain front matter separator") line = input.readUtf8Line() //?: error("Input does not contain front matter separator")
} while (!line.startsWith(SEPARATOR)) } while (!line.startsWith(SEPARATOR))

View File

@ -86,16 +86,15 @@ public fun YamlMap.toMeta(): Meta = YamlMeta(this)
*/ */
@DFExperimental @DFExperimental
public class YamlMetaFormat(private val meta: Meta) : MetaFormat { public class YamlMetaFormat(private val meta: Meta) : MetaFormat {
private val coder = Yaml.default
override fun writeMeta(output: Output, meta: Meta, descriptor: NodeDescriptor?) { override fun writeMeta(output: Output, meta: Meta, descriptor: NodeDescriptor?) {
val yaml = meta.toYaml() val yaml = meta.toYaml()
val string = coder.encodeToString(yaml) val string = Yaml.encodeToString(yaml)
output.writeUtf8String(string) output.writeUtf8String(string)
} }
override fun readMeta(input: Input, descriptor: NodeDescriptor?): Meta { override fun readMeta(input: Input, descriptor: NodeDescriptor?): Meta {
val yaml = coder.decodeYamlMapFromString(input.readUtf8String()) val yaml = Yaml.decodeYamlMapFromString(input.readUtf8String())
return yaml.toMeta() return yaml.toMeta()
} }
@ -116,7 +115,7 @@ public class YamlMetaFormat(private val meta: Meta) : MetaFormat {
override fun writeMeta(output: Output, meta: Meta, descriptor: NodeDescriptor?): Unit = override fun writeMeta(output: Output, meta: Meta, descriptor: NodeDescriptor?): Unit =
default.writeMeta(output, meta, descriptor) default.writeMeta(output, meta, descriptor)
override fun readMeta(input: kotlinx.io.Input, descriptor: NodeDescriptor?): Meta = override fun readMeta(input: Input, descriptor: NodeDescriptor?): Meta =
default.readMeta(input, descriptor) default.readMeta(input, descriptor)
} }
} }

View File

@ -54,7 +54,7 @@ class FileBinaryTest {
val tmpPath = Files.createTempFile("dataforge_test", ".df") val tmpPath = Files.createTempFile("dataforge_test", ".df")
Global.io.writeEnvelopeFile(tmpPath, envelope) Global.io.writeEnvelopeFile(tmpPath, envelope)
val binary = Global.io.readEnvelopeFile(tmpPath)?.data!! val binary = Global.io.readEnvelopeFile(tmpPath).data!!
assertEquals(binary.size, binary.toByteArray().size) assertEquals(binary.size, binary.toByteArray().size)
} }
} }

View File

@ -29,7 +29,7 @@ class FileEnvelopeTest {
val tmpPath = Files.createTempFile("dataforge_test", ".df") val tmpPath = Files.createTempFile("dataforge_test", ".df")
writeEnvelopeFile(tmpPath, envelope) writeEnvelopeFile(tmpPath, envelope)
println(tmpPath.toUri()) println(tmpPath.toUri())
val restored: Envelope = readEnvelopeFile(tmpPath)!! val restored: Envelope = readEnvelopeFile(tmpPath)
assertTrue { envelope.contentEquals(restored) } assertTrue { envelope.contentEquals(restored) }
} }
} }
@ -40,7 +40,7 @@ class FileEnvelopeTest {
val tmpPath = Files.createTempFile("dataforge_test_tagless", ".df") val tmpPath = Files.createTempFile("dataforge_test_tagless", ".df")
writeEnvelopeFile(tmpPath, envelope, envelopeFormat = TaglessEnvelopeFormat) writeEnvelopeFile(tmpPath, envelope, envelopeFormat = TaglessEnvelopeFormat)
println(tmpPath.toUri()) println(tmpPath.toUri())
val restored: Envelope = readEnvelopeFile(tmpPath)!! val restored: Envelope = readEnvelopeFile(tmpPath)
assertTrue { envelope.contentEquals(restored) } assertTrue { envelope.contentEquals(restored) }
} }
} }

View File

@ -10,3 +10,7 @@ kscience {
} }
description = "Meta definition and basic operations on meta" description = "Meta definition and basic operations on meta"
readme{
maturity = ru.mipt.npm.gradle.Maturity.DEVELOPMENT
}

View File

@ -23,3 +23,7 @@ kotlin {
} }
} }
} }
readme{
maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
}

View File

@ -13,3 +13,7 @@ kotlin {
} }
} }
} }
readme{
maturity = ru.mipt.npm.gradle.Maturity.PROTOTYPE
}

View File

@ -14,3 +14,7 @@ kotlin {
} }
} }
} }
readme{
maturity = ru.mipt.npm.gradle.Maturity.EXPERIMENTAL
}

View File

@ -10,8 +10,8 @@ pluginManagement {
maven("https://dl.bintray.com/mipt-npm/dev") maven("https://dl.bintray.com/mipt-npm/dev")
} }
val toolsVersion = "0.7.4" val toolsVersion = "0.7.6"
val kotlinVersion = "1.4.30-RC" val kotlinVersion = "1.4.30"
plugins { plugins {
id("ru.mipt.npm.project") version toolsVersion id("ru.mipt.npm.project") version toolsVersion