[Catalyst-commits] r8354 - in branches/Config-Any/unsupported_error: . lib/Config t

bricas at dev.catalyst.perl.org bricas at dev.catalyst.perl.org
Thu Sep 4 14:52:33 BST 2008


Author: bricas
Date: 2008-09-04 14:52:33 +0100 (Thu, 04 Sep 2008)
New Revision: 8354

Added:
   branches/Config-Any/unsupported_error/t/64-extfail.t
Modified:
   branches/Config-Any/unsupported_error/Changes
   branches/Config-Any/unsupported_error/lib/Config/Any.pm
   branches/Config-Any/unsupported_error/t/10-branches.t
Log:
when use_ext is true, a fatal error will be thrown if there are no loaders available that understand the file extension

Modified: branches/Config-Any/unsupported_error/Changes
===================================================================
--- branches/Config-Any/unsupported_error/Changes	2008-09-04 08:16:16 UTC (rev 8353)
+++ branches/Config-Any/unsupported_error/Changes	2008-09-04 13:52:33 UTC (rev 8354)
@@ -4,6 +4,8 @@
     - when use_ext is true, we will check to see if there are no supported
       modules for a particular file. instead of the file being skipped, an
       error will be thrown.
+    - also, when use_ext is true, a fatal error will be thrown if there are
+      no loaders available that understand the file extension.
     - officially support multiple loaders per extension
     - add a Config::Any::Base for all loaders to inherit from, plus add
       a new dependency mechanism: requires_any_of() and requires_all_of().

Modified: branches/Config-Any/unsupported_error/lib/Config/Any.pm
===================================================================
--- branches/Config-Any/unsupported_error/lib/Config/Any.pm	2008-09-04 08:16:16 UTC (rev 8353)
+++ branches/Config-Any/unsupported_error/lib/Config/Any.pm	2008-09-04 13:52:33 UTC (rev 8354)
@@ -177,7 +177,12 @@
 
         if ( $use_ext_lut ) {
             $filename =~ m{\.($extension_re)\z};
-            next unless $1;
+
+            if( !$1 ) {
+                $filename =~ m{\.([^.]+)\z};
+                croak "There are no loaders available for .${1} files";
+            }
+
             @try_plugins = @{ $extension_lut{ $1 } };
         }
 

Modified: branches/Config-Any/unsupported_error/t/10-branches.t
===================================================================
--- branches/Config-Any/unsupported_error/t/10-branches.t	2008-09-04 08:16:16 UTC (rev 8353)
+++ branches/Config-Any/unsupported_error/t/10-branches.t	2008-09-04 13:52:33 UTC (rev 8354)
@@ -38,7 +38,8 @@
     );
 }
 
-my @files = glob( "t/conf/conf.*" );
+# grep out files we don't understand for these tests
+my @files = grep { !m{\.(foo|unsupported)$} } glob( "t/conf/conf.*" );
 my $filter = sub { return };
 ok( Config::Any->load_files( { files => \@files, use_ext => 0 } ),
     "use_ext 0 works" );

Added: branches/Config-Any/unsupported_error/t/64-extfail.t
===================================================================
--- branches/Config-Any/unsupported_error/t/64-extfail.t	                        (rev 0)
+++ branches/Config-Any/unsupported_error/t/64-extfail.t	2008-09-04 13:52:33 UTC (rev 8354)
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+use Test::More tests => 3;
+
+use Config::Any;
+
+{
+    my $result = eval {
+        Config::Any->load_files(
+            { files => [ 't/conf/conf.unsupported' ], use_ext => 1 } );
+    };
+
+    ok( !defined $result, 'empty result' );
+    ok( $@,               'error thrown' );
+    like(
+        $@,
+        qr/There are no loaders available for \.unsupported files/,
+        'error message'
+    );
+}




More information about the Catalyst-commits mailing list