fixed suffix appending to explicit config paths.
Brian Cassidy [Wed, 21 Nov 2007 13:13:04 +0000 (13:13 +0000)]
Changes
lib/Catalyst/Plugin/ConfigLoader.pm
t/21-mock_load_env.t [new file with mode: 0644]

diff --git a/Changes b/Changes
index 06e3918..0a04f8a 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
 
+0.19  Wed Nov 21 2007
+    - fixed suffix appending to explicit config paths
+
 0.18  Sat Oct 13 2007
     - fix indentation on manual entry for DBIC::Schema config (Jeremy Wall)
       RT #29967
index cd8a556..e8d44af 100644 (file)
@@ -8,7 +8,7 @@ use NEXT;
 use Data::Visitor::Callback;
 use Catalyst::Utils ();
 
-our $VERSION = '0.18';
+our $VERSION = '0.19';
 
 =head1 NAME
 
@@ -113,7 +113,8 @@ sub find_files {
     my @files;
     if ($extension) {
         next unless grep { $_ eq $extension } @extensions;
-        push @files, $path, "${path}_${suffix}";
+        ( my $local = $path ) =~ s{\.$extension}{_$suffix.$extension};
+        push @files, $path, $local;
     } else {
         @files = map { ( "$path.$_", "${path}_${suffix}.$_" ) } @extensions;
     }
@@ -170,7 +171,7 @@ sub get_config_path {
         $path  =~ s{[\/\\]$}{};
         $path .= "/$prefix";
     }
-    
+
     return( $path, $extension );
 }
 
diff --git a/t/21-mock_load_env.t b/t/21-mock_load_env.t
new file mode 100644 (file)
index 0000000..f5fd60a
--- /dev/null
@@ -0,0 +1,24 @@
+package MockApp;
+
+use Test::More tests => 9;
+
+use Cwd;
+$ENV{ CATALYST_HOME } = cwd . '/t/mockapp';
+$ENV{ MOCKAPP_CONFIG } = $ENV{ CATALYST_HOME } . '/mockapp.pl';
+
+use_ok( 'Catalyst', qw( ConfigLoader ) );
+
+__PACKAGE__->config->{ 'Plugin::ConfigLoader' }->{ substitutions } = {
+    foo => sub { shift; join('-', @_); }
+};
+
+__PACKAGE__->setup;
+
+ok( __PACKAGE__->config );
+is( __PACKAGE__->config->{ 'Controller::Foo' }->{ foo }, 'bar' );
+is( __PACKAGE__->config->{ 'Controller::Foo' }->{ new }, 'key' );
+is( __PACKAGE__->config->{ 'Model::Baz' }->{ qux }, 'xyzzy' );
+is( __PACKAGE__->config->{ 'Model::Baz' }->{ another }, 'new key' );
+is( __PACKAGE__->config->{ 'view' }, 'View::TT::New' );
+is( __PACKAGE__->config->{ 'foo_sub' }, 'x-y' );
+is( __PACKAGE__->config->{ 'literal_macro' }, '__DATA__' );