Add repository resource to all the MI Makefile.PLs
[p5sagit/Config-Any.git] / lib / Config / Any / YAML.pm
CommitLineData
f0e3c221 1package Config::Any::YAML;
2
3use strict;
4use warnings;
5
dcfb1d1d 6use base 'Config::Any::Base';
7
f0e3c221 8=head1 NAME
9
10Config::Any::YAML - Load YAML config files
11
12=head1 DESCRIPTION
13
14Loads YAML files. Example:
15
16 ---
17 name: TestApp
18 Controller::Foo:
19 foo: bar
20 Model::Baz:
21 qux: xyzzy
22
23
24=head1 METHODS
25
26=head2 extensions( )
27
28return an array of valid extensions (C<yml>, C<yaml>).
29
30=cut
31
32sub extensions {
33 return qw( yml yaml );
34}
35
36=head2 load( $file )
37
38Attempts to load C<$file> as a YAML file.
39
40=cut
41
42sub load {
43 my $class = shift;
44 my $file = shift;
45
48e4a267 46 eval { require YAML::Syck; YAML::Syck->VERSION( '0.70' ) };
d49610ab 47 unless ( $@ ) {
f0e3c221 48 open( my $fh, $file ) or die $!;
49 my $content = do { local $/; <$fh> };
50 close $fh;
51 return YAML::Syck::Load( $content );
52 }
d49610ab 53
54 require YAML;
55 return YAML::LoadFile( $file );
f0e3c221 56}
57
dcfb1d1d 58=head2 requires_any_of( )
72628dc7 59
dcfb1d1d 60Specifies that this modules requires one of L<YAML::Syck> (0.70) or L<YAML> in
61order to work.
72628dc7 62
63=cut
64
dcfb1d1d 65sub requires_any_of { [ 'YAML::Syck', '0.70' ], 'YAML' }
72628dc7 66
f0e3c221 67=head1 AUTHOR
68
a918b0b8 69Brian Cassidy E<lt>bricas@cpan.orgE<gt>
f0e3c221 70
71=head1 COPYRIGHT AND LICENSE
72
a918b0b8 73Copyright 2007 by Brian Cassidy
f0e3c221 74
75This library is free software; you can redistribute it and/or modify
76it 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=item * L<YAML>
87
88=item * L<YAML::Syck>
89
90=back
91
92=cut
93
941;