ciris-hocon


License

License

GroupId

GroupId

lt.dvim.ciris-hocon
ArtifactId

ArtifactId

ciris-hocon_2.12
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

ciris-hocon
ciris-hocon
Project URL

Project URL

https://github.com/2m/ciris-hocon
Project Organization

Project Organization

Martynas Mickevičius
Source Code Management

Source Code Management

https://github.com/2m/ciris-hocon

Download ciris-hocon_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/lt.dvim.ciris-hocon/ciris-hocon_2.12/ -->
<dependency>
    <groupId>lt.dvim.ciris-hocon</groupId>
    <artifactId>ciris-hocon_2.12</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/lt.dvim.ciris-hocon/ciris-hocon_2.12/
implementation 'lt.dvim.ciris-hocon:ciris-hocon_2.12:0.1'
// https://jarcasting.com/artifacts/lt.dvim.ciris-hocon/ciris-hocon_2.12/
implementation ("lt.dvim.ciris-hocon:ciris-hocon_2.12:0.1")
'lt.dvim.ciris-hocon:ciris-hocon_2.12:jar:0.1'
<dependency org="lt.dvim.ciris-hocon" name="ciris-hocon_2.12" rev="0.1">
  <artifact name="ciris-hocon_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='lt.dvim.ciris-hocon', module='ciris-hocon_2.12', version='0.1')
)
libraryDependencies += "lt.dvim.ciris-hocon" % "ciris-hocon_2.12" % "0.1"
[lt.dvim.ciris-hocon/ciris-hocon_2.12 "0.1"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
is.cir : ciris-core_2.12 jar 0.12.1
com.typesafe : config jar 1.3.3

test (1)

Group / Artifact Type Version
org.scalatest : scalatest_2.12 jar 3.0.5

Project Modules

There are no modules declared in this project.

ciris-hocon scaladex-badge ci-badge gitter-badge

ciris-hocon provides a HOCON configuration source for Ciris configuration loading library.

The implementation of this library was created by following the excellent Ciris documentation.

Setup

Add the dependency to your project build settings:

libraryDependencies += "lt.dvim.ciris-hocon" %% "ciris-hocon" % "0.2"

Or a snapshot from a snapshot repository for which you will need an additional resolver:

resolvers += Resolver.bintrayRepo("2m", "snapshots")
version scala ciris
0.1 2.12 0.12.1
0.2 2.13 0.13.0-RC1
upstream 2.12, 2.13 1.0.x

Example usage

This library provides configuration sources as well as decoders from ConfigValue values.

import ciris._
import lt.dvim.ciris.Hocon._
import com.typesafe.config.ConfigFactory
import scala.concurrent.duration._
import java.time.Period

val config = ConfigFactory.parseString("""
    |rate {
    |  elements = 2
    |  burst-duration = 100 millis
    |  check-interval = 2 weeks
    |}
  """.stripMargin)

case class Rate(elements: Int, burstDuration: FiniteDuration, checkInterval: Period)

val hocon = hoconAt(config)("rate")
val rate = loadConfig(
  hocon[Int]("elements"),
  hocon[FiniteDuration]("burst-duration"),
  hocon[Period]("check-interval")
)(Rate.apply).orThrow()

rate.burstDuration shouldBe 100.millis
rate.checkInterval shouldBe Period.ofWeeks(2)

Licence

Copyright 2018 Martynas Mickevičius

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Versions

Version
0.1