[Catalyst-commits] r7097 - in trunk/Config-Any: . lib/Config t
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Thu Nov 8 14:21:58 GMT 2007
Author: bricas
Date: 2007-11-08 14:21:58 +0000 (Thu, 08 Nov 2007)
New Revision: 7097
Modified:
trunk/Config-Any/Changes
trunk/Config-Any/lib/Config/Any.pm
trunk/Config-Any/t/10-branches.t
Log:
some code and pod cleanups.
Modified: trunk/Config-Any/Changes
===================================================================
--- trunk/Config-Any/Changes 2007-11-08 13:54:07 UTC (rev 7096)
+++ trunk/Config-Any/Changes 2007-11-08 14:21:58 UTC (rev 7097)
@@ -1,5 +1,8 @@
Revision history for Config-Any
+0.09 Thu Nov 08 2007
+ code and pod cleanups
+
0.08 Thu Aug 23 2007
pass config options to each parser
fix for loading the same perl config twice (RT #28812)
Modified: trunk/Config-Any/lib/Config/Any.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any.pm 2007-11-08 13:54:07 UTC (rev 7096)
+++ trunk/Config-Any/lib/Config/Any.pm 2007-11-08 14:21:58 UTC (rev 7097)
@@ -7,7 +7,7 @@
use Module::Pluggable::Object ();
use English qw(-no_match_vars);
-our $VERSION = '0.08';
+our $VERSION = '0.09';
=head1 NAME
@@ -51,9 +51,9 @@
=head2 load_files( )
- Config::Any->load_files({files => \@files});
- Config::Any->load_files({files => \@files, filter => \&filter});
- Config::Any->load_files({files => \@files, use_ext => 1});
+ Config::Any->load_files( { files => \@files } );
+ Config::Any->load_files( { files => \@files, filter => \&filter } );
+ Config::Any->load_files( { files => \@files, use_ext => 1 } );
C<load_files()> attempts to load configuration from the list of files passed in
the C<files> parameter, if the file exists.
@@ -86,17 +86,13 @@
sub load_files {
my ( $class, $args ) = @_;
- return unless defined $args;
- unless ( exists $args->{ files } ) {
- warn "no files specified";
+
+ unless ( $args && exists $args->{ files } ) {
+ warn "No files specified!";
return;
}
- my %load_args
- = map { $_ => defined $args->{ $_ } ? $args->{ $_ } : undef }
- qw(filter use_ext force_plugins driver_args);
- $load_args{ files } = [ grep { -f $_ } @{ $args->{ files } } ];
- return $class->_load( \%load_args );
+ return $class->_load( $args );
}
=head2 load_stems( )
@@ -126,8 +122,7 @@
= map { $_ => defined $args->{ $_ } ? $args->{ $_ } : undef }
qw(filter use_ext force_plugins driver_args);
- my $filenames = $class->_stems_to_files( $args->{ stems } );
- $load_args{ files } = [ grep { -f $_ } @{ $filenames } ];
+ $load_args{ files } = $class->_stems_to_files( $args->{ stems } );
return $class->_load( \%load_args );
}
@@ -136,22 +131,17 @@
return unless defined $stems;
my @files;
-STEM:
for my $s ( @$stems ) {
- EXT:
for my $ext ( $class->extensions ) {
- my $file = "$s.$ext";
- next EXT unless -f $file;
- push @files, $file;
- last EXT;
+ push @files, "$s.$ext";
}
}
- \@files;
+ return \@files;
}
-sub _maphash (@) {
+sub _maphash { # syntactic sugar
map { $_ => 1 } @_;
-} # sugar
+}
# this is where we do the real work
# it's a private class-method because users should use the interface described
@@ -180,6 +170,7 @@
FILE:
for my $filename ( keys %files ) {
+ next unless -f $filename;
# use file extension to decide whether this loader should try this file
# use_ext => 1 hits this block
@@ -252,7 +243,7 @@
sub extensions {
my $class = shift;
my @ext = map { $_->extensions } $class->plugins;
- return wantarray ? @ext : [ @ext ];
+ return wantarray ? @ext : \@ext;
}
=head1 DIAGNOSTICS
Modified: trunk/Config-Any/t/10-branches.t
===================================================================
--- trunk/Config-Any/t/10-branches.t 2007-11-08 13:54:07 UTC (rev 7096)
+++ trunk/Config-Any/t/10-branches.t 2007-11-08 14:21:58 UTC (rev 7097)
@@ -1,18 +1,26 @@
use Test::More tests => 9;
use Config::Any;
-ok( !Config::Any->load_files(), "load_files expects args" );
ok( !Config::Any->load_stems(), "load_stems expects args" );
{
my @warnings;
local $SIG{ __WARN__ } = sub { push @warnings, @_ };
+
+ Config::Any->load_files( );
+ like(
+ shift @warnings,
+ qr/^No files specified!/,
+ "load_files expects args"
+ );
+
Config::Any->load_files( {} );
like(
shift @warnings,
- qr/^no files specified/,
+ qr/^No files specified!/,
"load_files expects files"
);
+
Config::Any->load_stems( {} );
like(
shift @warnings,
More information about the Catalyst-commits
mailing list