Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Config / Any / General.pm
CommitLineData
3fea05b9 1package Config::Any::General;
2
3use strict;
4use warnings;
5
6use base 'Config::Any::Base';
7
8=head1 NAME
9
10Config::Any::General - Load Config::General files
11
12=head1 DESCRIPTION
13
14Loads Config::General files. Example:
15
16 name = TestApp
17 <Component Controller::Foo>
18 foo bar
19 </Component>
20 <Model Baz>
21 qux xyzzy
22 </Model>
23
24=head1 METHODS
25
26=head2 extensions( )
27
28return an array of valid extensions (C<cnf>, C<conf>).
29
30=cut
31
32sub extensions {
33 return qw( cnf conf );
34}
35
36=head2 load( $file )
37
38Attempts to load C<$file> via Config::General.
39
40=cut
41
42sub load {
43 my $class = shift;
44 my $file = shift;
45 my $args = shift || {};
46
47 # work around bug (?) in Config::General
48 # return if $class->_test_perl($file);
49
50 $args->{ -ConfigFile } = $file;
51
52 require Config::General;
53 my $configfile = Config::General->new( %$args );
54 my $config = { $configfile->getall };
55
56 return $config;
57}
58
59# this is a bit of a hack but necessary, because Config::General is *far* too lax
60# about what it will load -- specifically, it seems to be quite happy to load a Perl
61# config file (ie, a file which is valid Perl and creates a hashref) as if it were
62# an Apache-style configuration file, presumably due to laziness on the part of the
63# developer.
64
65sub _test_perl {
66 my ( $class, $file ) = @_;
67 my $is_perl_src;
68 eval { $is_perl_src = do "$file"; };
69 delete $INC{ $file }; # so we don't screw stuff later on
70 return defined $is_perl_src;
71}
72
73=head2 requires_all_of( )
74
75Specifies that this module requires L<Config::General> in order to work.
76
77=cut
78
79sub requires_all_of { 'Config::General' }
80
81=head1 AUTHOR
82
83Brian Cassidy E<lt>bricas@cpan.orgE<gt>
84
85=head1 CONTRIBUTORS
86
87Joel Bernstein C<< <rataxis@cpan.org> >>
88
89=head1 COPYRIGHT AND LICENSE
90
91Copyright 2006-2009 by Brian Cassidy
92
93Portions Copyright 2006 Portugal Telecom
94
95This library is free software; you can redistribute it and/or modify
96it under the same terms as Perl itself.
97
98=head1 SEE ALSO
99
100=over 4
101
102=item * L<Catalyst>
103
104=item * L<Config::Any>
105
106=item * L<Config::General>
107
108=back
109
110=cut
111
1121;
113