Oddly enough, a Scala wrapper for Typesafe's (pure-Java) Config library.
Scala
Switch branches/tags
Nothing to show
Latest commit be5736b Oct 15, 2013 @arosien s/pure/point/g
Permalink
Failed to load latest commit information.
core/src s/pure/point/g Oct 15, 2013
project scalaz7 Oct 14, 2013
LICENSE-2.0.txt initial commit Feb 24, 2013
README.md scalaz7 Oct 14, 2013
version.sbt initial commit Feb 24, 2013

README.md

Oddly enough, a Scala wrapper for Typesafe's (pure-Java) Config library.

Usage

import com.typesafe.config._
import net.rosien.configz._
import scalaz._
import Scalaz._

val config = ConfigFactory.load // or some other constructor from com.typesafe.config

// Config instances may be appended using Config.withFallback() semantics. (Config has a Monoid[Config])
val combinedConfig = config |+| ConfigFactory.parseFile(...)

// Define some paths to values of a certain type.
val boolPath: Configz[Boolean] = "some.path.to.a.bool".path[Boolean]
val intPath:  Configz[Int]     = "some.path.to.an.int".path[Int]

// Get the values at the path, which may fail with a com.typesafe.config.ConfigException.
val boolProp: Settings[Boolean] = config.get(boolPath)
val intProp:  Settings[Int]     = config.get(intPath)

// Note that Settings[A] is an alias for ValidationNEL[ConfigException, A].

// Configz is an applicative functor, so you can combine them (using scalaz operators like <*> or |@|):
val boolIntConfig: Configz[(Boolean, Int)]  = (boolPath |@| intPath)(_ -> _)
val boolIntProp:   Settings[(Boolean, Int)] = config.get(boolIntConfig)

// Configz paths can have custom validation:
val validatedIntPath = intPath.validate((_: Int) > 1000, "some.path.to.an.int must be > 1000")