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