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