Commit | Line | Data |
---|---|---|
f0e3c221 | 1 | package Config::Any::Perl; |
2 | ||
3 | use strict; | |
4 | use warnings; | |
5 | ||
83020fbd | 6 | my %cache; |
7 | ||
f0e3c221 | 8 | =head1 NAME |
9 | ||
10 | Config::Any::Perl - Load Perl config files | |
11 | ||
12 | =head1 DESCRIPTION | |
13 | ||
14 | Loads Perl files. Example: | |
15 | ||
16 | { | |
17 | name => 'TestApp', | |
18 | 'Controller::Foo' => { | |
19 | foo => 'bar' | |
20 | }, | |
21 | 'Model::Baz' => { | |
22 | qux => 'xyzzy' | |
23 | } | |
24 | } | |
25 | ||
26 | =head1 METHODS | |
27 | ||
28 | =head2 extensions( ) | |
29 | ||
30 | return an array of valid extensions (C<pl>, C<perl>). | |
31 | ||
32 | =cut | |
33 | ||
34 | sub extensions { | |
35 | return qw( pl perl ); | |
36 | } | |
37 | ||
38 | =head2 load( $file ) | |
39 | ||
40 | Attempts to load C<$file> as a Perl file. | |
41 | ||
42 | =cut | |
43 | ||
44 | sub load { | |
45 | my $class = shift; | |
46 | my $file = shift; | |
83020fbd | 47 | my $content; |
48 | ||
92a04e78 | 49 | unless ( $content = $cache{ $file } ) { |
8af0a7cf | 50 | $content = require $file; |
83020fbd | 51 | $cache{ $file } = $content; |
52 | } | |
53 | ||
54 | return $content; | |
f0e3c221 | 55 | } |
56 | ||
72628dc7 | 57 | =head2 is_supported( ) |
58 | ||
59 | Returns true. | |
60 | ||
61 | =cut | |
62 | ||
63 | sub is_supported { | |
64 | return 1; | |
65 | } | |
66 | ||
f0e3c221 | 67 | =head1 AUTHOR |
68 | ||
a918b0b8 | 69 | Brian Cassidy E<lt>bricas@cpan.orgE<gt> |
f0e3c221 | 70 | |
71 | =head1 COPYRIGHT AND LICENSE | |
72 | ||
a918b0b8 | 73 | Copyright 2007 by Brian Cassidy |
f0e3c221 | 74 | |
75 | This library is free software; you can redistribute it and/or modify | |
76 | it under the same terms as Perl itself. | |
77 | ||
78 | =head1 SEE ALSO | |
79 | ||
80 | =over 4 | |
81 | ||
82 | =item * L<Catalyst> | |
83 | ||
84 | =item * L<Config::Any> | |
85 | ||
86 | =back | |
87 | ||
88 | =cut | |
89 | ||
90 | 1; |