line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use strict; |
3
|
3
|
|
|
3
|
|
528899
|
use warnings; |
|
3
|
|
|
|
|
47
|
|
|
3
|
|
|
|
|
81
|
|
4
|
3
|
|
|
3
|
|
16
|
use English; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
70
|
|
5
|
3
|
|
|
3
|
|
14
|
use YAML; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
32
|
|
6
|
3
|
|
|
3
|
|
2383
|
use Data::Dumper; |
|
3
|
|
|
|
|
18769
|
|
|
3
|
|
|
|
|
141
|
|
7
|
3
|
|
|
3
|
|
24
|
|
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
123
|
|
8
|
|
|
|
|
|
|
use Moose; |
9
|
3
|
|
|
3
|
|
1590
|
|
|
3
|
|
|
|
|
1212690
|
|
|
3
|
|
|
|
|
22
|
|
10
|
|
|
|
|
|
|
extends 'Connector::Builtin::Memory'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
has '+LOCATION' => ( required => 1 ); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $self = shift; |
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
3
|
|
8
|
# File not exist or not readable |
18
|
|
|
|
|
|
|
my $file = $self->LOCATION(); |
19
|
|
|
|
|
|
|
if ( ! ( ( -e $file ) && ( -r $file ) ) ) { |
20
|
3
|
|
|
|
|
74
|
die 'configuration file '.$file.' not found '; |
21
|
3
|
50
|
33
|
|
|
182
|
} |
22
|
0
|
|
|
|
|
0
|
|
23
|
|
|
|
|
|
|
my $yaml = YAML::LoadFile( $file ); |
24
|
|
|
|
|
|
|
|
25
|
3
|
|
|
|
|
51
|
my $config = $self->makeRefs($yaml); |
26
|
|
|
|
|
|
|
|
27
|
3
|
|
|
|
|
64718
|
return $config; |
28
|
|
|
|
|
|
|
|
29
|
3
|
|
|
|
|
113
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# Traverse the tree read from the YAML file and replace the "@" keys by |
32
|
|
|
|
|
|
|
# scalar references |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my $self = shift; |
36
|
|
|
|
|
|
|
my $config = shift; |
37
|
|
|
|
|
|
|
|
38
|
56
|
|
|
56
|
0
|
65
|
if ( ref($config) eq 'HASH' ) { |
39
|
56
|
|
|
|
|
65
|
my $ret = {}; |
40
|
|
|
|
|
|
|
foreach my $key ( keys %{$config} ) { |
41
|
56
|
100
|
|
|
|
122
|
if ( $key =~ m{ (?: \A @ (.*?) @ \z | \A @ (.*) | (.*?) @ \z ) }xms ) { |
|
|
100
|
|
|
|
|
|
42
|
26
|
|
|
|
|
35
|
my $match = $1 || $2 || $3; |
43
|
26
|
|
|
|
|
30
|
# make it a ref to an anonymous scalar so we know it's a symlink |
|
26
|
|
|
|
|
71
|
|
44
|
60
|
100
|
|
|
|
204
|
$ret->{$match} = \$config->{$key}; |
45
|
11
|
|
33
|
|
|
62
|
} else { |
46
|
|
|
|
|
|
|
$ret->{$key} = $self->makeRefs( $config->{$key} ); |
47
|
11
|
|
|
|
|
44
|
} |
48
|
|
|
|
|
|
|
} |
49
|
49
|
|
|
|
|
103
|
return $ret; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
elsif ( ref($config) eq 'ARRAY' ) { |
52
|
26
|
|
|
|
|
56
|
my $ret = []; |
53
|
|
|
|
|
|
|
my $i = 0; |
54
|
|
|
|
|
|
|
foreach my $entry ( @{$config} ) { |
55
|
1
|
|
|
|
|
1
|
$ret->[ $i++ ] = $self->makeRefs($entry); |
56
|
1
|
|
|
|
|
2
|
} |
57
|
1
|
|
|
|
|
2
|
return $ret; |
|
1
|
|
|
|
|
3
|
|
58
|
4
|
|
|
|
|
7
|
} |
59
|
|
|
|
|
|
|
else { |
60
|
1
|
|
|
|
|
3
|
return $config; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
29
|
|
|
|
|
68
|
|
64
|
|
|
|
|
|
|
1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 Name |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Connector::Multi::YAML |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 Description |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This is a glue connector to create the required reference syntax for |
75
|
|
|
|
|
|
|
Connector::Multi based on a backend configuration handled by YAML. |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
LOCATION is passed over as file to load by YAML. |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Internally, the constructor walks down the whole tree and translates |
80
|
|
|
|
|
|
|
all keys starting or ending with the "@" character into references as |
81
|
|
|
|
|
|
|
understood by Connector::Multi. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 CONFIGURATION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
There is no special configuration besides the mandatory LOCATION property. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 Example |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $backend = Connector::Multi::YAML->new({ |
90
|
|
|
|
|
|
|
LOCATION = /etc/myconfig.yaml |
91
|
|
|
|
|
|
|
}) |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
my $multi = Connector::Multi->new({ |
94
|
|
|
|
|
|
|
BASECONNECTOR => $backend |
95
|
|
|
|
|
|
|
}) |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|