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