Connector/Multi/Merge.pm

filter: Statementstmt 86.3% 38 / 44 Branchbran 83.3% 5 / 6 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 77.9% 53 / 68 CC 8 SCAR 18.6
CC
8
Cov
80%
cm2tree
11.2
BEGIN
1.0
BEGIN
1.0
CRAP 6.4
« Connector/Builtin/Authentication/Password.pm ↑ Summary Connector/Proxy/DBI.pm »
1 package Connector::Multi::Merge;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use English;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Config::Merge;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 extends 'Connector::Builtin::Memory';
12  
13 1 has '+LOCATION' => ( required => 1 );
14  
15 1 ▶sub _build_config {
Subroutine _build_config: called CC=1 SCAR=0.0
16  
17 1 my $self = shift;
18  
19 # Skip the workflow directories
20 1 my $cm = Config::Merge->new( $self->LOCATION() );
21 1 my $cmref = $cm->();
22 1 my $tree = $self->cm2tree($cmref);
23  
24 1 return $tree;
25  
26 }
27  
28 # Traverse the tree read from Config::Merge and replace the "@" keys by
29 # scalar references
30  
31 8 ▶sub cm2tree {
Subroutine cm2tree: called CC=8 SCAR=24.1
Pod undocumented
32 8 my $self = shift;
33 8 my $cm = shift;
34  
35 8 ▶ if ( ref($cm) eq 'HASH' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $cm eq 'HASH') { } 6 2 8
elsif (ref $cm eq 'ARRAY') { } 0 2 2
36 6 my $ret = {};
37 6 foreach my $key ( keys %{$cm} ) {
38 8 ▶ if ( $key =~ m{ (?: \A @ (.*?) @ \z | \A @ (.*) | (.*?) @ \z ) }xms ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($key =~ / (?: \A @ (.*?) @ \z | \A @ (.*) | (.*?) @ \z ) /msx) { } 1 7 8
39 1 ▶ my $match = $1 || $2 || $3;
Condition33%2/6
$1 || $2 || $3
l!l&&r!l&&!r
010
$1 or $2
l!l&&r!l&&!r
001
MC/DC0%0/3
$1 || $2 || $3
$1 $2 $3
Truth table25%1/4
A or B || C
A= $1B= $2C= $3
ABCresult
1XX1
01X1
0011
0000
40 # make it a ref to an anonymous scalar so we know it's a symlink
41 1 $ret->{$match} = \$cm->{$key};
42 } else {
43 7 $ret->{$key} = $self->cm2tree( $cm->{$key} )
44 }
45 }
46 6 return $ret;
47 }
48 elsif ( ref($cm) eq 'ARRAY' ) {
49 0 my $ret = [];
50 0 my $i = 0;
51 0 foreach my $entry ( @{$cm} ) {
52 0 $ret->[ $i++ ] = $self->cm2tree($entry);
53 }
54 0 return $ret;
55 }
56 else {
57 2 return $cm;
58 }
59 }
60  
61 1 1;
62  
63 __DATA__
« Connector/Builtin/Authentication/Password.pm ↑ Summary Connector/Proxy/DBI.pm »