Skip to content

Commit

Permalink
Allow ChronoUnitReader to accept - (i.e. half-days)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdedetrich committed Sep 9, 2021
1 parent 537fd6f commit e1a1cb4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait ChronoUnitReader {

/** Reads the value at the path `path` in the Config */
override def read(config: Config, path: String): ChronoUnit =
ChronoUnit.valueOf(config.getString(path).toUpperCase)
ChronoUnit.valueOf(config.getString(path).toUpperCase.replace('-', '_'))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ class ChronoUnitReaderSpec extends Spec {
chronoUnit should_== expected
}

def readChronoUnitHalfDaysDash = {
val cfg = ConfigFactory.parseString(s"""
| foo {
| chrono-unit = "half-days"
| }
""".stripMargin)
val chronoUnit = cfg.as[ChronoUnit]("foo.chrono-unit")
val expected = ChronoUnit.HALF_DAYS
chronoUnit should_== expected
}

}

0 comments on commit e1a1cb4

Please sign in to comment.