From: Brian Cassidy Date: Tue, 18 Apr 2006 23:25:40 +0000 (+0000) Subject: attemp to load local config X-Git-Tag: v0.05^0 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Plugin-ConfigLoader.git;a=commitdiff_plain;h=04ea923f91f29550671e555bc8606b59ec778eef attemp to load local config updated docs updated Changes bumped version --- diff --git a/Changes b/Changes index dcc1191..28c3b30 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,11 @@ Revision history for Perl extension Catalyst::Plugin::ConfigLoader. +0.05 Thu Apr 18 2006 + - __HOME__ now corresponds to $c->path_to( '' ) and nothing else + - __path_to( 'foo/bar' )__ turns in to $c->path_to( 'foo', 'bar' ) + - attemps to load ${config}_local.$ext after ${config}.$ext for + an overriding effect + 0.04 Wed Feb 08 2006 - add finalize_config method - make default finalize_config traverse the config and substitute diff --git a/lib/Catalyst/Plugin/ConfigLoader.pm b/lib/Catalyst/Plugin/ConfigLoader.pm index fc68afb..f073ccf 100644 --- a/lib/Catalyst/Plugin/ConfigLoader.pm +++ b/lib/Catalyst/Plugin/ConfigLoader.pm @@ -10,7 +10,7 @@ use Module::Pluggable::Fast require => 1; use Data::Visitor::Callback; -our $VERSION = '0.04'; +our $VERSION = '0.05'; =head1 NAME @@ -30,17 +30,21 @@ Catalyst::Plugin::ConfigLoader - Load config files of various types =head1 DESCRIPTION -This mdoule will attempt to load find and load a configuration +This module will attempt to load find and load a configuration file of various types. Currently it supports YAML, JSON, XML, INI and Perl formats. +To support the distinction between development and production environments, +this module will also attemp to load a local config (e.g. myapp_local.yaml) +which will override any duplicate settings. + =head1 METHODS =head2 setup( ) This method is automatically called by Catalyst's setup routine. It will attempt to use each plugin and, once a file has been successfully -loaded, set the C section. +loaded, set the C section. =cut @@ -58,7 +62,7 @@ sub setup { push @files, $path; } else { - push @files, "$path.$_" for @extensions; + @files = map { ( "$path.$_", "${path}_local.$_" ) } @extensions; } for( @files ) { @@ -84,8 +88,10 @@ at runtime. If you need to do this to properly configure any plugins, it's important to load ConfigLoader before them. ConfigLoader provides a default finalize_config method which walks through the loaded config hash and replaces any strings -beginning with C<< __HOME__/ >> with the full path to -the file inside the app's home directory. +beginning containing C<__HOME__> with the full path to +app's home directory (i.e. C<$c-Epath_to('')> ). +You can also use C<__path_to('foo/bar')__> which translates to +C<$c-Epath_to('foo', 'bar')> =cut