line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Config::Any::XML; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
2898
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
140
|
|
4
|
6
|
|
|
6
|
|
26
|
use warnings; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
129
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
27
|
use base 'Config::Any::Base'; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
1370
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Config::Any::XML - Load XML config files |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 DESCRIPTION |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
Loads XML files. Example: |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
TestApp |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
bar |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
xyzzy |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 METHODS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 extensions( ) |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
return an array of valid extensions (C). |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub extensions { |
35
|
10
|
|
|
10
|
1
|
27
|
return qw( xml ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head2 load( $file ) |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Attempts to load C<$file> as an XML file. |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub load { |
45
|
0
|
|
|
0
|
1
|
0
|
my $class = shift; |
46
|
0
|
|
|
|
|
0
|
my $file = shift; |
47
|
0
|
|
0
|
|
|
0
|
my $args = shift || {}; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
require XML::Simple; |
50
|
0
|
|
|
|
|
0
|
my $config = XML::Simple::XMLin( |
51
|
|
|
|
|
|
|
$file, |
52
|
|
|
|
|
|
|
ForceArray => [ qw( component model view controller ) ], |
53
|
|
|
|
|
|
|
%$args |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
0
|
return $class->_coerce( $config ); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _coerce { |
60
|
|
|
|
|
|
|
# coerce the XML-parsed config into the correct format |
61
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
62
|
0
|
|
|
|
|
0
|
my $config = shift; |
63
|
0
|
|
|
|
|
0
|
my $out; |
64
|
0
|
|
|
|
|
0
|
for my $k ( keys %$config ) { |
65
|
0
|
|
|
|
|
0
|
my $ref = $config->{ $k }; |
66
|
0
|
0
|
|
|
|
0
|
my $name = ref $ref eq 'HASH' ? delete $ref->{ name } : undef; |
67
|
0
|
0
|
|
|
|
0
|
if ( defined $name ) { |
68
|
0
|
|
|
|
|
0
|
$out->{ $k }->{ $name } = $ref; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
else { |
71
|
0
|
|
|
|
|
0
|
$out->{ $k } = $ref; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
0
|
|
|
|
|
0
|
$out; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head2 requires_all_of( ) |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Specifies that this module requires L and L |
80
|
|
|
|
|
|
|
in order to work. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
2
|
|
|
2
|
1
|
35
|
sub requires_all_of { 'XML::Simple', 'XML::NamespaceSupport' } |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 CAVEATS |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 Strict Mode |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
If, by some chance, L has already been loaded with the strict |
91
|
|
|
|
|
|
|
flag turned on, then you will likely get errors as warnings will become |
92
|
|
|
|
|
|
|
fatal exceptions and certain arguments to XMLin() will no longer be optional. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
See L for |
95
|
|
|
|
|
|
|
more information. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHORS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Brian Cassidy |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Joel Bernstein |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2006-2016 by Brian Cassidy |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
108
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SEE ALSO |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=over 4 |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item * L |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * L |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item * L |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=cut |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
1; |