Skip to content

Latest commit

 

History

History

cron4s

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Cron4s module for PureConfig

Adds support for Cron4s's CronExpr class to PureConfig.

Add pureconfig-cron4s to your project

In addition to core PureConfig, you'll need:

libraryDependencies += "com.github.pureconfig" %% "pureconfig-cron4s" % "0.17.4"

Example

To load an CronExpr into a configuration, create a class to hold it:

import cron4s.expr.CronExpr
import com.typesafe.config.ConfigFactory.parseString
import pureconfig._
import pureconfig.generic.auto._
import pureconfig.module.cron4s._

case class MyConfig(schedule: CronExpr)

We can read a MyConfig with the following code:

val conf = parseString("""{ schedule: "10-35 2,4,6 * ? * *" }""")
// conf: com.typesafe.config.Config = Config(SimpleConfigObject({"schedule":"10-35 2,4,6 * ? * *"}))

ConfigSource.fromConfig(conf).load[MyConfig]
// res0: ConfigReader.Result[MyConfig] = Right(
//   MyConfig(CronExpr(10-35, 2,4,6, *, ?, *, *))
// )