Skip to content

The configuration manager perl module is used to dynamicaly load YAML configuration files with leazy load

License

Notifications You must be signed in to change notification settings

cscfa/perl-module-configurationManager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

perl-module-configurationManager

The configuration manager perl module is used to dynamicaly load YAML configuration files with leazy load

Define the configuration repository:

To define a repository, several ways exists:

With use statement :

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"];

With the 'new' subroutine

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"],
});

Get configuration

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.

Example:

/path/to/the/repository:
	-> myConfig.yaml
	-> mySecondConfig.yaml
	-> aDirectory:
		-> anotherConfig.yaml
content of /path/to/the/repository/myConfig.yaml :
hello: "world"
my: "name"
content of /path/to/the/repository/aDirectory/anotherConfig.yaml :
hello: "state"
my: "purpose"
code :
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'
# };

Reserved keys :

name purpose content
import Import another configuration scalar OR array

Import

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.

example:
/path/to/the/repository:
	-> myConfig.yaml
	-> mySecondConfig.yaml
content of /path/to/the/repository/myConfig.yaml :
hello: "world"
my: "name"
import: "mySecondConfig"
content of /path/to/the/repository/mySecondConfig.yaml :
is: "bergamote"
and: 'I'
eat: "strudle"
code :
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'
# };

About

The configuration manager perl module is used to dynamicaly load YAML configuration files with leazy load

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages