ensure require() happens against plugin specified in force_plugins
[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' ) };
92a04e78 47 if ( $@ ) {
f0e3c221 48 require YAML;
49 return YAML::LoadFile( $file );
50 }
51 else {
52 open( my $fh, $file ) or die $!;
53 my $content = do { local $/; <$fh> };
54 close $fh;
55 return YAML::Syck::Load( $content );
56 }
57}
58
dcfb1d1d 59=head2 requires_any_of( )
72628dc7 60
dcfb1d1d 61Specifies that this modules requires one of L<YAML::Syck> (0.70) or L<YAML> in
62order to work.
72628dc7 63
64=cut
65
dcfb1d1d 66sub requires_any_of { [ 'YAML::Syck', '0.70' ], 'YAML' }
72628dc7 67
f0e3c221 68=head1 AUTHOR
69
a918b0b8 70Brian Cassidy E<lt>bricas@cpan.orgE<gt>
f0e3c221 71
72=head1 COPYRIGHT AND LICENSE
73
a918b0b8 74Copyright 2007 by Brian Cassidy
f0e3c221 75
76This library is free software; you can redistribute it and/or modify
77it under the same terms as Perl itself.
78
79=head1 SEE ALSO
80
81=over 4
82
83=item * L<Catalyst>
84
85=item * L<Config::Any>
86
87=item * L<YAML>
88
89=item * L<YAML::Syck>
90
91=back
92
93=cut
94
951;