fix configloader to use Catalyst::Utils::env_value()
[catagits/Catalyst-Plugin-ConfigLoader.git] / lib / Catalyst / Plugin / ConfigLoader.pm
index bf688d0..8763331 100644 (file)
@@ -6,8 +6,9 @@ use warnings;
 use Config::Any;
 use NEXT;
 use Data::Visitor::Callback;
+use Catalyst::Utils ();
 
-our $VERSION = '0.14';
+our $VERSION = '0.16';
 
 =head1 NAME
 
@@ -130,6 +131,8 @@ The order of preference is specified as:
 
 =item * C<$ENV{ MYAPP_CONFIG }>
 
+=item * C<$ENV{ CATALYST_CONFIG }>
+
 =item * C<$c-E<gt>config-E<gt>{ file }>
 
 =item * C<$c-E<gt>path_to( $application_prefix )>
@@ -145,7 +148,7 @@ sub get_config_path {
     my $c       = shift;
     my $appname = ref $c || $c;
     my $prefix  = Catalyst::Utils::appprefix( $appname );
-    my $path    = $ENV{ Catalyst::Utils::class2env( $appname ) . '_CONFIG' }
+    my $path    = Catalyst::Utils::env_value( $c, 'CONFIG' )
         || $c->config->{ file }
         || $c->path_to( $prefix );
 
@@ -166,10 +169,10 @@ this value is C<local>, but it can be specified in the following order of prefer
 
 =over 4
 
-=item * C<$ENV{ CATALYST_CONFIG_LOCAL_SUFFIX }>
-
 =item * C<$ENV{ MYAPP_CONFIG_LOCAL_SUFFIX }>
 
+=item * C<$ENV{ CATALYST_CONFIG_LOCAL_SUFFIX }>
+
 =item * C<$c-E<gt>config-E<gt>{ config_local_suffix }>
 
 =back
@@ -179,8 +182,7 @@ this value is C<local>, but it can be specified in the following order of prefer
 sub get_config_local_suffix {
     my $c       = shift;
     my $appname = ref $c || $c;
-    my $suffix  = $ENV{ CATALYST_CONFIG_LOCAL_SUFFIX }
-        || $ENV{ Catalyst::Utils::class2env( $appname ) . '_CONFIG_LOCAL_SUFFIX' }
+    my $suffix  = Catalyst::Utils::env_value( $c, 'CONFIG_LOCAL_SUFFIX' )
         || $c->config->{ config_local_suffix }
         || 'local';
 
@@ -228,8 +230,8 @@ sub finalize_config {
     my $v = Data::Visitor::Callback->new(
         plain_value => sub {
             return unless defined $_;
-            s{__HOME__}{ $c->path_to( '' ) }e;
-            s{__path_to\((.+)\)__}{ $c->path_to( split( '/', $1 ) ) }e;
+            s{__HOME__}{ $c->path_to( '' ) }eg;
+            s{__path_to\((.+?)\)__}{ $c->path_to( split( '/', $1 ) ) }eg;
         }
     );
     $v->visit( $c->config );
@@ -237,11 +239,7 @@ sub finalize_config {
 
 =head1 AUTHOR
 
-=over 4
-
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>
-
-=back
+Brian Cassidy E<lt>bricas@cpan.orgE<gt>
 
 =head1 CONTRIBUTORS
 
@@ -266,7 +264,7 @@ Work to this module has been generously sponsored by:
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006 by Brian Cassidy
+Copyright 2007 by Brian Cassidy
 
 This library is free software; you can redistribute it and/or modify
 it under the same terms as Perl itself.