The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
Changes 111
MANIFEST 023
META.yml 12
Makefile.PL 11
lib/Catalyst/Plugin/ConfigLoader.pm 23
t/21-mock_load_env.t 11
t/25-setting-config-file.t 0113
t/lib/TestApp1/Controller/Config.pm 019
t/lib/TestApp1/Controller/Root.pm 016
t/lib/TestApp1/customconfig.pl 03
t/lib/TestApp1/testapp1.pl 05
t/lib/TestApp1.pm 020
t/lib/TestApp2/Controller/Config.pm 019
t/lib/TestApp2/Controller/Root.pm 016
t/lib/TestApp2/customconfig.pl 03
t/lib/TestApp2/testapp2.pl 05
t/lib/TestApp2.pm 026
t/lib/TestApp3/Controller/Config.pm 018
t/lib/TestApp3/Controller/Root.pm 016
t/lib/TestApp3/config/another_file.pl 03
t/lib/TestApp3/config/testapp3.pl 03
t/lib/TestApp3/testapp3.pl 05
t/lib/TestApp3.pm 026
t/lib/TestApp4/Controller/Config.pm 018
t/lib/TestApp4/Controller/Root.pm 016
t/lib/TestApp4/config.d/another_file.pl 03
t/lib/TestApp4/config.d/testapp4.pl 03
t/lib/TestApp4/testapp.pl 05
t/lib/TestApp4.pm 026
29 files changed (This is a version diff) 6428
@@ -1,5 +1,15 @@
 Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
 
+0.34  Wed Apr 16 2014
+   - Repackage without non-standard tarball headers.
+
+0.33  Mon Jan 13 2014
+   - Fix config loading so that if passed a directory including
+     a . in the file name, then loading it as a directory works
+     (would have previously tried to force a specific filename
+     and failed)
+   - More comprehensive tests
+
 0.32  Thu Mar 14 2013
    - Don't ship .git inside the tarball, whoops.
 
@@ -30,7 +40,7 @@ Revision history for Perl extension Catalyst::Plugin::ConfigLoader.
       k-v pairs (RT #48557)
 
 0.25  Fri Aug 07 2009
-    - Fix get_config_local_suffix and get_config_path when finding values 
+    - Fix get_config_local_suffix and get_config_path when finding values
       from ENV vars (RT #47937)
 
 0.24  Mon Jun 29 2009
@@ -21,11 +21,34 @@ t/21-mock_load_env.t
 t/22-suffix_env.t
 t/23-path_env.t
 t/24-mock-shortappname.t
+t/25-setting-config-file.t
 t/98-pod_coverage.t
 t/99-pod.t
 t/lib/TestApp.pm
 t/lib/TestApp/Controller/Config.pm
 t/lib/TestApp/Controller/Root.pm
 t/lib/TestApp/testapp.pl
+t/lib/TestApp1.pm
+t/lib/TestApp1/Controller/Config.pm
+t/lib/TestApp1/Controller/Root.pm
+t/lib/TestApp1/customconfig.pl
+t/lib/TestApp1/testapp1.pl
+t/lib/TestApp2.pm
+t/lib/TestApp2/Controller/Config.pm
+t/lib/TestApp2/Controller/Root.pm
+t/lib/TestApp2/customconfig.pl
+t/lib/TestApp2/testapp2.pl
+t/lib/TestApp3.pm
+t/lib/TestApp3/config/another_file.pl
+t/lib/TestApp3/config/testapp3.pl
+t/lib/TestApp3/Controller/Config.pm
+t/lib/TestApp3/Controller/Root.pm
+t/lib/TestApp3/testapp3.pl
+t/lib/TestApp4.pm
+t/lib/TestApp4/config.d/another_file.pl
+t/lib/TestApp4/config.d/testapp4.pl
+t/lib/TestApp4/Controller/Config.pm
+t/lib/TestApp4/Controller/Root.pm
+t/lib/TestApp4/testapp.pl
 t/mockapp/mockapp.pl
 t/mockapp/mockapp_local.pl
@@ -4,6 +4,7 @@ author:
   - 'Brian Cassidy <bricas@cpan.org>'
 build_requires:
   ExtUtils::MakeMaker: 6.59
+  Path::Class: 0
   Test::More: 0
 configure_requires:
   ExtUtils::MakeMaker: 6.59
@@ -28,4 +29,4 @@ requires:
 resources:
   license: http://dev.perl.org/licenses/
   repository: git://git.shadowcat.co.uk/catagits/Catalyst-Plugin-ConfigLoader.git
-version: 0.32
+version: 0.34
@@ -15,8 +15,8 @@ requires 'Config::Any'       => '0.20';
 requires 'MRO::Compat'       => '0.09';
 
 test_requires 'Test::More';
+test_requires 'Path::Class';
 
 resources repository => 'git://git.shadowcat.co.uk/catagits/Catalyst-Plugin-ConfigLoader.git';
 
 WriteAll;
-
@@ -8,7 +8,7 @@ use MRO::Compat;
 use Data::Visitor::Callback;
 use Catalyst::Utils ();
 
-our $VERSION = '0.32';
+our $VERSION = '0.34';
 
 =head1 NAME
 
@@ -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{[\/\\]$}{};
@@ -6,7 +6,7 @@ use Cwd;
 # Remove all relevant env variables to avoid accidental fail
 foreach my $name ( grep { m{^(CATALYST|MOCKAPP)} } keys %ENV ) {
     delete $ENV{ $name };
-} 
+}
 
 $ENV{ CATALYST_HOME }  = cwd . '/t/mockapp';
 $ENV{ MOCKAPP_CONFIG } = $ENV{ CATALYST_HOME } . '/mockapp.pl';
@@ -0,0 +1,113 @@
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More;
+
+BEGIN {
+
+    # Remove all relevant env variables to avoid accidental fail
+    foreach my $name ( grep { m{^(CATALYST|MOCKAPP)} } keys %ENV ) {
+        delete $ENV{ $name };
+    }
+
+    eval { require Catalyst; Catalyst->VERSION( '5.80001' ); };
+
+    plan skip_all => 'Catalyst 5.80001 required' if $@;
+    plan tests => 18;
+
+    use Catalyst::Test ();
+
+}
+
+## TestApp1: a .conf config file exists but should not be loaded
+{
+
+    Catalyst::Test->import('TestApp1');
+
+    note( "TestApp1" );
+
+    ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
+
+    isa_ok( $c, "TestApp1" );
+
+    subtest "normal config loaded" => sub {
+
+        is( get( '/appconfig/foo' ), "bar1", "config var foo ok" );
+
+        ## a config var not set will give a blank web page hence ""
+        is( get( '/appconfig/bar' ), "", "config var in custom config" );
+
+    };
+    is( get( '/appconfig/bar' ), "", "custom config not loaded" );
+}
+
+## TestApp2: config points to a file in addition to normal config and
+## should get loaded
+{
+    Catalyst::Test->import('TestApp2');
+
+    note( "TestApp2" );
+
+    ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
+
+    isa_ok( $c, "TestApp2" );
+
+    subtest "normal config loaded" => sub {
+
+        is( get( '/appconfig/foo' ), "bar2", "config var foo" );
+
+        is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" );
+
+    };
+
+    is( get( '/appconfig/bar' ), "baz2", "custom config loaded" );
+}
+
+## TestApp3: config points to a directory
+{
+    Catalyst::Test->import('TestApp3');
+
+    note( "TestApp3" );
+
+    ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
+
+    isa_ok( $c, "TestApp3" );
+
+    subtest "normal config loaded" => sub {
+
+        is( get( '/appconfig/foo' ), "bar3", "config var foo" );
+
+        is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" );
+
+    };
+
+    is( get( '/appconfig/test3_conf3' ), "a_value", "custom config var3 set" );
+    is( get( '/appconfig/test3_conf4' ), "", "custom config var4 not set" );
+
+}
+
+## TestApp4: config points to a directory with a suffix
+{
+    Catalyst::Test->import('TestApp4');
+
+    note( "TestApp4" );
+
+    ok my ( $res, $c ) = ctx_request( '/' ), 'context object';
+
+    isa_ok( $c, "TestApp4" );
+
+    subtest "normal config loaded" => sub {
+
+        is( get( '/appconfig/foo' ), "bar4", "config var foo" );
+
+        is( get( '/appconfig/unspecified_variable' ), "", "unknown config var" );
+
+    };
+
+    is( get( '/appconfig/test4_conf3' ), "a_value", "custom config var3 set" );
+    is( get( '/appconfig/test4_conf4' ), "", "custom config var4 not set" );
+
+}
@@ -0,0 +1,19 @@
+package TestApp1::Controller::Config;
+
+use strict;
+use warnings;
+
+use base qw( Catalyst::Controller );
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->output( $self->{ foo } );
+}
+
+sub appconfig : Global {
+    my ( $self, $c, $var ) = @_;
+
+    $c->res->body( $c->config->{ $var } );
+}
+
+1;
@@ -0,0 +1,16 @@
+package TestApp1::Controller::Root;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config->{namespace} = '';
+
+sub default :Path {
+    my ( $self, $c ) = @_;
+    $c->response->body( 'Page not found' );
+    $c->response->status(404);
+}
+
+1;
@@ -0,0 +1,3 @@
+{
+    bar => "baz"
+}
@@ -0,0 +1,5 @@
+{   name               => 'TestApp2',
+    Controller::Config => { foo => 'foo' },
+    cache              => '__HOME__/cache',
+    multi              => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__',
+}
@@ -0,0 +1,20 @@
+package TestApp1;
+
+use strict;
+use warnings;
+
+use MRO::Compat;
+
+use Catalyst qw/ConfigLoader/;
+
+our $VERSION = '0.01';
+
+__PACKAGE__->setup;
+
+sub finalize_config {
+    my $c = shift;
+    $c->config( foo => 'bar1' );
+    $c->next::method( @_ );
+}
+
+1;
@@ -0,0 +1,19 @@
+package TestApp2::Controller::Config;
+
+use strict;
+use warnings;
+
+use base qw( Catalyst::Controller );
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->output( $self->{ foo } );
+}
+
+sub appconfig : Global {
+    my ( $self, $c, $var ) = @_;
+
+    $c->res->body( $c->config->{ $var } );
+}
+
+1;
@@ -0,0 +1,16 @@
+package TestApp2::Controller::Root;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config->{namespace} = '';
+
+sub default :Path {
+    my ( $self, $c ) = @_;
+    $c->response->body( 'Page not found' );
+    $c->response->status(404);
+}
+
+1;
@@ -0,0 +1,3 @@
+{
+    bar => "baz2"
+}
@@ -0,0 +1,5 @@
+{   name               => 'TestApp2',
+    Controller::Config => { foo => 'foo' },
+    cache              => '__HOME__/cache',
+    multi              => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__',
+}
@@ -0,0 +1,26 @@
+package TestApp2;
+
+use strict;
+use warnings;
+
+use MRO::Compat;
+
+use Catalyst qw/ConfigLoader/;
+
+__PACKAGE__->config( "Plugin::ConfigLoader",
+                     {
+                         file => __PACKAGE__->path_to( "customconfig.pl" )
+                     }
+                 );
+
+our $VERSION = '0.01';
+
+__PACKAGE__->setup;
+
+sub finalize_config {
+    my $c = shift;
+    $c->config( foo => 'bar2' );
+    $c->next::method( @_ );
+}
+
+1;
@@ -0,0 +1,18 @@
+package TestApp3::Controller::Config;
+
+use strict;
+use warnings;
+
+use base qw( Catalyst::Controller );
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->output( $self->{ foo } );
+}
+
+sub appconfig : Global {
+    my ( $self, $c, $var ) = @_;
+    $c->res->body( $c->config->{ $var } );
+}
+
+1;
@@ -0,0 +1,16 @@
+package TestApp3::Controller::Root;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config->{namespace} = '';
+
+sub default :Path {
+    my ( $self, $c ) = @_;
+    $c->response->body( 'Page not found' );
+    $c->response->status(404);
+}
+
+1;
@@ -0,0 +1,3 @@
+{
+    test4_conf => "this is not set"
+}
@@ -0,0 +1,3 @@
+{
+  test3_conf3 => "a_value"
+}
@@ -0,0 +1,5 @@
+{   name               => 'TestApp',
+    Controller::Config => { foo => 'foo' },
+    cache              => '__HOME__/cache',
+    multi              => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__',
+}
@@ -0,0 +1,26 @@
+package TestApp3;
+
+use strict;
+use warnings;
+
+use MRO::Compat;
+
+use Catalyst qw/ConfigLoader/;
+
+our $VERSION = '0.01';
+
+__PACKAGE__->config(
+    "Plugin::ConfigLoader" => {
+        file => __PACKAGE__->path_to( "config" )
+    }
+);
+
+__PACKAGE__->setup;
+
+sub finalize_config {
+    my $c = shift;
+    $c->config( foo => 'bar3' );
+    $c->next::method( @_ );
+}
+
+1;
@@ -0,0 +1,18 @@
+package TestApp4::Controller::Config;
+
+use strict;
+use warnings;
+
+use base qw( Catalyst::Controller );
+
+sub index : Private {
+    my ( $self, $c ) = @_;
+    $c->res->output( $self->{ foo } );
+}
+
+sub appconfig : Global {
+    my ( $self, $c, $var ) = @_;
+    $c->res->body( $c->config->{ $var } );
+}
+
+1;
@@ -0,0 +1,16 @@
+package TestApp4::Controller::Root;
+
+use strict;
+use warnings;
+
+use base 'Catalyst::Controller';
+
+__PACKAGE__->config->{namespace} = '';
+
+sub default :Path {
+    my ( $self, $c ) = @_;
+    $c->response->body( 'Page not found' );
+    $c->response->status(404);
+}
+
+1;
@@ -0,0 +1,3 @@
+{
+    test4_conf => "this is not set"
+}
@@ -0,0 +1,3 @@
+{
+  test4_conf3 => "a_value"
+}
@@ -0,0 +1,5 @@
+{   name               => 'TestApp',
+    Controller::Config => { foo => 'foo' },
+    cache              => '__HOME__/cache',
+    multi              => '__HOME__,__path_to(x)__,__HOME__,__path_to(y)__',
+}
@@ -0,0 +1,26 @@
+package TestApp4;
+
+use strict;
+use warnings;
+
+use MRO::Compat;
+
+use Catalyst qw/ConfigLoader/;
+
+our $VERSION = '0.01';
+
+__PACKAGE__->config(
+    "Plugin::ConfigLoader" => {
+        file => __PACKAGE__->path_to( "config.d" )
+    }
+);
+
+__PACKAGE__->setup;
+
+sub finalize_config {
+    my $c = shift;
+    $c->config( foo => 'bar4' );
+    $c->next::method( @_ );
+}
+
+1;