pod fixes
[catagits/Catalyst-Plugin-ConfigLoader.git] / lib / Catalyst / Plugin / ConfigLoader / XML.pm
1 package Catalyst::Plugin::ConfigLoader::XML;\r
2 \r
3 use strict;\r
4 use warnings;\r
5 \r
6 =head1 NAME\r
7 \r
8 Catalyst::Plugin::ConfigLoader::XML - Load XML config files\r
9 \r
10 =head1 DESCRIPTION\r
11 \r
12 Loads XML files. Example:\r
13 \r
14     <config>\r
15         <name>TestApp</name>\r
16         <component name="Controller::Foo">\r
17             <foo>bar</foo>\r
18         </component>\r
19     </config>\r
20 \r
21 =head1 METHODS\r
22 \r
23 =head2 extensions( )\r
24 \r
25 return an array of valid extensions (C<xml>).\r
26 \r
27 =cut\r
28 \r
29 sub extensions {\r
30     return qw( xml );\r
31 }\r
32 \r
33 =head2 load( $file )\r
34 \r
35 Attempts to load C<$file> as an XML file.\r
36 \r
37 =cut\r
38 \r
39 sub load {\r
40     my $class = shift;\r
41     my $file  = shift;\r
42 \r
43     require XML::Simple;\r
44     XML::Simple->import;\r
45     my $config = XMLin( $file, ForceArray => [ 'component' ] );\r
46 \r
47     my $components = delete $config->{ component };\r
48         foreach my $element ( keys %$components ) {\r
49             $config->{ $element } = $components->{ $element };\r
50     }\r
51 \r
52     return $config;\r
53 }\r
54 \r
55 =head1 AUTHOR\r
56 \r
57 =over 4 \r
58 \r
59 =item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>\r
60 \r
61 =back\r
62 \r
63 =head1 COPYRIGHT AND LICENSE\r
64 \r
65 Copyright 2006 by Brian Cassidy\r
66 \r
67 This library is free software; you can redistribute it and/or modify\r
68 it under the same terms as Perl itself. \r
69 \r
70 =head1 SEE ALSO\r
71 \r
72 =over 4 \r
73 \r
74 =item * L<Catalyst>\r
75 \r
76 =item * L<Catalyst::Plugin::ConfigLoader>\r
77 \r
78 =back\r
79 \r
80 =cut\r
81 \r
82 1;