Commit | Line | Data |
---|---|---|
f0e3c221 | 1 | package Config::Any::General; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
dcfb1d1d | 6 | use base 'Config::Any::Base'; |
7 | ||
f0e3c221 | 8 | =head1 NAME |
9 | ||
10 | Config::Any::General - Load Config::General files | |
11 | ||
12 | =head1 DESCRIPTION | |
13 | ||
14 | Loads Config::General files. Example: | |
15 | ||
16 | name = TestApp | |
17 | <Component Controller::Foo> | |
18 | foo bar | |
7adf5673 | 19 | bar [ arrayref-value ] |
f0e3c221 | 20 | </Component> |
21 | <Model Baz> | |
22 | qux xyzzy | |
23 | </Model> | |
24 | ||
25 | =head1 METHODS | |
26 | ||
27 | =head2 extensions( ) | |
28 | ||
29 | return an array of valid extensions (C<cnf>, C<conf>). | |
30 | ||
31 | =cut | |
32 | ||
33 | sub extensions { | |
34 | return qw( cnf conf ); | |
35 | } | |
36 | ||
37 | =head2 load( $file ) | |
38 | ||
39 | Attempts to load C<$file> via Config::General. | |
40 | ||
41 | =cut | |
42 | ||
43 | sub load { | |
44 | my $class = shift; | |
45 | my $file = shift; | |
e0c0c283 | 46 | my $args = shift || {}; |
f0e3c221 | 47 | |
92a04e78 | 48 | $args->{ -ConfigFile } = $file; |
e0c0c283 | 49 | |
e3c5f84b | 50 | require Config::General; |
766100bd | 51 | Config::General->VERSION( '2.47' ); |
82222ecc | 52 | |
7adf5673 | 53 | $args->{ -ForceArray } = 1 unless exists $args->{ -ForceArray }; |
54 | ||
e0c0c283 | 55 | my $configfile = Config::General->new( %$args ); |
f0e3c221 | 56 | my $config = { $configfile->getall }; |
92a04e78 | 57 | |
f0e3c221 | 58 | return $config; |
59 | } | |
60 | ||
dcfb1d1d | 61 | =head2 requires_all_of( ) |
72628dc7 | 62 | |
dcfb1d1d | 63 | Specifies that this module requires L<Config::General> in order to work. |
72628dc7 | 64 | |
65 | =cut | |
66 | ||
82222ecc | 67 | sub requires_all_of { [ 'Config::General' ] } |
72628dc7 | 68 | |
f0e3c221 | 69 | =head1 AUTHOR |
70 | ||
a918b0b8 | 71 | Brian Cassidy E<lt>bricas@cpan.orgE<gt> |
f0e3c221 | 72 | |
73 | =head1 CONTRIBUTORS | |
74 | ||
766100bd | 75 | Joel Bernstein E<lt>rataxis@cpan.orgE<gt> |
f0e3c221 | 76 | |
77 | =head1 COPYRIGHT AND LICENSE | |
78 | ||
f9f3d682 | 79 | Copyright 2006-2015 by Brian Cassidy |
f0e3c221 | 80 | |
81 | Portions Copyright 2006 Portugal Telecom | |
82 | ||
83 | This library is free software; you can redistribute it and/or modify | |
84 | it under the same terms as Perl itself. | |
85 | ||
86 | =head1 SEE ALSO | |
87 | ||
88 | =over 4 | |
89 | ||
90 | =item * L<Catalyst> | |
91 | ||
92 | =item * L<Config::Any> | |
93 | ||
94 | =item * L<Config::General> | |
95 | ||
96 | =back | |
97 | ||
98 | =cut | |
99 | ||
100 | 1; |