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;
56 croak "Config::General 2.47 or later required"
57 unless Config::General->VERSION('2.47');
59 $args->{ -ForceArray } = 1 unless exists $args->{ -ForceArray };
61 my $configfile = Config::General->new( %$args );
62 my $config = { $configfile->getall };
67 # this is a bit of a hack but necessary, because Config::General is *far* too lax
68 # about what it will load -- specifically, it seems to be quite happy to load a Perl
69 # config file (ie, a file which is valid Perl and creates a hashref) as if it were
70 # an Apache-style configuration file, presumably due to laziness on the part of the
74 my ( $class, $file ) = @_;
76 eval { $is_perl_src = do "$file"; };
77 delete $INC{ $file }; # so we don't screw stuff later on
78 return defined $is_perl_src;
81 =head2 requires_all_of( )
83 Specifies that this module requires L<Config::General> in order to work.
87 sub requires_all_of { [ 'Config::General' ] }
91 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
95 Joel Bernstein C<< <rataxis@cpan.org> >>
97 =head1 COPYRIGHT AND LICENSE
99 Copyright 2006-2010 by Brian Cassidy
101 Portions Copyright 2006 Portugal Telecom
103 This library is free software; you can redistribute it and/or modify
104 it under the same terms as Perl itself.
112 =item * L<Config::Any>
114 =item * L<Config::General>