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