1 package Config::Any::YAML;
6 use base 'Config::Any::Base';
12 Config::Any::YAML - Load YAML config files
16 Loads YAML files. Example:
30 return an array of valid extensions (C<yml>, C<yaml>).
35 return qw( yml yaml );
40 Attempts to load C<$file> as a YAML file.
44 our $NO_YAML_XS_WARNING;
50 eval { require YAML::XS };
52 return YAML::XS::LoadFile( $file );
56 'Use of YAML::Syck or YAML to parse config files is DEPRECATED. '
57 . 'Please install YAML::XS for proper YAML support'
58 unless $NO_YAML_XS_WARNING;
60 eval { require YAML::Syck; YAML::Syck->VERSION( '0.70' ) };
62 open( my $fh, $file ) or die $!;
63 my $content = do { local $/; <$fh> };
65 return YAML::Syck::Load( $content );
69 return YAML::LoadFile( $file );
72 =head2 requires_any_of( )
74 Specifies that this modules requires one of L<YAML::XS>, L<YAML::Syck> (0.70) or
75 L<YAML> in order to work.
79 sub requires_any_of { 'YAML::XS', [ 'YAML::Syck', '0.70' ], 'YAML' }
83 Brian Cassidy E<lt>bricas@cpan.orgE<gt>
85 =head1 COPYRIGHT AND LICENSE
87 Copyright 2006-2011 by Brian Cassidy
89 This library is free software; you can redistribute it and/or modify
90 it under the same terms as Perl itself.
98 =item * L<Config::Any>
104 =item * L<YAML::Syck>