[Config-loader] Config::Loader design

Robert Krimen robertkrimen at gmail.com
Tue Apr 28 02:01:56 GMT 2009

Thanks Clinton for organizing all those ideas into the wiki.

I've just put up some thoughts of mine at the wiki, which I'm sure you've
received updates notices about.

This was put under use cases:

Config::Loader::Stack # Each read configuration gets pushed onto this
Config::Loader::Read::Any (... using Config::Any)
Config::Loader::Read::General (... using Config::General)

my $loader =3D Config::Loader->new
$loader->setup_reader('Any' =3D> { ... Any setup (name, _local suffix, look=
$ENV, etc)... })
$loader->setup_parser('Substitute') # Does C::P::ConfigLoader style

$loader->read({ ... A hash containing default values ... })
$loader->read( 'any:path/to/config/directory' )
$loader->read( 'path/to/general-style.cnf' )
$loader->read( 'general:unknown-extension.txt' )

my $config =3D $loader->load # Does parsing and merging

The idea with the above being that Config::Loader as-is is just an API.
Projects can define the MyApplication::Config package which provides a
customized loader.
Config::Loader::Simple is a pre-packaged Config::Loader that works out of
the box.

Configuration loading goes through the following:


   1.  The read phase # Using ::Any, ::General, etc.
   2. The merge phase # Each read config can be given a weight when it is
   pushed on the stack. The default weight is 0
   3. The parse/filter phase # C::P::ConfigLoader-style substitution

Finally, return a collapsed hash back to the user which is the result of 1,
2, and 3

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/config-loader/attachments/20090427/=

More information about the Config-loader mailing list