use absolute paths when loading perl files
[p5sagit/Config-Any.git] / lib / Config / Any / Perl.pm
1 package Config::Any::Perl;
2
3 use strict;
4 use warnings;
5
6 use base 'Config::Any::Base';
7 use File::Spec;
8
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;
48
49     my( $exception, $content );
50     {
51         local $@;
52         $content = do File::Spec->rel2abs($file);
53         $exception = $@;
54     }
55     die $exception if $exception;
56
57     return $content;
58 }
59
60 =head1 AUTHOR
61
62 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
63
64 =head1 COPYRIGHT AND LICENSE
65
66 Copyright 2006-2016 by Brian Cassidy
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;