1 package Config::Any::General;
7 use base 'Config::Any::Base';
11 Config::Any::General - Load Config::General files
15 Loads Config::General files. Example:
18 <Component Controller::Foo>
20 bar [ arrayref-value ]
30 return an array of valid extensions (C<cnf>, C<conf>).
35 return qw( cnf conf );
40 Attempts to load C<$file> via Config::General.
47 my $args = shift || {};
49 # work around bug (?) in Config::General
50 # return if $class->_test_perl($file);
52 $args->{ -ConfigFile } = $file;
54 require Config::General;
55 Config::General->VERSION('2.47');
57 $args->{ -ForceArray } = 1 unless exists $args->{ -ForceArray };
59 my $configfile = Config::General->new( %$args );
60 my $config = { $configfile->getall };
65 # this is a bit of a hack but necessary, because Config::General is *far* too lax
66 # about what it will load -- specifically, it seems to be quite happy to load a Perl
67 # config file (ie, a file which is valid Perl and creates a hashref) as if it were
68 # an Apache-style configuration file, presumably due to laziness on the part of the
72 my ( $class, $file ) = @_;
74 eval { $is_perl_src = do "$file"; };
75 delete $INC{ $file }; # so we don't screw stuff later on
76 return defined $is_perl_src;
79 =head2 requires_all_of( )
81 Specifies that this module requires L<Config::General> in order to work.
85 sub requires_all_of { [ 'Config::General' ] }
89 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
93 Joel Bernstein C<< <rataxis@cpan.org> >>
95 =head1 COPYRIGHT AND LICENSE
97 Copyright 2006-2010 by Brian Cassidy
99 Portions Copyright 2006 Portugal Telecom
101 This library is free software; you can redistribute it and/or modify
102 it under the same terms as Perl itself.
110 =item * L<Config::Any>
112 =item * L<Config::General>