[add] added simple yml parsing
This commit is contained in:
@@ -15,6 +15,9 @@ repositories {
|
|||||||
// Use jcenter for resolving dependencies.
|
// Use jcenter for resolving dependencies.
|
||||||
// You can declare any Maven/Ivy/file repository here.
|
// You can declare any Maven/Ivy/file repository here.
|
||||||
jcenter()
|
jcenter()
|
||||||
|
maven {
|
||||||
|
url = uri("http://oss.sonatype.org/content/groups/public/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
|
|||||||
17
src/main/scala/scim/Library.scala
Normal file
17
src/main/scala/scim/Library.scala
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
11
src/main/scala/scim/Main.scala
Normal file
11
src/main/scala/scim/Main.scala
Normal 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)
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user