Configuration Refinements
Branch: master
Clone or download
Latest commit 2c2d9f0 Jun 2, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
doc version and comments Jun 2, 2018
label license label on top of readme Oct 19, 2016
lib/Config/DataLang
t
xt Avoid use of removed method Apr 11, 2017
.gitignore documentation Jun 3, 2016
.travis.yml dropped cache Apr 19, 2017
LICENSE start of project Jun 1, 2016
META6.json version and comments Jun 2, 2018
README.md pod doc and readme Dec 27, 2016
appveyor.yml modified to use zef instead of panda Apr 19, 2017

README.md

Configuration refinements

Build Status AppVeyor Build Status License

Synopsis

The following piece of code

use Config::DataLang::Refine;

my Config::DataLang::Refine $c .= new(:config-name<myConfig.toml>);

my Hash $hp1 = $c.refine(<options plugin1 test>);
my Hash $hp2 = $c.refine(<options plugin2 deploy>);

With the following config file in myConfig.toml

[options]
  key1 = 'val1'

[options.plugin1]
  key2 = 'val2'

[options.plugin1.test]
  key1 = false
  key2 = 'val3'

[options.plugin2.deploy]
  key3 = 'val3'

Will get you the following as if $hp* is set like

$hp1 = { key2 => 'val3'};
$hp2 = { key1 => 'val1', key3 => 'val3'};

A better example might be from the MongoDB project to test several server setups, the config again in TOML format;

[mongod]
  journal = false
  fork = true
  smallfiles = true
  oplogSize = 128
  logappend = true

# Configuration for Server 1
[mongod.s1]
  logpath = './Sandbox/Server1/m.log'
  pidfilepath = './Sandbox/Server1/m.pid'
  dbpath = './Sandbox/Server1/m.data'
  port = 65010

[mongod.s1.replicate1]
  replSet = 'first_replicate'

[mongod.s1.replicate2]
  replSet = 'second_replicate'

[mongod.s1.authenticate]
  auth = true

Now, to get run options to start server 1 one does the following;

my Config::DataLang::Refine $c .= new(:config-name<mongoservers.toml>);
my Array $opts = $c.refine-str( <mongod s1 replicate1>, :C-UNIX-OPTS-T2);

# Output
# --nojournal, --fork, --smallfiles, --oplogSize=128, --logappend,
# --logpath='./Sandbox/Server1/m.log', --pidfilepath='./Sandbox/Server1/m.pid',
# --dbpath='./Sandbox/Server1/m.data', --port=65010, --replSet=first_replicate

Easy to run the server now;

my Proc $proc = shell(('/usr/bin/mongod', |@$opts).join(' '));

Description

The Config::DataLang::Refine class adds facilities to use a configuration file and gather the key value pairs by searching top down a list of keys thereby refining the resulting set of keys. Boolean values are used to add a key without a value when True or to cancel a previously found key out when False.

Documentation

Look for documentation and other information at