| 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"
MC/DC100%1/1
$result // "undef"
$result
Truth table100%2/2
A
A= $result
| |||||||||||||||||||||
| 43 | |||||||||||||||||||||
| 44 | 8 | ▶ | if (!defined $result) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 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)
MC/DC0%0/2
$result // Dumper($result)
$result
Dumper($result)
Truth table66%2/3
A // B
A= $resultB= Dumper($result)
| |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | 2 | ▶ | if (!defined $result) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||