[Catalyst-commits] r6707 - in trunk/Config-Any: . lib/Config
lib/Config/Any t t/conf
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Wed Aug 22 04:21:48 GMT 2007
Author: bricas
Date: 2007-08-22 04:21:48 +0100 (Wed, 22 Aug 2007)
New Revision: 6707
Added:
trunk/Config-Any/MANIFEST.SKIP
trunk/Config-Any/Makefile.PL
Removed:
trunk/Config-Any/Build.PL
trunk/Config-Any/MANIFEST
Modified:
trunk/Config-Any/Changes
trunk/Config-Any/README
trunk/Config-Any/lib/Config/Any.pm
trunk/Config-Any/lib/Config/Any/General.pm
trunk/Config-Any/lib/Config/Any/INI.pm
trunk/Config-Any/lib/Config/Any/JSON.pm
trunk/Config-Any/lib/Config/Any/Perl.pm
trunk/Config-Any/lib/Config/Any/XML.pm
trunk/Config-Any/lib/Config/Any/YAML.pm
trunk/Config-Any/t/01-use.t
trunk/Config-Any/t/10-branches.t
trunk/Config-Any/t/20-parse.t
trunk/Config-Any/t/50-general.t
trunk/Config-Any/t/52-json.t
trunk/Config-Any/t/53-perl.t
trunk/Config-Any/t/54-xml.t
trunk/Config-Any/t/55-yaml.t
trunk/Config-Any/t/61-features.t
trunk/Config-Any/t/conf/conf.pl
trunk/Config-Any/t/conf/conf.xml
trunk/Config-Any/t/conf/conf.yml
Log:
distro work
Deleted: trunk/Config-Any/Build.PL
===================================================================
--- trunk/Config-Any/Build.PL 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/Build.PL 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,19 +0,0 @@
-use strict;
-use warnings;
-use Module::Build;
-
-my $builder = Module::Build->new(
- module_name => 'Config::Any',
- license => 'perl',
- dist_author => 'Joel Bernstein <rataxis at cpan.org>',
- dist_version_from => 'lib/Config/Any.pm',
- requires => {
- 'Test::More' => 0,
- 'version' => 0,
- 'Module::Pluggable' => '3.01'
- },
- add_to_cleanup => [ 'Config-Any-*' ],
- create_makefile_pl => 'traditional',
-);
-
-$builder->create_build_script();
Modified: trunk/Config-Any/Changes
===================================================================
--- trunk/Config-Any/Changes 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/Changes 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,10 +1,16 @@
Revision history for Config-Any
-0.01 - 0.03 dev releases
+0.07 Mon Feb 26 2007
+ promote 0.06_01 to non-dev.
-0.04 Mon Aug 7 15:15:15 2006
- Initial CPAN-worthy release with proper test suite
+0.06_01 Sun Feb 25 19:23:00 2007
+ fixed bug [rt.cpan.org #25143] make tests fails
+ - t/61_features.t had 1 more test added than was set to skip if the INI parser
+ was not installed. Fixed by s/9/10/ on the skip() line.
+0.06 Thu Feb 22 21:05:00 2007
+ removed reference to Test::Exception, bumped version number
+
0.05 Wed Feb 21 22:00:00 2007
added support for:
'force_plugins => [ qw(Config::Any::Foo Config::Any::Blah) ]' parameter
@@ -14,11 +20,8 @@
to nested hashrefs
both as requested by Evan Kaufman
-0.06 Thu Feb 22 21:05:00 2007
- removed reference to Test::Exception, bumped version number
+0.04 Mon Aug 7 15:15:15 2006
+ Initial CPAN-worthy release with proper test suite
-0.06_01 Sun Feb 25 19:23:00 2007
- fixed bug [rt.cpan.org #25143] make tests fails
- - t/61_features.t had 1 more test added than was set to skip if the INI parser
- was not installed. Fixed by s/9/10/ on the skip() line.
+0.01 - 0.03 dev releases
Deleted: trunk/Config-Any/MANIFEST
===================================================================
--- trunk/Config-Any/MANIFEST 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/MANIFEST 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,33 +0,0 @@
-Build.PL
-Changes
-lib/Config/Any.pm
-lib/Config/Any/General.pm
-lib/Config/Any/INI.pm
-lib/Config/Any/JSON.pm
-lib/Config/Any/Perl.pm
-lib/Config/Any/XML.pm
-lib/Config/Any/YAML.pm
-Makefile.PL
-MANIFEST This list of files
-README
-t/01-use.t
-t/10-branches.t
-t/20-parse.t
-t/50-general.t
-t/51-ini.t
-t/52-json.t
-t/53-perl.t
-t/54-xml.t
-t/55-yaml.t
-t/61-features.t
-t/conf/conf.conf
-t/conf/conf.foo
-t/conf/conf.ini
-t/conf/conf.json
-t/conf/conf.pl
-t/conf/conf.xml
-t/conf/conf.yml
-t/conf/conf2.ini
-t/pod-coverage.t
-t/pod.t
-META.yml
Added: trunk/Config-Any/MANIFEST.SKIP
===================================================================
--- trunk/Config-Any/MANIFEST.SKIP (rev 0)
+++ trunk/Config-Any/MANIFEST.SKIP 2007-08-22 03:21:48 UTC (rev 6707)
@@ -0,0 +1,29 @@
+# Avoid version control files.
+\bRCS\b
+\bCVS\b
+,v$
+\B\.svn\b
+
+# Avoid Makemaker generated and utility files.
+\bMakefile$
+\bblib
+\bMakeMaker-\d
+\bpm_to_blib$
+\bblibdirs$
+^MANIFEST\.SKIP$
+
+# Avoid Module::Build generated and utility files.
+\bBuild$
+\b_build
+
+# Avoid temp and backup files.
+~$
+\.tmp$
+\.old$
+\.bak$
+\#$
+\b\.#
+\.DS_Store$
+
+# No tarballs!
+\.gz$
Added: trunk/Config-Any/Makefile.PL
===================================================================
--- trunk/Config-Any/Makefile.PL (rev 0)
+++ trunk/Config-Any/Makefile.PL 2007-08-22 03:21:48 UTC (rev 6707)
@@ -0,0 +1,12 @@
+use inc::Module::Install 0.65;
+
+name 'Config-Any';
+all_from 'lib/Config/Any.pm';
+
+requires 'Module::Pluggable' => '3.01';
+requires 'version';
+
+requires 'Test::More';
+
+auto_install;
+WriteAll;
Modified: trunk/Config-Any/README
===================================================================
--- trunk/Config-Any/README 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/README 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,26 +1,163 @@
-Config-Any version 0.0.4
+NAME
+ Config::Any - Load configuration from different file formats,
+ transparently
-This module generalises loading class configuration data from a number of different
-file formats.
+VERSION
+ This document describes Config::Any version 0.0.7
-INSTALLATION
+SYNOPSIS
+ use Config::Any;
-To install this module, run the following commands:
- perl Build.PL
- ./Build
- ./Build test
- ./Build install
+ my $cfg = Config::Any->load_stems({stems => \@filepath_stems, ... });
+ # or
+ my $cfg = Config::Any->load_files({files => \@filepaths, ... });
+ for (@$cfg) {
+ my ($filename, $config) = each %$_;
+ $class->config($config);
+ warn "loaded config from file: $filename";
+ }
+DESCRIPTION
+ Config::Any provides a facility for Perl applications and libraries to
+ load configuration data from multiple different file formats. It
+ supports XML, YAML, JSON, Apache-style configuration, Windows INI files,
+ and even Perl code.
+
+ The rationale for this module is as follows: Perl programs are deployed
+ on many different platforms and integrated with many different systems.
+ Systems administrators and end users may prefer different configuration
+ formats than the developers. The flexibility inherent in a multiple
+ format configuration loader allows different users to make different
+ choices, without generating extra work for the developers. As a
+ developer you only need to learn a single interface to be able to use
+ the power of different configuration formats.
+
+INTERFACE
+ 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});
+
+ "load_files()" attempts to load configuration from the list of files
+ passed in the "files" parameter, if the file exists.
+
+ If the "filter" parameter is set, it is used as a callback to modify the
+ configuration data before it is returned. It will be passed a single
+ hash-reference parameter which it should modify in-place.
+
+ If the "use_ext" parameter is defined, the loader will attempt to parse
+ the file extension from each filename and will skip the file unless it
+ matches a standard extension for the loading plugins. Only plugins whose
+ standard extensions match the file extension will be used. For
+ efficiency reasons, its use is encouraged, but be aware that you will
+ lose flexibility -- for example, a file called "myapp.cfg" containing
+ YAML data will not be offered to the YAML plugin, whereas "myapp.yml" or
+ "myapp.yaml" would be.
+
+ "load_files()" also supports a 'force_plugins' parameter, whose value
+ should be an arrayref of plugin names like "Config::Any::INI". Its
+ intended use is to allow the use of a non-standard file extension while
+ forcing it to be offered to a particular parser. It is not compatible
+ with 'use_ext'.
+
+ load_stems( )
+ Config::Any->load_stems({stems => \@stems]});
+ Config::Any->load_stems({stems => \@stems, filter => \&filter});
+ Config::Any->load_stems({stems => \@stems, use_ext => 1});
+
+ "load_stems()" attempts to load configuration from a list of files which
+ it generates by combining the filename stems list passed in the "stems"
+ parameter with the potential filename extensions from each loader, which
+ you can check with the "extensions()" classmethod described below. Once
+ this list of possible filenames is built it is treated exactly as in
+ "load_files()" above, as which it takes the same parameters. Please read
+ the "load_files()" documentation before using this method.
+
+ finder( )
+ The "finder()" classmethod returns the Module::Pluggable::Object object
+ which is used to load the plugins. See the documentation for that module
+ for more information.
+
+ plugins( )
+ The "plugins()" classmethod returns the names of configuration loading
+ plugins as found by Module::Pluggable::Object.
+
+ extensions( )
+ The "extensions()" classmethod returns the possible file extensions
+ which can be loaded by "load_stems()" and "load_files()". This may be
+ useful if you set the "use_ext" parameter to those methods.
+
+DIAGNOSTICS
+ "no files specified" or "no stems specified"
+ The "load_files()" and "load_stems()" methods will issue this
+ warning if called with an empty list of files/stems to load.
+
+ "_load requires a arrayref of file paths"
+ This fatal error will be thrown by the internal "_load" method. It
+ should not occur but is specified here for completeness. If your
+ code dies with this error, please email a failing test case to the
+ authors below.
+
+CONFIGURATION AND ENVIRONMENT
+ Config::Any requires no configuration files or environment variables.
+
DEPENDENCIES
+ Module::Pluggable
-Module::Pluggable >= 3.01
+ And at least one of the following: Config::General Config::Tiny JSON
+ YAML JSON::Syck YAML::Syck XML::Simple
-COPYRIGHT AND LICENCE
+INCOMPATIBILITIES
+ None reported.
-The development of this module was sponsored by SAPO, a division of Portugal Telecom.
+BUGS AND LIMITATIONS
+ No bugs have been reported.
-Copyright (C) 2006, Portugal Telecom
+ Please report any bugs or feature requests to
+ "bug-config-any at rt.cpan.org", or through the web interface at
+ <http://rt.cpan.org>.
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
+AUTHOR
+ Joel Bernstein <rataxis at cpan.org>
+
+CONTRIBUTORS
+ This module was based on the original Catalyst::Plugin::ConfigLoader
+ module by Brian Cassidy "<bricas at cpan.org>".
+
+ With ideas and support from Matt S Trout "<mst at shadowcatsystems.co.uk>".
+
+ Further enhancements suggested by Evan Kaufman "<evank at cpan.org>".
+
+LICENCE AND COPYRIGHT
+ Copyright (c) 2006, Portugal Telecom "http://www.sapo.pt/". All rights
+ reserved. Portions copyright 2007, Joel Bernstein "<rataxis at cpan.org>".
+
+ This module is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself. See perlartistic.
+
+DISCLAIMER OF WARRANTY
+ BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+ FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+ PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+ EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
+ ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
+ YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+ NECESSARY SERVICING, REPAIR, OR CORRECTION.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+ REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE
+ TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR
+ CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+ SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+ RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+ FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+ SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ DAMAGES.
+
+SEE ALSO
+ Catalyst::Plugin::ConfigLoader -- now a wrapper around this module.
+
Modified: trunk/Config-Any/lib/Config/Any/General.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/General.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any/General.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,108 +1,108 @@
-package Config::Any::General;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-Config::Any::General - Load Config::General files
-
-=head1 DESCRIPTION
-
-Loads Config::General files. Example:
-
- name = TestApp
- <Component Controller::Foo>
- foo bar
- </Component>
- <Model Baz>
- qux xyzzy
- </Model>
-
-=head1 METHODS
-
-=head2 extensions( )
-
-return an array of valid extensions (C<cnf>, C<conf>).
-
-=cut
-
-sub extensions {
- return qw( cnf conf );
-}
-
-=head2 load( $file )
-
-Attempts to load C<$file> via Config::General.
-
-=cut
-
-sub load {
- my $class = shift;
- my $file = shift;
-
- # work around bug (?) in Config::General
-# return if $class->_test_perl($file);
-
- require Config::General;
- my $configfile = Config::General->new( $file );
- my $config = { $configfile->getall };
-
- return $config;
-}
-
-# this is a bit of a hack but necessary, because Config::General is *far* too lax
-# about what it will load -- specifically, it seems to be quite happy to load a Perl
-# config file (ie, a file which is valid Perl and creates a hashref) as if it were
-# an Apache-style configuration file, presumably due to laziness on the part of the
-# developer.
-
-sub _test_perl {
- my ($class, $file) = @_;
- my $is_perl_src;
- eval { $is_perl_src = do "$file"; };
- delete $INC{$file}; # so we don't screw stuff later on
- return defined $is_perl_src;
-}
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=back
-
-=head1 CONTRIBUTORS
-
-=over 4
-
-=item * Joel Bernstein C<< <rataxis at cpan.org> >>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy
-
-Portions Copyright 2006 Portugal Telecom
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Catalyst>
-
-=item * L<Config::Any>
-
-=item * L<Config::General>
-
-=back
-
-=cut
-
-1;
-
+package Config::Any::General;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Config::Any::General - Load Config::General files
+
+=head1 DESCRIPTION
+
+Loads Config::General files. Example:
+
+ name = TestApp
+ <Component Controller::Foo>
+ foo bar
+ </Component>
+ <Model Baz>
+ qux xyzzy
+ </Model>
+
+=head1 METHODS
+
+=head2 extensions( )
+
+return an array of valid extensions (C<cnf>, C<conf>).
+
+=cut
+
+sub extensions {
+ return qw( cnf conf );
+}
+
+=head2 load( $file )
+
+Attempts to load C<$file> via Config::General.
+
+=cut
+
+sub load {
+ my $class = shift;
+ my $file = shift;
+
+ # work around bug (?) in Config::General
+# return if $class->_test_perl($file);
+
+ require Config::General;
+ my $configfile = Config::General->new( $file );
+ my $config = { $configfile->getall };
+
+ return $config;
+}
+
+# this is a bit of a hack but necessary, because Config::General is *far* too lax
+# about what it will load -- specifically, it seems to be quite happy to load a Perl
+# config file (ie, a file which is valid Perl and creates a hashref) as if it were
+# an Apache-style configuration file, presumably due to laziness on the part of the
+# developer.
+
+sub _test_perl {
+ my ($class, $file) = @_;
+ my $is_perl_src;
+ eval { $is_perl_src = do "$file"; };
+ delete $INC{$file}; # so we don't screw stuff later on
+ return defined $is_perl_src;
+}
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=back
+
+=head1 CONTRIBUTORS
+
+=over 4
+
+=item * Joel Bernstein C<< <rataxis at cpan.org> >>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Brian Cassidy
+
+Portions Copyright 2006 Portugal Telecom
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * L<Catalyst>
+
+=item * L<Config::Any>
+
+=item * L<Config::General>
+
+=back
+
+=cut
+
+1;
+
Modified: trunk/Config-Any/lib/Config/Any/INI.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/INI.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any/INI.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,117 +1,117 @@
-package Config::Any::INI;
-
-use strict;
-use warnings;
-
-our $MAP_SECTION_SPACE_TO_NESTED_KEY = 1;
-
-=head1 NAME
-
-Config::Any::INI - Load INI config files
-
-=head1 DESCRIPTION
-
-Loads INI files. Example:
-
- name=TestApp
-
- [Controller::Foo]
- foo=bar
-
- [Model::Baz]
- qux=xyzzy
-
-=head1 METHODS
-
-=head2 extensions( )
-
-return an array of valid extensions (C<ini>).
-
-=cut
-
-sub extensions {
- return qw( ini );
-}
-
-=head2 load( $file )
-
-Attempts to load C<$file> as an INI file.
-
-=cut
-
-sub load {
- my $class = shift;
- my $file = shift;
-
- require Config::Tiny;
- my $config = Config::Tiny->read( $file );
-
- my $main = delete $config->{ _ };
- my $out;
- $out->{$_} = $main->{$_} for keys %$main;
-
- for my $k (keys %$config) {
- my @keys = split /\s+/, $k if $MAP_SECTION_SPACE_TO_NESTED_KEY;
- my $ref = $config->{$k};
-
- if (@keys > 1) {
- my ($a, $b) = @keys[0,1];
- $out->{$a}->{$b} = $ref;
- } else {
- $out->{$k} = $ref;
- }
- }
- return $out;
-}
-
-=head1 PACKAGE VARIABLES
-
-=over 4
-
-=item $MAP_SECTION_SPACE_TO_NESTED_KEY (boolean)
-
-This variable controls whether spaces in INI section headings will be expanded into nested hash keys.
-e.g. it controls whether [Full Power] maps to $config->{'Full Power'} or $config->{'Full'}->{'Power'}
-
-By default it is set to 1 (i.e. true).
-
-Set it to 0 to preserve literal spaces in section headings:
-
- use Config::Any;
- use Config::Any::INI;
- $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;
-
-=back
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=item * Joel Bernstein E<lt>rataxis at cpan.orgE<gt>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy, portions copyright 2006, 2007 by Joel Bernstein
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Catalyst>
-
-=item * L<Config::Any>
-
-=item * L<Config::Tiny>
-
-=back
-
-=cut
-
-1;
+package Config::Any::INI;
+
+use strict;
+use warnings;
+
+our $MAP_SECTION_SPACE_TO_NESTED_KEY = 1;
+
+=head1 NAME
+
+Config::Any::INI - Load INI config files
+
+=head1 DESCRIPTION
+
+Loads INI files. Example:
+
+ name=TestApp
+
+ [Controller::Foo]
+ foo=bar
+
+ [Model::Baz]
+ qux=xyzzy
+
+=head1 METHODS
+
+=head2 extensions( )
+
+return an array of valid extensions (C<ini>).
+
+=cut
+
+sub extensions {
+ return qw( ini );
+}
+
+=head2 load( $file )
+
+Attempts to load C<$file> as an INI file.
+
+=cut
+
+sub load {
+ my $class = shift;
+ my $file = shift;
+
+ require Config::Tiny;
+ my $config = Config::Tiny->read( $file );
+
+ my $main = delete $config->{ _ };
+ my $out;
+ $out->{$_} = $main->{$_} for keys %$main;
+
+ for my $k (keys %$config) {
+ my @keys = split /\s+/, $k if $MAP_SECTION_SPACE_TO_NESTED_KEY;
+ my $ref = $config->{$k};
+
+ if (@keys > 1) {
+ my ($a, $b) = @keys[0,1];
+ $out->{$a}->{$b} = $ref;
+ } else {
+ $out->{$k} = $ref;
+ }
+ }
+ return $out;
+}
+
+=head1 PACKAGE VARIABLES
+
+=over 4
+
+=item $MAP_SECTION_SPACE_TO_NESTED_KEY (boolean)
+
+This variable controls whether spaces in INI section headings will be expanded into nested hash keys.
+e.g. it controls whether [Full Power] maps to $config->{'Full Power'} or $config->{'Full'}->{'Power'}
+
+By default it is set to 1 (i.e. true).
+
+Set it to 0 to preserve literal spaces in section headings:
+
+ use Config::Any;
+ use Config::Any::INI;
+ $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;
+
+=back
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=item * Joel Bernstein E<lt>rataxis at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Brian Cassidy, portions copyright 2006, 2007 by Joel Bernstein
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * L<Catalyst>
+
+=item * L<Config::Any>
+
+=item * L<Config::Tiny>
+
+=back
+
+=cut
+
+1;
Modified: trunk/Config-Any/lib/Config/Any/JSON.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/JSON.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any/JSON.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,92 +1,92 @@
-package Config::Any::JSON;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-Config::Any::JSON - Load JSON config files
-
-=head1 DESCRIPTION
-
-Loads JSON files. Example:
-
- {
- "name": "TestApp",
- "Controller::Foo": {
- "foo": "bar"
- },
- "Model::Baz": {
- "qux": "xyzzy"
- }
- }
-
-=head1 METHODS
-
-=head2 extensions( )
-
-return an array of valid extensions (C<json>, C<jsn>).
-
-=cut
-
-sub extensions {
- return qw( json jsn );
-}
-
-=head2 load( $file )
-
-Attempts to load C<$file> as a JSON file.
-
-=cut
-
-sub load {
- my $class = shift;
- my $file = shift;
-
- open( my $fh, $file ) or die $!;
- my $content = do { local $/; <$fh> };
- close $fh;
-
- eval { require JSON::Syck; };
- if( $@ ) {
- require JSON;
- JSON->import;
- return jsonToObj( $content );
- }
- else {
- return JSON::Syck::Load( $content );
- }
-}
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Catalyst>
-
-=item * L<Config::Any>
-
-=item * L<JSON>
-
-=item * L<JSON::Syck>
-
-=back
-
-=cut
-
-1;
\ No newline at end of file
+package Config::Any::JSON;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Config::Any::JSON - Load JSON config files
+
+=head1 DESCRIPTION
+
+Loads JSON files. Example:
+
+ {
+ "name": "TestApp",
+ "Controller::Foo": {
+ "foo": "bar"
+ },
+ "Model::Baz": {
+ "qux": "xyzzy"
+ }
+ }
+
+=head1 METHODS
+
+=head2 extensions( )
+
+return an array of valid extensions (C<json>, C<jsn>).
+
+=cut
+
+sub extensions {
+ return qw( json jsn );
+}
+
+=head2 load( $file )
+
+Attempts to load C<$file> as a JSON file.
+
+=cut
+
+sub load {
+ my $class = shift;
+ my $file = shift;
+
+ open( my $fh, $file ) or die $!;
+ my $content = do { local $/; <$fh> };
+ close $fh;
+
+ eval { require JSON::Syck; };
+ if( $@ ) {
+ require JSON;
+ JSON->import;
+ return jsonToObj( $content );
+ }
+ else {
+ return JSON::Syck::Load( $content );
+ }
+}
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * L<Catalyst>
+
+=item * L<Config::Any>
+
+=item * L<JSON>
+
+=item * L<JSON::Syck>
+
+=back
+
+=cut
+
+1;
Modified: trunk/Config-Any/lib/Config/Any/Perl.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/Perl.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any/Perl.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,75 +1,75 @@
-package Config::Any::Perl;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-Config::Any::Perl - Load Perl config files
-
-=head1 DESCRIPTION
-
-Loads Perl files. Example:
-
- {
- name => 'TestApp',
- 'Controller::Foo' => {
- foo => 'bar'
- },
- 'Model::Baz' => {
- qux => 'xyzzy'
- }
- }
-
-=head1 METHODS
-
-=head2 extensions( )
-
-return an array of valid extensions (C<pl>, C<perl>).
-
-=cut
-
-sub extensions {
- return qw( pl perl );
-}
-
-=head2 load( $file )
-
-Attempts to load C<$file> as a Perl file.
-
-=cut
-
-sub load {
- my $class = shift;
- my $file = shift;
- return eval { require $file };
-}
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Catalyst>
-
-=item * L<Config::Any>
-
-=back
-
-=cut
-
-1;
+package Config::Any::Perl;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Config::Any::Perl - Load Perl config files
+
+=head1 DESCRIPTION
+
+Loads Perl files. Example:
+
+ {
+ name => 'TestApp',
+ 'Controller::Foo' => {
+ foo => 'bar'
+ },
+ 'Model::Baz' => {
+ qux => 'xyzzy'
+ }
+ }
+
+=head1 METHODS
+
+=head2 extensions( )
+
+return an array of valid extensions (C<pl>, C<perl>).
+
+=cut
+
+sub extensions {
+ return qw( pl perl );
+}
+
+=head2 load( $file )
+
+Attempts to load C<$file> as a Perl file.
+
+=cut
+
+sub load {
+ my $class = shift;
+ my $file = shift;
+ return eval { require $file };
+}
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * L<Catalyst>
+
+=item * L<Config::Any>
+
+=back
+
+=cut
+
+1;
Modified: trunk/Config-Any/lib/Config/Any/XML.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/XML.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any/XML.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,104 +1,104 @@
-package Config::Any::XML;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-Config::Any::XML - Load XML config files
-
-=head1 DESCRIPTION
-
-Loads XML files. Example:
-
- <config>
- <name>TestApp</name>
- <component name="Controller::Foo">
- <foo>bar</foo>
- </component>
- <model name="Baz">
- <qux>xyzzy</qux>
- </model>
- </config>
-
-=head1 METHODS
-
-=head2 extensions( )
-
-return an array of valid extensions (C<xml>).
-
-=cut
-
-sub extensions {
- return qw( xml );
-}
-
-=head2 load( $file )
-
-Attempts to load C<$file> as an XML file.
-
-=cut
-
-sub load {
- my $class = shift;
- my $file = shift;
-
- require XML::Simple;
- XML::Simple->import;
- my $config = XMLin(
- $file,
- ForceArray => [ qw( component model view controller ) ],
- );
-
- return $class->_coerce($config);
-}
-
-sub _coerce {
- # coerce the XML-parsed config into the correct format
- my $class = shift;
- my $config = shift;
- my $out;
- for my $k (keys %$config) {
- my $ref = $config->{$k};
- my $name = ref $ref ? delete $ref->{name} : undef;
- if (defined $name) {
- $out->{$k}->{$name} = $ref;
- } else {
- $out->{$k} = $ref;
- }
- }
- $out;
-}
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=item * Joel Bernstein E<lt>rataxis at cpan.orgE<gt>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Catalyst>
-
-=item * L<Config::Any>
-
-=item * L<XML::Simple>
-
-=back
-
-=cut
-
-1;
+package Config::Any::XML;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Config::Any::XML - Load XML config files
+
+=head1 DESCRIPTION
+
+Loads XML files. Example:
+
+ <config>
+ <name>TestApp</name>
+ <component name="Controller::Foo">
+ <foo>bar</foo>
+ </component>
+ <model name="Baz">
+ <qux>xyzzy</qux>
+ </model>
+ </config>
+
+=head1 METHODS
+
+=head2 extensions( )
+
+return an array of valid extensions (C<xml>).
+
+=cut
+
+sub extensions {
+ return qw( xml );
+}
+
+=head2 load( $file )
+
+Attempts to load C<$file> as an XML file.
+
+=cut
+
+sub load {
+ my $class = shift;
+ my $file = shift;
+
+ require XML::Simple;
+ XML::Simple->import;
+ my $config = XMLin(
+ $file,
+ ForceArray => [ qw( component model view controller ) ],
+ );
+
+ return $class->_coerce($config);
+}
+
+sub _coerce {
+ # coerce the XML-parsed config into the correct format
+ my $class = shift;
+ my $config = shift;
+ my $out;
+ for my $k (keys %$config) {
+ my $ref = $config->{$k};
+ my $name = ref $ref ? delete $ref->{name} : undef;
+ if (defined $name) {
+ $out->{$k}->{$name} = $ref;
+ } else {
+ $out->{$k} = $ref;
+ }
+ }
+ $out;
+}
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=item * Joel Bernstein E<lt>rataxis at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * L<Catalyst>
+
+=item * L<Config::Any>
+
+=item * L<XML::Simple>
+
+=back
+
+=cut
+
+1;
Modified: trunk/Config-Any/lib/Config/Any/YAML.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/YAML.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any/YAML.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,88 +1,88 @@
-package Config::Any::YAML;
-
-use strict;
-use warnings;
-
-=head1 NAME
-
-Config::Any::YAML - Load YAML config files
-
-=head1 DESCRIPTION
-
-Loads YAML files. Example:
-
- ---
- name: TestApp
- Controller::Foo:
- foo: bar
- Model::Baz:
- qux: xyzzy
-
-
-=head1 METHODS
-
-=head2 extensions( )
-
-return an array of valid extensions (C<yml>, C<yaml>).
-
-=cut
-
-sub extensions {
- return qw( yml yaml );
-}
-
-=head2 load( $file )
-
-Attempts to load C<$file> as a YAML file.
-
-=cut
-
-sub load {
- my $class = shift;
- my $file = shift;
-
- eval { require YAML::Syck; };
- if( $@ ) {
- require YAML;
- return YAML::LoadFile( $file );
- }
- else {
- open( my $fh, $file ) or die $!;
- my $content = do { local $/; <$fh> };
- close $fh;
- return YAML::Syck::Load( $content );
- }
-}
-
-=head1 AUTHOR
-
-=over 4
-
-=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
-
-=back
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright 2006 by Brian Cassidy
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
-
-=head1 SEE ALSO
-
-=over 4
-
-=item * L<Catalyst>
-
-=item * L<Config::Any>
-
-=item * L<YAML>
-
-=item * L<YAML::Syck>
-
-=back
-
-=cut
-
-1;
\ No newline at end of file
+package Config::Any::YAML;
+
+use strict;
+use warnings;
+
+=head1 NAME
+
+Config::Any::YAML - Load YAML config files
+
+=head1 DESCRIPTION
+
+Loads YAML files. Example:
+
+ ---
+ name: TestApp
+ Controller::Foo:
+ foo: bar
+ Model::Baz:
+ qux: xyzzy
+
+
+=head1 METHODS
+
+=head2 extensions( )
+
+return an array of valid extensions (C<yml>, C<yaml>).
+
+=cut
+
+sub extensions {
+ return qw( yml yaml );
+}
+
+=head2 load( $file )
+
+Attempts to load C<$file> as a YAML file.
+
+=cut
+
+sub load {
+ my $class = shift;
+ my $file = shift;
+
+ eval { require YAML::Syck; };
+ if( $@ ) {
+ require YAML;
+ return YAML::LoadFile( $file );
+ }
+ else {
+ open( my $fh, $file ) or die $!;
+ my $content = do { local $/; <$fh> };
+ close $fh;
+ return YAML::Syck::Load( $content );
+ }
+}
+
+=head1 AUTHOR
+
+=over 4
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2006 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * L<Catalyst>
+
+=item * L<Config::Any>
+
+=item * L<YAML>
+
+=item * L<YAML::Syck>
+
+=back
+
+=cut
+
+1;
Modified: trunk/Config-Any/lib/Config/Any.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any.pm 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/lib/Config/Any.pm 2007-08-22 03:21:48 UTC (rev 6707)
@@ -6,7 +6,7 @@
use Module::Pluggable::Object ();
use English qw(-no_match_vars);
-our $VERSION = '0.06_01';
+our $VERSION = '0.07';
=head1 NAME
@@ -14,21 +14,21 @@
=head1 VERSION
-This document describes Config::Any version 0.0.5
+This document describes Config::Any version 0.0.7
=head1 SYNOPSIS
use Config::Any;
- my $cfg = Config::Any->load_stems({stems => \@filepath_stems, ... });
- # or
- my $cfg = Config::Any->load_files({files => \@filepaths, ... });
+ my $cfg = Config::Any->load_stems({stems => \@filepath_stems, ... });
+ # or
+ my $cfg = Config::Any->load_files({files => \@filepaths, ... });
- for (@$cfg) {
- my ($filename, $config) = each %$_;
- $class->config($config);
- warn "loaded config from file: $filename";
- }
+ for (@$cfg) {
+ my ($filename, $config) = each %$_;
+ $class->config($config);
+ warn "loaded config from file: $filename";
+ }
=head1 DESCRIPTION
@@ -150,7 +150,7 @@
@{$args}{qw(files filter use_ext force_plugins)};
croak "_load requires a arrayref of file paths" unless defined $files_ref;
- my %files = _maphash @$files_ref;
+ my %files = _maphash @$files_ref;
my %force_plugins = _maphash @$force_plugins_ref;
my $enforcing = keys %force_plugins ? 1 : 0;
@@ -160,7 +160,7 @@
# perform a separate file loop for each loader
for my $loader ( $class->plugins ) {
next if $enforcing && not defined $force_plugins{$loader};
- last unless keys %files;
+ last unless keys %files;
my %ext = _maphash $loader->extensions;
FILE:
@@ -168,25 +168,25 @@
# use file extension to decide whether this loader should try this file
# use_ext => 1 hits this block
if (defined $use_ext && !$enforcing) {
- my $matched_ext = 0;
+ my $matched_ext = 0;
EXT:
for my $e (keys %ext) {
next EXT unless $filename =~ m{ \. $e \z }xms;
next FILE unless exists $ext{$e};
- $matched_ext = 1;
+ $matched_ext = 1;
}
- next FILE unless $matched_ext;
+ next FILE unless $matched_ext;
}
my $config;
- eval {
- $config = $loader->load( $filename );
- };
+ eval {
+ $config = $loader->load( $filename );
+ };
- next if $EVAL_ERROR; # if it croaked or warned, we can't use it
+ next if $EVAL_ERROR; # if it croaked or warned, we can't use it
next if !$config;
- delete $files{$filename};
+ delete $files{$filename};
# post-process config with a filter callback, if we got one
$filter_cb->( $config ) if defined $filter_cb;
@@ -238,7 +238,7 @@
sub extensions {
my $class = shift;
my @ext = map { $_->extensions } $class->plugins;
- return wantarray ? @ext : [@ext];
+ return wantarray ? @ext : [@ext];
}
=head1 DIAGNOSTICS
@@ -289,7 +289,7 @@
=head1 AUTHOR
-Joel Bernstein C<< <rataxis at cpan.org> >>
+Joel Bernstein E<lt>rataxis at cpan.orgE<gt>
=head1 CONTRIBUTORS
Modified: trunk/Config-Any/t/01-use.t
===================================================================
--- trunk/Config-Any/t/01-use.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/01-use.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,10 +1,10 @@
-use Test::More tests => 6;
-
-BEGIN {
- use_ok( 'Config::Any' );
- use_ok( 'Config::Any::INI' );
- use_ok( 'Config::Any::JSON' );
- use_ok( 'Config::Any::Perl' );
- use_ok( 'Config::Any::XML' );
- use_ok( 'Config::Any::YAML' );
-}
+use Test::More tests => 6;
+
+BEGIN {
+ use_ok( 'Config::Any' );
+ use_ok( 'Config::Any::INI' );
+ use_ok( 'Config::Any::JSON' );
+ use_ok( 'Config::Any::Perl' );
+ use_ok( 'Config::Any::XML' );
+ use_ok( 'Config::Any::YAML' );
+}
Modified: trunk/Config-Any/t/10-branches.t
===================================================================
--- trunk/Config-Any/t/10-branches.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/10-branches.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,26 +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 files");
- Config::Any->load_stems({});
- like (shift @warnings, qr/^no stems specified/, "load_stems expects stems");
-}
-
-my @files = glob("t/conf/conf.*");
-my $filter = sub { return };
-ok(Config::Any->load_files({files=>\@files, use_ext=>0}), "use_ext 0 works");
-ok(Config::Any->load_files({files=>\@files, use_ext=>1}), "use_ext 1 works");
-
-ok(Config::Any->load_files({files=>\@files, use_ext=>1, filter=>\&$filter}), "filter works");
-eval {Config::Any->load_files({files=>\@files, use_ext=>1, filter=>sub{die}}) };
-ok($@, "filter breaks");
-
-my @stems = qw(t/conf/conf);
-ok(Config::Any->load_stems({stems=>\@stems, use_ext=>1}), "load_stems with stems works");
+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 files");
+ Config::Any->load_stems({});
+ like (shift @warnings, qr/^no stems specified/, "load_stems expects stems");
+}
+
+my @files = glob("t/conf/conf.*");
+my $filter = sub { return };
+ok(Config::Any->load_files({files=>\@files, use_ext=>0}), "use_ext 0 works");
+ok(Config::Any->load_files({files=>\@files, use_ext=>1}), "use_ext 1 works");
+
+ok(Config::Any->load_files({files=>\@files, use_ext=>1, filter=>\&$filter}), "filter works");
+eval {Config::Any->load_files({files=>\@files, use_ext=>1, filter=>sub{die}}) };
+ok($@, "filter breaks");
+
+my @stems = qw(t/conf/conf);
+ok(Config::Any->load_stems({stems=>\@stems, use_ext=>1}), "load_stems with stems works");
Modified: trunk/Config-Any/t/20-parse.t
===================================================================
--- trunk/Config-Any/t/20-parse.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/20-parse.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,63 +1,63 @@
-package MockApp;
-use strict;
-use warnings;
-
-$|++;
-use Test::More tests => 54;
-use Scalar::Util qw(blessed reftype);
-use Config::Any;
-use Config::Any::General;
-use Config::Any::INI;
-use Config::Any::JSON;
-use Config::Any::Perl;
-use Config::Any::XML;
-use Config::Any::YAML;
-
-
-our %ext_map = (
- conf => 'Config::Any::General',
- ini => 'Config::Any::INI',
- json => 'Config::Any::JSON',
- pl => 'Config::Any::Perl',
- xml => 'Config::Any::XML',
- yml => 'Config::Any::YAML'
-);
-
-sub load_parser_for {
- my $f = shift;
- return unless $f;
-
- my ($ext) = $f =~ m{ \. ( [^\.]+ ) \z }xms;
- my $mod = $ext_map{$ext};
- my $mod_load_result;
- eval { $mod_load_result = $mod->load( $f ); delete $INC{$f} if $ext eq 'pl' };
- return $@ ? (1,$mod) : (0,$mod);
-}
-
-for my $f (map { "t/conf/conf.$_" } keys %ext_map) {
- my ($skip,$mod) = load_parser_for($f);
- SKIP: {
- skip "File loading backend for $mod not found", 9 if $skip;
-
- ok(my $c_arr = Config::Any->load_files({files=>[$f], use_ext=>1}),
- "load_files with use_ext works [$f]");
- ok(my $c = $c_arr->[0], "load_files returns an arrayref");
-
- ok(ref $c, "load_files arrayref contains a ref");
- my $ref = blessed $c ? reftype $c : ref $c;
- is(substr($ref,0,4), "HASH", "hashref");
-
- my ($name, $cfg) = each %$c;
- is($name, $f, "filename matches");
-
- my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;
- is(substr($cfgref,0,4), "HASH", "hashref cfg");
-
- is( $cfg->{name}, 'TestApp', "appname parses" );
- is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar',
- "component->cntrlr->foo = bar" );
- is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy',
- "model->model::baz->qux = xyzzy" );
- }
-}
-
+package MockApp;
+use strict;
+use warnings;
+
+$|++;
+use Test::More tests => 54;
+use Scalar::Util qw(blessed reftype);
+use Config::Any;
+use Config::Any::General;
+use Config::Any::INI;
+use Config::Any::JSON;
+use Config::Any::Perl;
+use Config::Any::XML;
+use Config::Any::YAML;
+
+
+our %ext_map = (
+ conf => 'Config::Any::General',
+ ini => 'Config::Any::INI',
+ json => 'Config::Any::JSON',
+ pl => 'Config::Any::Perl',
+ xml => 'Config::Any::XML',
+ yml => 'Config::Any::YAML'
+);
+
+sub load_parser_for {
+ my $f = shift;
+ return unless $f;
+
+ my ($ext) = $f =~ m{ \. ( [^\.]+ ) \z }xms;
+ my $mod = $ext_map{$ext};
+ my $mod_load_result;
+ eval { $mod_load_result = $mod->load( $f ); delete $INC{$f} if $ext eq 'pl' };
+ return $@ ? (1,$mod) : (0,$mod);
+}
+
+for my $f (map { "t/conf/conf.$_" } keys %ext_map) {
+ my ($skip,$mod) = load_parser_for($f);
+ SKIP: {
+ skip "File loading backend for $mod not found", 9 if $skip;
+
+ ok(my $c_arr = Config::Any->load_files({files=>[$f], use_ext=>1}),
+ "load_files with use_ext works [$f]");
+ ok(my $c = $c_arr->[0], "load_files returns an arrayref");
+
+ ok(ref $c, "load_files arrayref contains a ref");
+ my $ref = blessed $c ? reftype $c : ref $c;
+ is(substr($ref,0,4), "HASH", "hashref");
+
+ my ($name, $cfg) = each %$c;
+ is($name, $f, "filename matches");
+
+ my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;
+ is(substr($cfgref,0,4), "HASH", "hashref cfg");
+
+ is( $cfg->{name}, 'TestApp', "appname parses" );
+ is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar',
+ "component->cntrlr->foo = bar" );
+ is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy',
+ "model->model::baz->qux = xyzzy" );
+ }
+}
+
Modified: trunk/Config-Any/t/50-general.t
===================================================================
--- trunk/Config-Any/t/50-general.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/50-general.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,11 +1,11 @@
-use Test::More tests => 2;
-
-use Config::Any::General;
-
-my $config = eval { Config::Any::General->load( 't/conf/conf.conf' ) };
-
-SKIP: {
- skip "Couldn't Load Config::General plugin", 2 if $@;
- ok( $config );
- is( $config->{ name }, 'TestApp' );
-}
+use Test::More tests => 2;
+
+use Config::Any::General;
+
+my $config = eval { Config::Any::General->load( 't/conf/conf.conf' ) };
+
+SKIP: {
+ skip "Couldn't Load Config::General plugin", 2 if $@;
+ ok( $config );
+ is( $config->{ name }, 'TestApp' );
+}
Modified: trunk/Config-Any/t/52-json.t
===================================================================
--- trunk/Config-Any/t/52-json.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/52-json.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,11 +1,11 @@
-use Test::More tests => 2;
-
-use Config::Any::JSON;
-
-my $config = eval { Config::Any::JSON->load( 't/conf/conf.json' ) };
-
-SKIP: {
- skip "Couldn't Load JSON plugin", 2 if $@;
- ok( $config );
- is( $config->{ name }, 'TestApp' );
-}
+use Test::More tests => 2;
+
+use Config::Any::JSON;
+
+my $config = eval { Config::Any::JSON->load( 't/conf/conf.json' ) };
+
+SKIP: {
+ skip "Couldn't Load JSON plugin", 2 if $@;
+ ok( $config );
+ is( $config->{ name }, 'TestApp' );
+}
Modified: trunk/Config-Any/t/53-perl.t
===================================================================
--- trunk/Config-Any/t/53-perl.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/53-perl.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,11 +1,11 @@
-use Test::More tests => 2;
-
-use Config::Any::Perl;
-
-my $config = eval { Config::Any::Perl->load( 't/conf/conf.pl' ) };
-
-SKIP: {
- skip "Couldn't Load Perl plugin", 2 if $@;
- ok( $config );
- is( $config->{ name }, 'TestApp' );
-}
+use Test::More tests => 2;
+
+use Config::Any::Perl;
+
+my $config = eval { Config::Any::Perl->load( 't/conf/conf.pl' ) };
+
+SKIP: {
+ skip "Couldn't Load Perl plugin", 2 if $@;
+ ok( $config );
+ is( $config->{ name }, 'TestApp' );
+}
Modified: trunk/Config-Any/t/54-xml.t
===================================================================
--- trunk/Config-Any/t/54-xml.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/54-xml.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,11 +1,11 @@
-use Test::More tests => 2;
-
-use Config::Any::XML;
-
-my $config = eval { Config::Any::XML->load( 't/conf/conf.xml' ) };
-
-SKIP: {
- skip "Couldn't Load XML plugin", 2 if $@;
- ok( $config );
- is( $config->{ name }, 'TestApp' );
-}
+use Test::More tests => 2;
+
+use Config::Any::XML;
+
+my $config = eval { Config::Any::XML->load( 't/conf/conf.xml' ) };
+
+SKIP: {
+ skip "Couldn't Load XML plugin", 2 if $@;
+ ok( $config );
+ is( $config->{ name }, 'TestApp' );
+}
Modified: trunk/Config-Any/t/55-yaml.t
===================================================================
--- trunk/Config-Any/t/55-yaml.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/55-yaml.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,11 +1,11 @@
-use Test::More tests => 2;
-
-use Config::Any::YAML;
-
-my $config = eval { Config::Any::YAML->load( 't/conf/conf.yml' ) };
-
-SKIP: {
- skip "Couldn't Load YAML plugin", 2 if $@;
- ok( $config );
- is( $config->{ name }, 'TestApp' );
-}
+use Test::More tests => 2;
+
+use Config::Any::YAML;
+
+my $config = eval { Config::Any::YAML->load( 't/conf/conf.yml' ) };
+
+SKIP: {
+ skip "Couldn't Load YAML plugin", 2 if $@;
+ ok( $config );
+ is( $config->{ name }, 'TestApp' );
+}
Modified: trunk/Config-Any/t/61-features.t
===================================================================
--- trunk/Config-Any/t/61-features.t 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/61-features.t 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,51 +1,51 @@
-package MockApp;
-use strict;
-use warnings;
-
-$|++;
-
-use Test::More tests => 10;
-use Scalar::Util qw(blessed reftype);
-
-use Config::Any;
-use Config::Any::INI;
-
-our $cfg_file = 't/conf/conf.foo';
-
-eval { Config::Any::INI->load($cfg_file); };
-SKIP: {
- skip "File loading backend for INI not found", 10 if $@;
-
- ok( my $c_arr = Config::Any->load_files({
- files => [ $cfg_file ],
- force_plugins => [qw(Config::Any::INI)]
- }), "load file with parser forced" );
-
- ok(my $c = $c_arr->[0], "load_files returns an arrayref");
-
- ok(ref $c, "load_files arrayref contains a ref");
- my $ref = blessed $c ? reftype $c : ref $c;
- is(substr($ref,0,4), "HASH", "hashref");
-
- my ($name, $cfg) = each %$c;
- is($name, $cfg_file, "filename matches");
-
- my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;
- is(substr($cfgref,0,4), "HASH", "hashref cfg");
-
- is( $cfg->{name}, 'TestApp', "appname parses" );
- is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar',
- "component->cntrlr->foo = bar" );
- is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy',
- "model->model::baz->qux = xyzzy" );
-
-
- ok( my $c_arr_2 = Config::Any->load_files({
- files => [ $cfg_file ],
- force_plugins => [qw(Config::Any::INI)],
- use_ext => 1
- }), "load file with parser forced" );
-}
-
-
-
+package MockApp;
+use strict;
+use warnings;
+
+$|++;
+
+use Test::More tests => 10;
+use Scalar::Util qw(blessed reftype);
+
+use Config::Any;
+use Config::Any::INI;
+
+our $cfg_file = 't/conf/conf.foo';
+
+eval { Config::Any::INI->load($cfg_file); };
+SKIP: {
+ skip "File loading backend for INI not found", 10 if $@;
+
+ ok( my $c_arr = Config::Any->load_files({
+ files => [ $cfg_file ],
+ force_plugins => [qw(Config::Any::INI)]
+ }), "load file with parser forced" );
+
+ ok(my $c = $c_arr->[0], "load_files returns an arrayref");
+
+ ok(ref $c, "load_files arrayref contains a ref");
+ my $ref = blessed $c ? reftype $c : ref $c;
+ is(substr($ref,0,4), "HASH", "hashref");
+
+ my ($name, $cfg) = each %$c;
+ is($name, $cfg_file, "filename matches");
+
+ my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;
+ is(substr($cfgref,0,4), "HASH", "hashref cfg");
+
+ is( $cfg->{name}, 'TestApp', "appname parses" );
+ is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar',
+ "component->cntrlr->foo = bar" );
+ is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy',
+ "model->model::baz->qux = xyzzy" );
+
+
+ ok( my $c_arr_2 = Config::Any->load_files({
+ files => [ $cfg_file ],
+ force_plugins => [qw(Config::Any::INI)],
+ use_ext => 1
+ }), "load file with parser forced" );
+}
+
+
+
Modified: trunk/Config-Any/t/conf/conf.pl
===================================================================
--- trunk/Config-Any/t/conf/conf.pl 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/conf/conf.pl 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,13 +1,13 @@
-{
- name => 'TestApp',
- Component => {
- 'Controller::Foo' => {
- foo => 'bar'
- }
- },
- Model => {
- 'Model::Baz' => {
- qux => 'xyzzy'
- }
- }
-}
+{
+ name => 'TestApp',
+ Component => {
+ 'Controller::Foo' => {
+ foo => 'bar'
+ }
+ },
+ Model => {
+ 'Model::Baz' => {
+ qux => 'xyzzy'
+ }
+ }
+}
Modified: trunk/Config-Any/t/conf/conf.xml
===================================================================
--- trunk/Config-Any/t/conf/conf.xml 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/conf/conf.xml 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,9 +1,9 @@
-<config>
- <name>TestApp</name>
- <Component name="Controller::Foo">
- <foo>bar</foo>
- </Component>
- <Model name="Model::Baz">
- <qux>xyzzy</qux>
- </Model>
-</config>
+<config>
+ <name>TestApp</name>
+ <Component name="Controller::Foo">
+ <foo>bar</foo>
+ </Component>
+ <Model name="Model::Baz">
+ <qux>xyzzy</qux>
+ </Model>
+</config>
Modified: trunk/Config-Any/t/conf/conf.yml
===================================================================
--- trunk/Config-Any/t/conf/conf.yml 2007-08-22 02:28:08 UTC (rev 6706)
+++ trunk/Config-Any/t/conf/conf.yml 2007-08-22 03:21:48 UTC (rev 6707)
@@ -1,8 +1,8 @@
----
-name: TestApp
-Component:
- Controller::Foo:
- foo: bar
-Model:
- Model::Baz:
- qux: xyzzy
+---
+name: TestApp
+Component:
+ Controller::Foo:
+ foo: bar
+Model:
+ Model::Baz:
+ qux: xyzzy
More information about the Catalyst-commits
mailing list