Switch HOCON dependency from typesafe-config to Jig
Jig (ma.chinespirit::jig) is the SummerCMS standard for HOCON. Uses sconfig under the hood (no Java deps, Scala Native compatible). Adapts HoconLoader to sconfig's parameterless method style.
This commit is contained in:
@@ -6,7 +6,7 @@ lazy val root = (project in file("."))
|
|||||||
scalaVersion := "3.3.4",
|
scalaVersion := "3.3.4",
|
||||||
|
|
||||||
libraryDependencies ++= Seq(
|
libraryDependencies ++= Seq(
|
||||||
"com.typesafe" % "config" % "1.4.3",
|
"ma.chinespirit" %% "jig" % "0.1.0",
|
||||||
"org.scalameta" %% "munit" % "1.0.3" % Test,
|
"org.scalameta" %% "munit" % "1.0.3" % Test,
|
||||||
),
|
),
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package summer.phrasebook
|
package summer.phrasebook
|
||||||
|
|
||||||
import com.typesafe.config.{Config, ConfigFactory, ConfigValueType}
|
import machinespir.it.jig.{Config, ConfigFactory}
|
||||||
|
import org.ekrich.config.ConfigValueType
|
||||||
import java.nio.file.{Files, Path}
|
import java.nio.file.{Files, Path}
|
||||||
import scala.jdk.CollectionConverters.*
|
import scala.jdk.CollectionConverters.*
|
||||||
|
|
||||||
@@ -39,10 +40,10 @@ object HoconLoader:
|
|||||||
/** Flatten a Typesafe Config into a string map. */
|
/** Flatten a Typesafe Config into a string map. */
|
||||||
def flatten(config: Config): Map[String, String] =
|
def flatten(config: Config): Map[String, String] =
|
||||||
val builder = Map.newBuilder[String, String]
|
val builder = Map.newBuilder[String, String]
|
||||||
for entry <- config.entrySet().asScala do
|
for entry <- config.entrySet.asScala do
|
||||||
val key = entry.getKey.nn
|
val key = entry.getKey.nn
|
||||||
val value = entry.getValue.nn
|
val value = entry.getValue.nn
|
||||||
value.valueType() match
|
value.valueType match
|
||||||
case ConfigValueType.STRING | ConfigValueType.NUMBER | ConfigValueType.BOOLEAN =>
|
case ConfigValueType.STRING | ConfigValueType.NUMBER | ConfigValueType.BOOLEAN =>
|
||||||
builder += key -> config.getString(key).nn
|
builder += key -> config.getString(key).nn
|
||||||
case ConfigValueType.NULL =>
|
case ConfigValueType.NULL =>
|
||||||
|
|||||||
Reference in New Issue
Block a user