1 package Config::Any::General;
6 use base 'Config::Any::Base';
10 Config::Any::General - Load Config::General files
14 Loads Config::General files. Example:
17 <Component Controller::Foo>
19 bar [ arrayref-value ]
29 return an array of valid extensions (C<cnf>, C<conf>).
34 return qw( cnf conf );
39 Attempts to load C<$file> via Config::General.
46 my $args = shift || {};
48 # work around bug (?) in Config::General
49 # return if $class->_test_perl($file);
51 $args->{ -ConfigFile } = $file;
53 $args->{ -ForceArray } = 1 unless exists $args->{ -ForceArray };
55 require Config::General;
56 my $configfile = Config::General->new( %$args );
57 my $config = { $configfile->getall };
62 # this is a bit of a hack but necessary, because Config::General is *far* too lax
63 # about what it will load -- specifically, it seems to be quite happy to load a Perl
64 # config file (ie, a file which is valid Perl and creates a hashref) as if it were
65 # an Apache-style configuration file, presumably due to laziness on the part of the
69 my ( $class, $file ) = @_;
71 eval { $is_perl_src = do "$file"; };
72 delete $INC{ $file }; # so we don't screw stuff later on
73 return defined $is_perl_src;
76 =head2 requires_all_of( )
78 Specifies that this module requires L<Config::General> in order to work.
82 sub requires_all_of { 'Config::General' }
86 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
90 Joel Bernstein C<< <rataxis@cpan.org> >>
92 =head1 COPYRIGHT AND LICENSE
94 Copyright 2006-2010 by Brian Cassidy
96 Portions Copyright 2006 Portugal Telecom
98 This library is free software; you can redistribute it and/or modify
99 it under the same terms as Perl itself.
107 =item * L<Config::Any>
109 =item * L<Config::General>