Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Config / Any / YAML.pm
CommitLineData
3fea05b9 1package Config::Any::YAML;
2
3use strict;
4use warnings;
5
6use base 'Config::Any::Base';
7
8use Carp ();
9
10=head1 NAME
11
12Config::Any::YAML - Load YAML config files
13
14=head1 DESCRIPTION
15
16Loads YAML files. Example:
17
18 ---
19 name: TestApp
20 Controller::Foo:
21 foo: bar
22 Model::Baz:
23 qux: xyzzy
24
25
26=head1 METHODS
27
28=head2 extensions( )
29
30return an array of valid extensions (C<yml>, C<yaml>).
31
32=cut
33
34sub extensions {
35 return qw( yml yaml );
36}
37
38=head2 load( $file )
39
40Attempts to load C<$file> as a YAML file.
41
42=cut
43
44sub load {
45 my $class = shift;
46 my $file = shift;
47
48 eval { require YAML::XS };
49 unless ( $@ ) {
50 return YAML::XS::LoadFile( $file );
51 }
52
53 Carp::carp
54 'Use of YAML::Syck or YAML to parse config files is DEPRECATED. '
55 . 'Please install YAML::XS for proper YAML support';
56
57 eval { require YAML::Syck; YAML::Syck->VERSION( '0.70' ) };
58 unless ( $@ ) {
59 open( my $fh, $file ) or die $!;
60 my $content = do { local $/; <$fh> };
61 close $fh;
62 return YAML::Syck::Load( $content );
63 }
64
65 require YAML;
66 return YAML::LoadFile( $file );
67}
68
69=head2 requires_any_of( )
70
71Specifies that this modules requires one of L<YAML::XS>, L<YAML::Syck> (0.70) or
72L<YAML> in order to work.
73
74=cut
75
76sub requires_any_of { 'YAML::XS', [ 'YAML::Syck', '0.70' ], 'YAML' }
77
78=head1 AUTHOR
79
80Brian Cassidy E<lt>bricas@cpan.orgE<gt>
81
82=head1 COPYRIGHT AND LICENSE
83
84Copyright 2006-2009 by Brian Cassidy
85
86This library is free software; you can redistribute it and/or modify
87it under the same terms as Perl itself.
88
89=head1 SEE ALSO
90
91=over 4
92
93=item * L<Catalyst>
94
95=item * L<Config::Any>
96
97=item * L<YAML::XS>
98
99=item * L<YAML>
100
101=item * L<YAML::Syck>
102
103=back
104
105=cut
106
1071;