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