[Config-loader] [Config Loader] Controlling which files / dirs are loaded was updated

Config Loader noreply at google.com
Sat Aug 30 15:22:08 BST 2008


Clinton Gormley updated the page Controlling which files / dirs are loaded.=
  =

View the changes below.
Color key: Insertion | Deletion


load_if and load_unless can be used to control which files or dirs are  =

loaded. Each can contain a single rule, or a list of rules. The first true  =

value will be returned and the subsequent rules will not be checked.

load_if rules will be run before load_unless . So if load_if returns true,  =

and load_unless ALSO returns true, the end result will be DO NOT LOAD.

By default, these rules will operate on the base name of the current file /=
  =

dir. There will also be load_if_path or load_unless_path , which will  =

operate on the full path relative to the root.

For instance:


if we've said: load path ' /opt/app/config/ '

and we're currently looking at ' /opt/app/config/db/main/creds.yml '

then the 'path' would be ' db.main.creds '
Do we also need load_if_file and load_if_dir ?


Possible values
The values passed to load_if* and load_unless* can be:


a string -> eq
a regex -> m//
a sub ref -> $_->($name)
a hash ref -> exists $_->{$name}

an array ref, which can contain any of the above



$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
load_if =3D> qr/^default_/,
load_unless =3D> qr/_test/,
});

$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
load_if_path =3D> qr/\.default_/,
load_unless_path =3D> qr/_test/,
});

$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
load_if =3D> sub {my $name =3D shift; ...},
load_unless =3D> sub { my $name =3D shift; ...},
});

$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
load_if =3D> [ qr/^default/, sub { my $name =3D shift; ...}],
load_unless =3D> [ qr/_test/, sub { my $name =3D shift; ...}],
});

$c =3D Config::Loader->new({
path =3D> '/path/to/conf/tree/',
load_if =3D> [ qr/^default/, sub { my $name =3D shift; ...}],
load_unless =3D> [ qr/_test/, sub { my $name =3D shift; ...}],
});




Go to page: Controlling which files / dirs are loaded


-------------
You requested this notification from Google Sites. You can unsubscribe at  =

any time.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/config-loader/attachments/20080830/=
4f37a845/attachment-0001.htm


More information about the Config-loader mailing list