+++ /dev/null
-use strict;
-use warnings;
-use Module::Build;
-
-my $builder = Module::Build->new(
- module_name => 'Config::Any',
- license => 'perl',
- dist_author => 'Joel Bernstein <rataxis@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();
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:
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
+++ /dev/null
-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
--- /dev/null
+# 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$
--- /dev/null
+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;
-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
+
+ And at least one of the following: Config::General Config::Tiny JSON
+ YAML JSON::Syck YAML::Syck XML::Simple
+
+INCOMPATIBILITIES
+ None reported.
+
+BUGS AND LIMITATIONS
+ No bugs have been reported.
+
+ Please report any bugs or feature requests to
+ "bug-config-any@rt.cpan.org", or through the web interface at
+ <http://rt.cpan.org>.
+
+AUTHOR
+ Joel Bernstein <rataxis@cpan.org>
+
+CONTRIBUTORS
+ This module was based on the original Catalyst::Plugin::ConfigLoader
+ module by Brian Cassidy "<bricas@cpan.org>".
+
+ With ideas and support from Matt S Trout "<mst@shadowcatsystems.co.uk>".
+
+ Further enhancements suggested by Evan Kaufman "<evank@cpan.org>".
+
+LICENCE AND COPYRIGHT
+ Copyright (c) 2006, Portugal Telecom "http://www.sapo.pt/". All rights
+ reserved. Portions copyright 2007, Joel Bernstein "<rataxis@cpan.org>".
-Module::Pluggable >= 3.01
+ This module is free software; you can redistribute it and/or modify it
+ under the same terms as Perl itself. See perlartistic.
-COPYRIGHT AND LICENCE
+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.
-The development of this module was sponsored by SAPO, a division of Portugal Telecom.
+ 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.
-Copyright (C) 2006, Portugal Telecom
+SEE ALSO
+ Catalyst::Plugin::ConfigLoader -- now a wrapper around this module.
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself.
use Module::Pluggable::Object ();
use English qw(-no_match_vars);
-our $VERSION = '0.06_01';
+our $VERSION = '0.07';
=head1 NAME
=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
@{$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;
# 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:
# 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;
sub extensions {
my $class = shift;
my @ext = map { $_->extensions } $class->plugins;
- return wantarray ? @ext : [@ext];
+ return wantarray ? @ext : [@ext];
}
=head1 DIAGNOSTICS
=head1 AUTHOR
-Joel Bernstein C<< <rataxis@cpan.org> >>
+Joel Bernstein E<lt>rataxis@cpan.orgE<gt>
=head1 CONTRIBUTORS
-package Config::Any::General;\r
-\r
-use strict;\r
-use warnings;\r
-\r
-=head1 NAME\r
-\r
-Config::Any::General - Load Config::General files\r
-\r
-=head1 DESCRIPTION\r
-\r
-Loads Config::General files. Example:\r
-\r
- name = TestApp\r
- <Component Controller::Foo>\r
- foo bar\r
- </Component>\r
- <Model Baz>\r
- qux xyzzy\r
- </Model>\r
-\r
-=head1 METHODS\r
-\r
-=head2 extensions( )\r
-\r
-return an array of valid extensions (C<cnf>, C<conf>).\r
-\r
-=cut\r
-\r
-sub extensions {\r
- return qw( cnf conf );\r
-}\r
-\r
-=head2 load( $file )\r
-\r
-Attempts to load C<$file> via Config::General.\r
-\r
-=cut\r
-\r
-sub load {\r
- my $class = shift;\r
- my $file = shift;\r
-\r
- # work around bug (?) in Config::General\r
-# return if $class->_test_perl($file);\r
-\r
- require Config::General;\r
- my $configfile = Config::General->new( $file );\r
- my $config = { $configfile->getall };\r
- \r
- return $config;\r
-}\r
-\r
-# this is a bit of a hack but necessary, because Config::General is *far* too lax\r
-# about what it will load -- specifically, it seems to be quite happy to load a Perl\r
-# config file (ie, a file which is valid Perl and creates a hashref) as if it were\r
-# an Apache-style configuration file, presumably due to laziness on the part of the\r
-# developer.\r
-\r
-sub _test_perl {\r
- my ($class, $file) = @_;\r
- my $is_perl_src;\r
- eval { $is_perl_src = do "$file"; };\r
- delete $INC{$file}; # so we don't screw stuff later on\r
- return defined $is_perl_src;\r
-}\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4 \r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 CONTRIBUTORS\r
-\r
-=over 4\r
-\r
-=item * Joel Bernstein C<< <rataxis@cpan.org> >>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Brian Cassidy\r
-\r
-Portions Copyright 2006 Portugal Telecom\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=head1 SEE ALSO\r
-\r
-=over 4 \r
-\r
-=item * L<Catalyst>\r
-\r
-=item * L<Config::Any>\r
-\r
-=item * L<Config::General>\r
-\r
-=back\r
-\r
-=cut\r
-\r
-1;\r
-\r
+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@cpan.orgE<gt>
+
+=back
+
+=head1 CONTRIBUTORS
+
+=over 4
+
+=item * Joel Bernstein C<< <rataxis@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::INI;\r
-\r
-use strict;\r
-use warnings;\r
-\r
-our $MAP_SECTION_SPACE_TO_NESTED_KEY = 1;\r
-\r
-=head1 NAME\r
-\r
-Config::Any::INI - Load INI config files\r
-\r
-=head1 DESCRIPTION\r
-\r
-Loads INI files. Example:\r
-\r
- name=TestApp\r
- \r
- [Controller::Foo]\r
- foo=bar\r
- \r
- [Model::Baz]\r
- qux=xyzzy\r
-\r
-=head1 METHODS\r
-\r
-=head2 extensions( )\r
-\r
-return an array of valid extensions (C<ini>).\r
-\r
-=cut\r
-\r
-sub extensions {\r
- return qw( ini );\r
-}\r
-\r
-=head2 load( $file )\r
-\r
-Attempts to load C<$file> as an INI file.\r
-\r
-=cut\r
-\r
-sub load {\r
- my $class = shift;\r
- my $file = shift;\r
-\r
- require Config::Tiny;\r
- my $config = Config::Tiny->read( $file );\r
-\r
- my $main = delete $config->{ _ };\r
- my $out;\r
- $out->{$_} = $main->{$_} for keys %$main;\r
-\r
- for my $k (keys %$config) {\r
- my @keys = split /\s+/, $k if $MAP_SECTION_SPACE_TO_NESTED_KEY;\r
- my $ref = $config->{$k};\r
-\r
- if (@keys > 1) {\r
- my ($a, $b) = @keys[0,1];\r
- $out->{$a}->{$b} = $ref;\r
- } else {\r
- $out->{$k} = $ref;\r
- }\r
- }\r
- return $out;\r
-}\r
-\r
-=head1 PACKAGE VARIABLES\r
-\r
-=over 4\r
-\r
-=item $MAP_SECTION_SPACE_TO_NESTED_KEY (boolean)\r
-\r
-This variable controls whether spaces in INI section headings will be expanded into nested hash keys.\r
-e.g. it controls whether [Full Power] maps to $config->{'Full Power'} or $config->{'Full'}->{'Power'}\r
-\r
-By default it is set to 1 (i.e. true). \r
-\r
-Set it to 0 to preserve literal spaces in section headings:\r
-\r
- use Config::Any;\r
- use Config::Any::INI;\r
- $Config::Any::INI::MAP_SECTION_SPACE_TO_NESTED_KEY = 0;\r
-\r
-=back\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4 \r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=item * Joel Bernstein E<lt>rataxis@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Brian Cassidy, portions copyright 2006, 2007 by Joel Bernstein\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=head1 SEE ALSO\r
-\r
-=over 4 \r
-\r
-=item * L<Catalyst>\r
-\r
-=item * L<Config::Any>\r
-\r
-=item * L<Config::Tiny>\r
-\r
-=back\r
-\r
-=cut\r
-\r
-1;\r
+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@cpan.orgE<gt>
+
+=item * Joel Bernstein E<lt>rataxis@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::JSON;\r
-\r
-use strict;\r
-use warnings;\r
-\r
-=head1 NAME\r
-\r
-Config::Any::JSON - Load JSON config files\r
-\r
-=head1 DESCRIPTION\r
-\r
-Loads JSON files. Example:\r
-\r
- {\r
- "name": "TestApp",\r
- "Controller::Foo": {\r
- "foo": "bar"\r
- },\r
- "Model::Baz": {\r
- "qux": "xyzzy"\r
- }\r
- }\r
-\r
-=head1 METHODS\r
-\r
-=head2 extensions( )\r
-\r
-return an array of valid extensions (C<json>, C<jsn>).\r
-\r
-=cut\r
-\r
-sub extensions {\r
- return qw( json jsn );\r
-}\r
-\r
-=head2 load( $file )\r
-\r
-Attempts to load C<$file> as a JSON file.\r
-\r
-=cut\r
-\r
-sub load {\r
- my $class = shift;\r
- my $file = shift;\r
-\r
- open( my $fh, $file ) or die $!;\r
- my $content = do { local $/; <$fh> };\r
- close $fh;\r
-\r
- eval { require JSON::Syck; };\r
- if( $@ ) {\r
- require JSON;\r
- JSON->import;\r
- return jsonToObj( $content );\r
- }\r
- else {\r
- return JSON::Syck::Load( $content );\r
- }\r
-}\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4 \r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Brian Cassidy\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=head1 SEE ALSO\r
-\r
-=over 4 \r
-\r
-=item * L<Catalyst>\r
-\r
-=item * L<Config::Any>\r
-\r
-=item * L<JSON>\r
-\r
-=item * L<JSON::Syck>\r
-\r
-=back\r
-\r
-=cut\r
-\r
-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@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;
-package Config::Any::Perl;\r
-\r
-use strict;\r
-use warnings;\r
-\r
-=head1 NAME\r
-\r
-Config::Any::Perl - Load Perl config files\r
-\r
-=head1 DESCRIPTION\r
-\r
-Loads Perl files. Example:\r
-\r
- {\r
- name => 'TestApp',\r
- 'Controller::Foo' => {\r
- foo => 'bar'\r
- },\r
- 'Model::Baz' => {\r
- qux => 'xyzzy'\r
- }\r
- }\r
-\r
-=head1 METHODS\r
-\r
-=head2 extensions( )\r
-\r
-return an array of valid extensions (C<pl>, C<perl>).\r
-\r
-=cut\r
-\r
-sub extensions {\r
- return qw( pl perl );\r
-}\r
-\r
-=head2 load( $file )\r
-\r
-Attempts to load C<$file> as a Perl file.\r
-\r
-=cut\r
-\r
-sub load {\r
- my $class = shift;\r
- my $file = shift;\r
- return eval { require $file };\r
-}\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4 \r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Brian Cassidy\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=head1 SEE ALSO\r
-\r
-=over 4 \r
-\r
-=item * L<Catalyst>\r
-\r
-=item * L<Config::Any>\r
-\r
-=back\r
-\r
-=cut\r
-\r
-1;\r
+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@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::XML;\r
-\r
-use strict;\r
-use warnings;\r
-\r
-=head1 NAME\r
-\r
-Config::Any::XML - Load XML config files\r
-\r
-=head1 DESCRIPTION\r
-\r
-Loads XML files. Example:\r
-\r
- <config>\r
- <name>TestApp</name>\r
- <component name="Controller::Foo">\r
- <foo>bar</foo>\r
- </component>\r
- <model name="Baz">\r
- <qux>xyzzy</qux>\r
- </model>\r
- </config>\r
-\r
-=head1 METHODS\r
-\r
-=head2 extensions( )\r
-\r
-return an array of valid extensions (C<xml>).\r
-\r
-=cut\r
-\r
-sub extensions {\r
- return qw( xml );\r
-}\r
-\r
-=head2 load( $file )\r
-\r
-Attempts to load C<$file> as an XML file.\r
-\r
-=cut\r
-\r
-sub load {\r
- my $class = shift;\r
- my $file = shift;\r
-\r
- require XML::Simple;\r
- XML::Simple->import;\r
- my $config = XMLin( \r
- $file, \r
- ForceArray => [ qw( component model view controller ) ],\r
- );\r
-\r
- return $class->_coerce($config);\r
-}\r
-\r
-sub _coerce {\r
- # coerce the XML-parsed config into the correct format\r
- my $class = shift;\r
- my $config = shift;\r
- my $out;\r
- for my $k (keys %$config) {\r
- my $ref = $config->{$k};\r
- my $name = ref $ref ? delete $ref->{name} : undef;\r
- if (defined $name) {\r
- $out->{$k}->{$name} = $ref; \r
- } else {\r
- $out->{$k} = $ref;\r
- }\r
- }\r
- $out;\r
-}\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4 \r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=item * Joel Bernstein E<lt>rataxis@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Brian Cassidy\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=head1 SEE ALSO\r
-\r
-=over 4 \r
-\r
-=item * L<Catalyst>\r
-\r
-=item * L<Config::Any>\r
-\r
-=item * L<XML::Simple>\r
-\r
-=back\r
-\r
-=cut\r
-\r
-1;\r
+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@cpan.orgE<gt>
+
+=item * Joel Bernstein E<lt>rataxis@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::YAML;\r
-\r
-use strict;\r
-use warnings;\r
-\r
-=head1 NAME\r
-\r
-Config::Any::YAML - Load YAML config files\r
-\r
-=head1 DESCRIPTION\r
-\r
-Loads YAML files. Example:\r
-\r
- ---\r
- name: TestApp\r
- Controller::Foo:\r
- foo: bar\r
- Model::Baz:\r
- qux: xyzzy\r
- \r
-\r
-=head1 METHODS\r
-\r
-=head2 extensions( )\r
-\r
-return an array of valid extensions (C<yml>, C<yaml>).\r
-\r
-=cut\r
-\r
-sub extensions {\r
- return qw( yml yaml );\r
-}\r
-\r
-=head2 load( $file )\r
-\r
-Attempts to load C<$file> as a YAML file.\r
-\r
-=cut\r
-\r
-sub load {\r
- my $class = shift;\r
- my $file = shift;\r
-\r
- eval { require YAML::Syck; };\r
- if( $@ ) {\r
- require YAML;\r
- return YAML::LoadFile( $file );\r
- }\r
- else {\r
- open( my $fh, $file ) or die $!;\r
- my $content = do { local $/; <$fh> };\r
- close $fh;\r
- return YAML::Syck::Load( $content );\r
- }\r
-}\r
-\r
-=head1 AUTHOR\r
-\r
-=over 4 \r
-\r
-=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
-\r
-=back\r
-\r
-=head1 COPYRIGHT AND LICENSE\r
-\r
-Copyright 2006 by Brian Cassidy\r
-\r
-This library is free software; you can redistribute it and/or modify\r
-it under the same terms as Perl itself. \r
-\r
-=head1 SEE ALSO\r
-\r
-=over 4 \r
-\r
-=item * L<Catalyst>\r
-\r
-=item * L<Config::Any>\r
-\r
-=item * L<YAML>\r
-\r
-=item * L<YAML::Syck>\r
-\r
-=back\r
-\r
-=cut\r
-\r
-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@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;
-use Test::More tests => 6;\r
-\r
-BEGIN { \r
- use_ok( 'Config::Any' );\r
- use_ok( 'Config::Any::INI' );\r
- use_ok( 'Config::Any::JSON' );\r
- use_ok( 'Config::Any::Perl' );\r
- use_ok( 'Config::Any::XML' );\r
- use_ok( 'Config::Any::YAML' );\r
-}\r
+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 => 9;\r
-use Config::Any;\r
-\r
-ok ( ! Config::Any->load_files(), "load_files expects args" );\r
-ok ( ! Config::Any->load_stems(), "load_stems expects args" );\r
-\r
-{\r
- my @warnings;\r
- local $SIG{__WARN__} = sub { push @warnings, @_ };\r
- Config::Any->load_files({});\r
- like (shift @warnings, qr/^no files specified/, "load_files expects files");\r
- Config::Any->load_stems({});\r
- like (shift @warnings, qr/^no stems specified/, "load_stems expects stems");\r
-}\r
-\r
-my @files = glob("t/conf/conf.*");\r
-my $filter = sub { return };\r
-ok(Config::Any->load_files({files=>\@files, use_ext=>0}), "use_ext 0 works");\r
-ok(Config::Any->load_files({files=>\@files, use_ext=>1}), "use_ext 1 works");\r
-\r
-ok(Config::Any->load_files({files=>\@files, use_ext=>1, filter=>\&$filter}), "filter works");\r
-eval {Config::Any->load_files({files=>\@files, use_ext=>1, filter=>sub{die}}) };\r
-ok($@, "filter breaks");\r
-\r
-my @stems = qw(t/conf/conf);\r
-ok(Config::Any->load_stems({stems=>\@stems, use_ext=>1}), "load_stems with stems works");\r
+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");
-package MockApp;\r
-use strict;\r
-use warnings;\r
-\r
-$|++;\r
-use Test::More tests => 54;\r
-use Scalar::Util qw(blessed reftype);\r
-use Config::Any;\r
-use Config::Any::General;\r
-use Config::Any::INI;\r
-use Config::Any::JSON;\r
-use Config::Any::Perl;\r
-use Config::Any::XML;\r
-use Config::Any::YAML;\r
-\r
-\r
-our %ext_map = (\r
- conf => 'Config::Any::General',\r
- ini => 'Config::Any::INI',\r
- json => 'Config::Any::JSON',\r
- pl => 'Config::Any::Perl',\r
- xml => 'Config::Any::XML',\r
- yml => 'Config::Any::YAML'\r
-);\r
-\r
-sub load_parser_for {\r
- my $f = shift;\r
- return unless $f;\r
-\r
- my ($ext) = $f =~ m{ \. ( [^\.]+ ) \z }xms;\r
- my $mod = $ext_map{$ext};\r
- my $mod_load_result;\r
- eval { $mod_load_result = $mod->load( $f ); delete $INC{$f} if $ext eq 'pl' };\r
- return $@ ? (1,$mod) : (0,$mod);\r
-}\r
-\r
-for my $f (map { "t/conf/conf.$_" } keys %ext_map) {\r
- my ($skip,$mod) = load_parser_for($f);\r
- SKIP: {\r
- skip "File loading backend for $mod not found", 9 if $skip;\r
- \r
- ok(my $c_arr = Config::Any->load_files({files=>[$f], use_ext=>1}), \r
- "load_files with use_ext works [$f]");\r
- ok(my $c = $c_arr->[0], "load_files returns an arrayref");\r
- \r
- ok(ref $c, "load_files arrayref contains a ref");\r
- my $ref = blessed $c ? reftype $c : ref $c;\r
- is(substr($ref,0,4), "HASH", "hashref");\r
-\r
- my ($name, $cfg) = each %$c;\r
- is($name, $f, "filename matches");\r
- \r
- my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;\r
- is(substr($cfgref,0,4), "HASH", "hashref cfg");\r
-\r
- is( $cfg->{name}, 'TestApp', "appname parses" );\r
- is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar', \r
- "component->cntrlr->foo = bar" );\r
- is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy', \r
- "model->model::baz->qux = xyzzy" );\r
- }\r
-}\r
-\r
+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" );
+ }
+}
+
-use Test::More tests => 2;\r
-\r
-use Config::Any::General;\r
-\r
-my $config = eval { Config::Any::General->load( 't/conf/conf.conf' ) };\r
-\r
-SKIP: {\r
- skip "Couldn't Load Config::General plugin", 2 if $@;\r
- ok( $config );\r
- is( $config->{ name }, 'TestApp' );\r
-}\r
+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;\r
-\r
-use Config::Any::JSON;\r
-\r
-my $config = eval { Config::Any::JSON->load( 't/conf/conf.json' ) };\r
-\r
-SKIP: {\r
- skip "Couldn't Load JSON plugin", 2 if $@;\r
- ok( $config );\r
- is( $config->{ name }, 'TestApp' );\r
-}\r
+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;\r
-\r
-use Config::Any::Perl;\r
-\r
-my $config = eval { Config::Any::Perl->load( 't/conf/conf.pl' ) };\r
-\r
-SKIP: {\r
- skip "Couldn't Load Perl plugin", 2 if $@;\r
- ok( $config );\r
- is( $config->{ name }, 'TestApp' );\r
-}\r
+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;\r
-\r
-use Config::Any::XML;\r
-\r
-my $config = eval { Config::Any::XML->load( 't/conf/conf.xml' ) };\r
-\r
-SKIP: {\r
- skip "Couldn't Load XML plugin", 2 if $@;\r
- ok( $config );\r
- is( $config->{ name }, 'TestApp' );\r
-}\r
+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;\r
-\r
-use Config::Any::YAML;\r
-\r
-my $config = eval { Config::Any::YAML->load( 't/conf/conf.yml' ) };\r
-\r
-SKIP: {\r
- skip "Couldn't Load YAML plugin", 2 if $@;\r
- ok( $config );\r
- is( $config->{ name }, 'TestApp' );\r
-}\r
+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' );
+}
-package MockApp;\r
-use strict;\r
-use warnings;\r
-\r
-$|++;\r
-\r
-use Test::More tests => 10;\r
-use Scalar::Util qw(blessed reftype);\r
-\r
-use Config::Any;\r
-use Config::Any::INI;\r
-\r
-our $cfg_file = 't/conf/conf.foo';\r
-\r
-eval { Config::Any::INI->load($cfg_file); };\r
-SKIP: {\r
- skip "File loading backend for INI not found", 10 if $@;\r
-\r
- ok( my $c_arr = Config::Any->load_files({ \r
- files => [ $cfg_file ], \r
- force_plugins => [qw(Config::Any::INI)] \r
- }), "load file with parser forced" );\r
-\r
- ok(my $c = $c_arr->[0], "load_files returns an arrayref");\r
- \r
- ok(ref $c, "load_files arrayref contains a ref");\r
- my $ref = blessed $c ? reftype $c : ref $c;\r
- is(substr($ref,0,4), "HASH", "hashref");\r
-\r
- my ($name, $cfg) = each %$c;\r
- is($name, $cfg_file, "filename matches");\r
- \r
- my $cfgref = blessed $cfg ? reftype $cfg : ref $cfg;\r
- is(substr($cfgref,0,4), "HASH", "hashref cfg");\r
-\r
- is( $cfg->{name}, 'TestApp', "appname parses" );\r
- is( $cfg->{Component}{ "Controller::Foo" }->{ foo }, 'bar', \r
- "component->cntrlr->foo = bar" );\r
- is( $cfg->{Model}{ "Model::Baz" }->{ qux }, 'xyzzy', \r
- "model->model::baz->qux = xyzzy" );\r
-\r
-\r
- ok( my $c_arr_2 = Config::Any->load_files({ \r
- files => [ $cfg_file ], \r
- force_plugins => [qw(Config::Any::INI)],\r
- use_ext => 1\r
- }), "load file with parser forced" );\r
-}\r
-\r
-\r
-\r
+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" );
+}
+
+
+
-{\r
- name => 'TestApp',\r
- Component => {\r
- 'Controller::Foo' => {\r
- foo => 'bar'\r
- }\r
- },\r
- Model => {\r
- 'Model::Baz' => {\r
- qux => 'xyzzy'\r
- }\r
- }\r
-}\r
+{
+ name => 'TestApp',
+ Component => {
+ 'Controller::Foo' => {
+ foo => 'bar'
+ }
+ },
+ Model => {
+ 'Model::Baz' => {
+ qux => 'xyzzy'
+ }
+ }
+}
-<config>\r
- <name>TestApp</name>\r
- <Component name="Controller::Foo">\r
- <foo>bar</foo>\r
- </Component>\r
- <Model name="Model::Baz">\r
- <qux>xyzzy</qux>\r
- </Model>\r
-</config>\r
+<config>
+ <name>TestApp</name>
+ <Component name="Controller::Foo">
+ <foo>bar</foo>
+ </Component>
+ <Model name="Model::Baz">
+ <qux>xyzzy</qux>
+ </Model>
+</config>
----\r
-name: TestApp\r
-Component:\r
- Controller::Foo:\r
- foo: bar\r
-Model:\r
- Model::Baz:\r
- qux: xyzzy\r
+---
+name: TestApp
+Component:
+ Controller::Foo:
+ foo: bar
+Model:
+ Model::Baz:
+ qux: xyzzy