The configuration manager perl module is used to dynamicaly load YAML configuration files with leazy load
To define a repository, several ways exists:
The repositories defined by the use statement are shared between each configuration manager.
use FindBin;
use configurationManager ["repo=".$FindBin::Bin."/conf", "repo=/an/other/config"];
By instanciate a new configurationManager with repositories, you assign to this manager a self repository that is not shared with the others.
use configurationManager;
my $altConfig = configurationManager->new({
repositories => [$FindBin::Bin."/altConf"],
});
The configurationManager offer access to the configuration behind the 'get' subroutine. The parameter to give as argument is the configuration filename without extension. If the file is into a recursive repository, give the relative path to it.
/path/to/the/repository:
-> myConfig.yaml
-> mySecondConfig.yaml
-> aDirectory:
-> anotherConfig.yaml
hello: "world"
my: "name"
hello: "state"
my: "purpose"
use configurationManager;
use Data::Dumper;
my $manager = configurationManager->new({
repositories => ["/path/to/the/repository"],
});
print Dumper $manager->get("myConfig");
# $VAR1 = {
# 'hello' => 'world',
# 'my' => 'name'
# };
print Dumper $manager->get("aDirectory/anotherConfig");
# $VAR2 = {
# 'hello' => 'state',
# 'my' => 'purpose'
# };
name | purpose | content |
---|---|---|
import | Import another configuration | scalar OR array |
The import key is used to automatically load another configuration into the current one. Note, the importation is done by first level key, and the imported configuration never override the current.
/path/to/the/repository:
-> myConfig.yaml
-> mySecondConfig.yaml
hello: "world"
my: "name"
import: "mySecondConfig"
is: "bergamote"
and: 'I'
eat: "strudle"
use configurationManager;
use Data::Dumper;
my $manager = configurationManager->new({
repositories => ["/path/to/the/repository"],
});
print Dumper $manager->get("myConfig");
# $VAR1 = {
# 'hello' => 'world',
# 'my' => 'name',
# 'is' => 'bergamote',
# 'and' => 'I',
# 'eat' => 'strudle'
# };