Connector/Tee.pm

filter: Statementstmt 92.1% 70 / 76 Branchbran 78.5% 11 / 14 Conditioncond 80.0% 4 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 100% 9 / 9 Podpod 100% 3 / 3 totaltotal 89.0% 98 / 110 CC 13 SCAR 14.8
CC
13
Cov
89%
get_hash
6.9
get
6.0
get_list
3.0
CRAP 4.4
« Connector/Multi/YAML.pm ↑ Summary Connector/Proxy/JSON.pm »
1 package Connector::Tee;
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 Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 extends 'Connector::Proxy';
10  
11 # Location must not be used
12 1 has '+LOCATION' => ( required => 0, 'isa' => 'Undef' );
13  
14 1 has branches => (
15 is => 'rw',
16 isa => 'ArrayRef',
17 );
18  
19 1 has accept => (
20 is => 'rw',
21 isa => 'Str',
22 default => '',
23 );
24  
25 4 ▶sub get {
Subroutine get: called CC=6 SCAR=17.9
Pod documented
26  
27 4 my $self = shift;
28 4 my $location = shift;
29 4 my @args = @_;
30  
31 4 my $accept = $self->accept();
32 4 $self->log()->trace('initialize tee');
33  
34 4 foreach my $child ( @{$self->branches()} ) {
35  
36 8 $self->log()->debug('query child ' . $child );
37  
38 8 my @prefix = $self->conn()->_build_path([ 'nodes', $child, @{$location}] );
39  
40 8 my $result = $self->conn()->get( \@prefix , \@args );
41  
42 8 ▶ $self->log()->trace('raw result ' . ($result // 'undef'));
Condition100%2/2
$result // "undef"
l!l
71
MC/DC100%1/1
$result // "undef"
$result
Truth table100%2/2
A
A= $result
Aresult
11
00
43  
44 8 ▶ if (!defined $result) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $result) { } 1 7 8
elsif (not $accept) { } 2 5 7
elsif ($result =~ qr/$accept/) { } 2 3 5
45 } elsif (!$accept) {
46 2 return $result;
47 } elsif ($result =~ qr/$accept/) {
48 2 $self->log()->debug('result accepted (scalar)');
49 2 return $result;
50 } else {
51 3 $self->log()->debug('result mismatches pattern (scalar)');
52 3 $self->log()->trace($accept . ' - ' . $result);
53 }
54 }
55  
56 0 return $self->_node_not_exists( $location );
57  
58 }
59  
60 1 ▶sub get_hash {
Subroutine get_hash: called CC=6 SCAR=19.4
Pod documented
61  
62 1 my $self = shift;
63 1 my $location = shift;
64 1 my @args = @_;
65  
66 1 my $accept = $self->accept();
67 1 $self->log()->trace('initialize tee');
68  
69 1 foreach my $child ( @{$self->branches()} ) {
70  
71 2 $self->log()->debug('query child ' . $child );
72  
73 2 my @prefix = $self->conn()->_build_path([ 'nodes', $child, @{$location}] );
74  
75 2 my $result = $self->conn()->get_hash( \@prefix , \@args );
76  
77 2 ▶ $self->log()->trace('raw result ' . ($result // Dumper $result));
Condition66%2/3
$result // Dumper($result)
l!l&&r!l&&!r
110
MC/DC0%0/2
$result // Dumper($result)
$result Dumper($result)
Truth table66%2/3
A // B
A= $resultB= Dumper($result)
ABresult
1X1
011
000
78  
79 2 ▶ if (!defined $result) {
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $result) { } 1 1 2
elsif (not $accept) { } 1 0 1
elsif (keys %{$result;}) { } 0 0 0
80  
81 } elsif (!$accept) {
82 1 return $result;
83 0 } elsif (keys %{$result}) {
84 0 $self->log()->debug('result accepted (hash)');
85 0 return $result;
86 }
87 }
88  
89 0 return $self->_node_not_exists( $location );
90 }
91  
92 1 ▶sub get_list {
Subroutine get_list: called CC=3 SCAR=11.0
Pod documented
93  
94  
95 1 my $self = shift;
96 1 my $location = shift;
97 1 my @args = @_;
98  
99 1 $self->log()->trace('initialize tee');
100  
101 1 foreach my $child ( @{$self->branches()} ) {
102  
103 2 $self->log()->debug('query child ' . $child );
104  
105 2 my @prefix = $self->conn()->_build_path([ 'nodes', $child, @{$location}] );
106  
107 2 my @result = $self->conn()->get_list( \@prefix , \@args );
108  
109 2 $self->log()->trace('raw result ' . (Dumper \@result));
110  
111 2 ▶ if (@result) {
Branch: 1 branch
BranchTrueFalseTotal
if (@result) 1 1 2
112 1 $self->log()->debug('result accepted (list)');
113 1 return @result;
114 }
115 }
116  
117 0 return $self->_node_not_exists( $location );
118  
119 }
120  
121  
122 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
123 1 __PACKAGE__->meta->make_immutable;
124  
125 1 1;
126 __END__
« Connector/Multi/YAML.pm ↑ Summary Connector/Proxy/JSON.pm »