[Catalyst-commits] r11850 - in trunk/Config-Any: . lib/Config/Any t
t/conf
bricas at dev.catalyst.perl.org
bricas at dev.catalyst.perl.org
Mon Nov 16 12:49:59 GMT 2009
Author: bricas
Date: 2009-11-16 12:49:59 +0000 (Mon, 16 Nov 2009)
New Revision: 11850
Added:
trunk/Config-Any/t/conf/conf_arrayref.xml
Modified:
trunk/Config-Any/Changes
trunk/Config-Any/lib/Config/Any/XML.pm
trunk/Config-Any/t/54-xml.t
Log:
ensure XML loader's _coerce() method checks specifically for HASH refs
Modified: trunk/Config-Any/Changes
===================================================================
--- trunk/Config-Any/Changes 2009-11-16 09:15:00 UTC (rev 11849)
+++ trunk/Config-Any/Changes 2009-11-16 12:49:59 UTC (rev 11850)
@@ -1,6 +1,7 @@
Revision history for Config-Any
0.18 XXX
+ - ensure XML loader's _coerce() method checks specifically for HASH refs
- add YAML::XS to the top of the YAML loaders list
0.17 Thu 05 Feb 2009
Modified: trunk/Config-Any/lib/Config/Any/XML.pm
===================================================================
--- trunk/Config-Any/lib/Config/Any/XML.pm 2009-11-16 09:15:00 UTC (rev 11849)
+++ trunk/Config-Any/lib/Config/Any/XML.pm 2009-11-16 12:49:59 UTC (rev 11850)
@@ -57,14 +57,13 @@
}
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;
+ my $name = ref $ref eq 'HASH' ? delete $ref->{ name } : undef;
if ( defined $name ) {
$out->{ $k }->{ $name } = $ref;
}
Modified: trunk/Config-Any/t/54-xml.t
===================================================================
--- trunk/Config-Any/t/54-xml.t 2009-11-16 09:15:00 UTC (rev 11849)
+++ trunk/Config-Any/t/54-xml.t 2009-11-16 12:49:59 UTC (rev 11850)
@@ -8,7 +8,7 @@
plan skip_all => 'XML format not supported';
}
else {
- plan tests => 4;
+ plan tests => 6;
}
{
@@ -30,3 +30,12 @@
ok( !$config, 'config load failed' );
ok( $@, "error thrown ($@)" );
}
+
+# test conf file with array ref
+{
+ my $file = 't/conf/conf_arrayref.xml';
+ my $config = eval { Config::Any::XML->load( $file ) };
+
+ ok( $config, 'config loaded' );
+ ok( !$@, 'no error thrown' );
+}
Added: trunk/Config-Any/t/conf/conf_arrayref.xml
===================================================================
--- trunk/Config-Any/t/conf/conf_arrayref.xml (rev 0)
+++ trunk/Config-Any/t/conf/conf_arrayref.xml 2009-11-16 12:49:59 UTC (rev 11850)
@@ -0,0 +1,10 @@
+<?xml version="1.0"?>
+<form>
+ <elements type="Text">
+ <label>Label1</label>
+ </elements>
+ <elements type="Text">
+ <label>Label2</label>
+ </elements>
+ <indicator>submit</indicator>
+</form>
More information about the Catalyst-commits
mailing list