[Config-loader] [Config Loader] Use cases was updated
Config Loader
noreply at google.com
Fri Aug 22 22:55:55 BST 2008
Clinton Gormley updated the page Use cases. View the changes below.
Color key: Insertion | Deletion
The "basic" C::P::ConfigLoader scenario
User has main config "myapp.conf", and wants to allow local overrides =
in "myapp_local.conf"
Directory tree
User has a number of files in a directory tree. CL recurses through the =
tree, loading each file, and inserting it into the config hash with the =
directory name and the file name as branches in the tree, for instance:
/app
/db
/main.conf
->
$config =3D { app =3D> { db =3D> { main =3D> $file_contents }}}
The contents of local override files could be applied at any point in the =
tree.
The "basic" C::P::ConfigLoader scenario
User has main config "myapp.conf", and wants to allow local overrides =
in "myapp_local.conf"
Directory tree
User has a number of files in a directory tree. CL recurses through the =
tree, loading each file, and inserting it into the config hash with the =
directory name and the file name as branches in the tree, for instance:
/app
/db
/main.conf
->
$config =3D { app =3D> { db =3D> { main =3D> $file_contents }}}
The contents of local override files could be applied at any point in the =
tree.
Specific filename
# Load the config directly
my $config =3D Config::Loader->new( file =3D> path/to/config.conf )
path/to/application_home/xyzzy.conf
path/to/application_home/xyzzy_local.conf
path/to/application_home/xyzzy.yml
path/to/application_home/xyzzy_local.yml
...
Base file name
# Guess at possible config files
my $config =3D Config::Loader->new( name =3D> xyzzy, path =3D> =
path/to/application_home/ )
Using ENV for file location
With the second style of instantiation, Config::JFDI will also lookup =
$ENV{uc $name . _CONFIG}, etc. for ENV overriding
Filtering which files are loaded
Only load that config files that (eg) pertain to this process' role, or are=
=
relevant to this particular machine (eg with hostname).
$config =3D Config::Loader->new({
path =3D> '/path/to/load',
load_if =3D> qr/.*_daemon/,
| skip_if =3D> qr/.*_daemon/,
});
load_if and skip_if could accept scalars (eq), regexes , code refs , hash =
refs (exists), or array refs containing any of the previous ( load_if loads=
=
and skip_if skips at the first true value).
The matching would be performed against the 'pseudo-path', for instance =
for './app/db/main.yaml', the matching would be performed =
against 'app.db.main'.
Should skip_if be called load_unless instead, for concistency with merge_if=
=
/ merge_unless below?
Filtering which files are merged (local overrides)
The user may want to control which files are intended for merging, instead =
of loading:
$config =3D Config::Loader->new({
path =3D> '/path/to/load',
merge_if =3D> qr/.*_local/,
| merge_unless =3D> qr/.*_local/,
});
To be considered for merging, the file would first have to be have passed =
the load_if and skip_if checks.
Go to page: Use cases
-------------
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/20080822/=
8c6cbda4/attachment-0001.htm
More information about the Config-loader
mailing list