X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FCatalyst%2FPlugin%2FConfigLoader.pm;h=a0a57a658f516fa556f49be8f01b91f7a78b53c9;hb=8089b9e4a1f9f70488a4dc2c70fd74d029dc6d89;hp=e13712045d79efa7836f9d309c44b4de8d1d7dfc;hpb=5bdb6290f42eb75d022c59f2f2f573163bbb4bd5;p=catagits%2FCatalyst-Plugin-ConfigLoader.git diff --git a/lib/Catalyst/Plugin/ConfigLoader.pm b/lib/Catalyst/Plugin/ConfigLoader.pm index e137120..a0a57a6 100644 --- a/lib/Catalyst/Plugin/ConfigLoader.pm +++ b/lib/Catalyst/Plugin/ConfigLoader.pm @@ -8,7 +8,7 @@ use MRO::Compat; use Data::Visitor::Callback; use Catalyst::Utils (); -our $VERSION = '0.28'; +our $VERSION = '0.35'; =head1 NAME @@ -26,21 +26,21 @@ Catalyst::Plugin::ConfigLoader - Load config files of various types # you can specify a file if you'd like __PACKAGE__->config( 'Plugin::ConfigLoader' => { file => 'config.yaml' } ); - In the file, assuming it's in YAML format: +In the file, assuming it's in YAML format: foo: bar - Accessible through the context object, or the class itself +Accessible through the context object, or the class itself - $c->config->{foo} # bar - MyApp->config->{foo} # bar + $c->config->{foo} # bar + MyApp->config->{foo} # bar =head1 DESCRIPTION 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. Special configuration for a particular driver format can -be stored in Cconfig-E{ 'Plugin::ConfigLoader' }-E{ driver }>. +be stored in C<< MyApp->config->{ 'Plugin::ConfigLoader' }->{ driver } >>. For example, to pass arguments to L, use the following: __PACKAGE__->config( 'Plugin::ConfigLoader' => { @@ -52,9 +52,9 @@ For example, to pass arguments to L, use the following: See L's C parameter for more information. To support the distinction between development and production environments, -this module will also attemp to load a local config (e.g. myapp_local.yaml) +this module will also attemp to load a local config (e.g. F) which will override any duplicate settings. See -L +L for details on how this is configured. =head1 METHODS @@ -125,7 +125,7 @@ sub load_config { This method determines the potential file paths to be used for config loading. It returns an array of paths (up to the filename less the extension) to pass to -L for loading. +L for loading. =cut @@ -162,9 +162,9 @@ The order of preference is specified as: =item * C<$ENV{ CATALYST_CONFIG }> -=item * C<$c-Econfig-E{ 'Plugin::ConfigLoader' }-E{ file }> +=item * C<< $c->config->{ 'Plugin::ConfigLoader' }->{ file } >> -=item * C<$c-Epath_to( $application_prefix )> +=item * C<< $c->path_to( $application_prefix ) >> =back @@ -183,7 +183,8 @@ sub get_config_path { || $c->config->{ 'Plugin::ConfigLoader' }->{ file } || $c->path_to( $prefix ); - my ( $extension ) = ( $path =~ m{\.([^/\.]{1,4})$} ); + ## don't look for extension if this is a dir + my ( $extension ) = !-d $path ? ( $path =~ m{\.([^\/\\.]{1,4})$} ) : () ; if ( -d $path ) { $path =~ s{[\/\\]$}{}; @@ -205,7 +206,7 @@ be specified in the following order of preference: =item * C<$ENV{ CATALYST_CONFIG_LOCAL_SUFFIX }> -=item * C<$c-Econfig-E{ 'Plugin::ConfigLoader' }-E{ config_local_suffix }> +=item * C<< $c->config->{ 'Plugin::ConfigLoader' }->{ config_local_suffix } >> =back @@ -213,8 +214,8 @@ The first one of these values found replaces the default of C in the name of the local config file to be loaded. For example, if C< $ENV{ MYAPP_CONFIG_LOCAL_SUFFIX }> is set to C, -ConfigLoader will try and load C instead of -C. +ConfigLoader will try and load F instead of +F. =cut @@ -254,9 +255,9 @@ This method is called after the config file is loaded. It can be used to implement tuning of config values that can only be done 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 calls the C -sub on any string. +ConfigLoader provides a default C method which +walks through the loaded config hash and calls the +L method on any string. =cut @@ -291,7 +292,7 @@ C<__DATA__> as a config value, for example) The parameter list is split on comma (C<,>). You can override this method to do your own string munging, or you can define your own macros in -Cconfig-E{ 'Plugin::ConfigLoader' }-E{ substitutions }>. +C<< MyApp->config->{ 'Plugin::ConfigLoader' }->{ substitutions } >>. Example: MyApp->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = { @@ -329,7 +330,7 @@ sub config_substitutions { =head1 AUTHOR -Brian Cassidy Ebricas@cpan.orgE +Brian Cassidy =head1 CONTRIBUTORS @@ -338,9 +339,9 @@ development of this module: =over 4 -=item * Joel Bernstein Erataxis@cpan.orgE - Rewrite to use L +=item * Joel Bernstein - Rewrite to use L -=item * David Kamholz Edkamholz@cpan.orgE - L integration +=item * David Kamholz - L integration =item * Stuart Watt - Addition of ENV macro.