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