[add] added simple yml parsing

This commit is contained in:
2020-01-29 01:19:10 -06:00
parent d1357ac099
commit feb31da347
3 changed files with 31 additions and 0 deletions

View File

@@ -15,6 +15,9 @@ repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
maven {
url = uri("http://oss.sonatype.org/content/groups/public/")
}
}
dependencies {

View File

@@ -0,0 +1,17 @@
package scim
package lib
import java.io.{File, FileInputStream}
import scala.collection.convert.wrapAll._
// external imports
import org.yaml.snakeyaml.Yaml
package object yml {
val yaml = new Yaml
// TODO: handle errors (invalid file/format)
def parse(file:String) : Map[Nothing, Nothing] = {
val fis = new FileInputStream(new File(file))
val list = mapAsScalaMap(yaml.load(fis))
return list.toMap
}
}

View File

@@ -0,0 +1,11 @@
package scim
import scim.lib._
object Main {
def main(args: Array[String]): Unit = {
val config = "docs/wiki/config/config.yml"
val list = yml.parse(config)
println(list)
}
}