made the local suffix overrideable as per robkinyon's suggestion
[catagits/Catalyst-Plugin-ConfigLoader.git] / lib / Catalyst / Plugin / ConfigLoader / XML.pm
index e44bcae..f44346c 100644 (file)
@@ -13,13 +13,26 @@ Loads XML files. Example:
 \r
     <config>\r
         <name>TestApp</name>\r
-        <component name="Controller::Config">\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
@@ -27,28 +40,12 @@ Attempts to load C<$file> as an XML file.
 =cut\r
 \r
 sub load {\r
-       my $class    = shift;\r
-       my $confpath = shift;\r
-\r
-       my $file;\r
-    if( $confpath =~ /\.(.{3})$/ ) {\r
-        return unless $1 eq 'xml';\r
-        $file = $confpath;\r
-    }\r
-    else {\r
-        $file = "$confpath.xml";\r
-    }\r
-    \r
-    return unless -f $file;\r
+    my $class = shift;\r
+    my $file  = shift;\r
 \r
     require XML::Simple;\r
     XML::Simple->import;\r
-    my $config      = XMLin( $file, ForceArray => [ 'component' ] );\r
-\r
-    my $components = delete $config->{ component };\r
-       foreach my $element ( keys %$components ) {\r
-            $config->{ $element } = $components->{ $element };\r
-    }\r
+    my $config = XMLin( $file, ForceArray => [ qw( component model view controller ) ] );\r
 \r
     return $config;\r
 }\r
@@ -74,6 +71,10 @@ it under the same terms as Perl itself.
 \r
 =item * L<Catalyst>\r
 \r
+=item * L<Catalyst::Plugin::ConfigLoader>\r
+\r
+=item * L<XML::Simple>\r
+\r
 =back\r
 \r
 =cut\r