From: Rafael Kitover Date: Mon, 2 Aug 2010 10:00:37 +0000 (+0000) Subject: enable -ForceArray option by default for Config::General X-Git-Tag: v0.20~9 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit%2FConfig-Any.git;a=commitdiff_plain;h=7adf5673d07031b77f7edd3403491512b9a48cb3 enable -ForceArray option by default for Config::General --- diff --git a/Changes b/Changes index 68d612f..c65bac5 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for Config-Any + - enable -ForceArray option by default for Config::General (caelum) + 0.19 Mon 15 Feb 2010 - add JSON::DWIW to the top of the JSON loaders list (caelum) - remove need for caching in Perl loader by using do() instead diff --git a/lib/Config/Any/General.pm b/lib/Config/Any/General.pm index c5de65c..936bb44 100644 --- a/lib/Config/Any/General.pm +++ b/lib/Config/Any/General.pm @@ -16,6 +16,7 @@ Loads Config::General files. Example: name = TestApp foo bar + bar [ arrayref-value ] qux xyzzy @@ -49,6 +50,8 @@ sub load { $args->{ -ConfigFile } = $file; + $args->{ -ForceArray } = 1 unless exists $args->{ -ForceArray }; + require Config::General; my $configfile = Config::General->new( %$args ); my $config = { $configfile->getall }; diff --git a/t/50-general.t b/t/50-general.t index c73c68a..6db7243 100644 --- a/t/50-general.t +++ b/t/50-general.t @@ -8,7 +8,7 @@ if ( !Config::Any::General->is_supported ) { plan skip_all => 'Config::General format not supported'; } else { - plan tests => 6; + plan tests => 7; } { @@ -24,6 +24,14 @@ else { ok( exists $config->{ component } ); } +{ + my $config = Config::Any::General->load( + 't/conf/single_element_arrayref.conf' + ); + is_deeply $config->{foo}, [ 'bar' ], + 'single element arrayref'; +} + # test invalid config { my $file = 't/invalid/conf.conf'; diff --git a/t/conf/single_element_arrayref.conf b/t/conf/single_element_arrayref.conf new file mode 100644 index 0000000..cb3b170 --- /dev/null +++ b/t/conf/single_element_arrayref.conf @@ -0,0 +1 @@ +foo [ bar ]