multiple replaces for __HOME__ and __path_to()__ v0.15
Brian Cassidy [Tue, 21 Aug 2007 14:53:42 +0000 (14:53 +0000)]
Changes
lib/Catalyst/Plugin/ConfigLoader.pm
t/10-live_auto.t
t/lib/TestApp/testapp.pl

diff --git a/Changes b/Changes
index 45860c8..429ad86 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
 
+0.15  Tue Aug 21 2007
+    - Allow multiple __HOME__ and __path_to()__ replaces in one string
+      (Greg Sheard)
+
 0.14  Tue Apr 03 2007
     - switch to Module::Install
     - added a user manual
index e3ffddc..a12539e 100644 (file)
@@ -7,7 +7,7 @@ use Config::Any;
 use NEXT;
 use Data::Visitor::Callback;
 
-our $VERSION = '0.14';
+our $VERSION = '0.15';
 
 =head1 NAME
 
@@ -228,8 +228,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 );
index 8420c27..5ec9575 100644 (file)
@@ -4,7 +4,7 @@ use warnings;
 use FindBin;
 use lib "$FindBin::Bin/lib";
 
-use Test::More tests => 4;
+use Test::More tests => 5;
 
 use Catalyst::Test 'TestApp';
 
@@ -18,4 +18,9 @@ use Catalyst::Test 'TestApp';
 
     $response = request('http://localhost/appconfig/foo');
     is( $response->content, 'bar', 'app finalize_config works' );
+
+    $response = request('http://localhost/appconfig/multi');
+    my $home = TestApp->config->{ home };
+    my $path = join( ',', $home, TestApp->path_to( 'x' ), $home, TestApp->path_to( 'y' ) );
+    is( $response->content, $path, 'vars substituted in config var, twice' );
 }
index eecc78b..d956bdc 100644 (file)
@@ -4,4 +4,5 @@
         foo => 'foo'
     },
     cache              => '__HOME__/cache',
+    multi              => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__',
 }