| 1 | package # Hide from pause | ||||||||||||||||||||||||||||
| 2 | Monitoring::Livestatus::Class::Base::Abstract; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 6 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 6 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 6 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 6 | ▶ | use Monitoring::Livestatus::Class; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 6 | ▶ | my $TRACE = Monitoring::Livestatus::Class->TRACE() || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
'Monitoring::Livestatus::Class'->TRACE || 0
MC/DC0%0/1
'Monitoring::Livestatus::Class'->TRACE || 0
'Monitoring::Livestatus::Class'->TRACE
Truth table50%1/2
A
A= 'Monitoring::Livestatus::Class'->TRACE
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 6 | has 'ctx' => ( | |||||||||||||||||||||||||||
| 12 | is => 'rw', | ||||||||||||||||||||||||||||
| 13 | handles => [qw/table_name backend_obj/], | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | has 'mode' => ( | |||||||||||||||||||||||||||
| 17 | is => 'ro', | ||||||||||||||||||||||||||||
| 18 | isa => 'Str', | ||||||||||||||||||||||||||||
| 19 | builder => 'build_mode', | ||||||||||||||||||||||||||||
| 20 | ); | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub build_mode { die "build_mode must be implemented in " . ref(shift) }; | ||||||||||||||||||||||||||
|
Subroutine
build_mode: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 6 | has 'operators' => ( | |||||||||||||||||||||||||||
| 25 | is => 'ro', | ||||||||||||||||||||||||||||
| 26 | isa => 'ArrayRef', | ||||||||||||||||||||||||||||
| 27 | builder => 'build_operators', | ||||||||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 61 | ▶ | sub build_operators { | ||||||||||||||||||||||||||
|
Subroutine
build_operators: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 31 | return [ | ||||||||||||||||||||||||||||
| 32 | { | ||||||||||||||||||||||||||||
| 33 | 61 | regexp => qr/(and|or)/ix, | |||||||||||||||||||||||||||
| 34 | handler => '_cond_compining', | ||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | ] | ||||||||||||||||||||||||||||
| 37 | }; | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 6 | has 'compining_prefix' => ( | |||||||||||||||||||||||||||
| 40 | is => 'ro', | ||||||||||||||||||||||||||||
| 41 | isa => 'Str', | ||||||||||||||||||||||||||||
| 42 | builder => 'build_compining_prefix', | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 40 | ▶ | sub build_compining_prefix { return ''; }; | ||||||||||||||||||||||||||
|
Subroutine
build_compining_prefix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 31 | ▶ | sub apply { | ||||||||||||||||||||||||||
|
Subroutine
apply: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||
| 50 | 31 | my $self = shift; | |||||||||||||||||||||||||||
| 51 | 31 | my $cond = shift; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 31 | my ( $combining_count, @statments ) = $self->_recurse_cond($cond); | |||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 31 | ▶ | return wantarray ? @statments : \@statments; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 144 | ▶ | sub _recurse_cond { | ||||||||||||||||||||||||||
|
Subroutine
_recurse_cond: called CC=4 SCAR=14.0
| |||||||||||||||||||||||||||||
| 59 | 144 | my $self = shift; | |||||||||||||||||||||||||||
| 60 | 144 | my $cond = shift; | |||||||||||||||||||||||||||
| 61 | 144 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 62 | 144 | ▶ | print STDERR "#IN _recurse_cond $cond $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 144 | my $method = $self->_METHOD_FOR_refkind("_cond",$cond); | |||||||||||||||||||||||||||
| 64 | 144 | my ( $child_combining_count, @statment ) = $self->$method($cond,$combining_count); | |||||||||||||||||||||||||||
| 65 | 144 | $combining_count = $child_combining_count; | |||||||||||||||||||||||||||
| 66 | 144 | ▶ | print STDERR "#OUT _recurse_cond $cond $combining_count ( $method )\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 144 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub _cond_UNDEF { return ( () ); } | ||||||||||||||||||||||||||
|
Subroutine
_cond_UNDEF: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 37 | ▶ | sub _cond_ARRAYREF { | ||||||||||||||||||||||||||
|
Subroutine
_cond_ARRAYREF: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 73 | 37 | my $self = shift; | |||||||||||||||||||||||||||
| 74 | 37 | my $conds = shift; | |||||||||||||||||||||||||||
| 75 | 37 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 76 | 37 | ▶ | print STDERR "#IN _cond_ARRAYREF $conds $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 77 | 37 | my @statment = (); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 37 | my $child_combining_count = 0; | |||||||||||||||||||||||||||
| 80 | 37 | my @child_statment = (); | |||||||||||||||||||||||||||
| 81 | 37 | my @cp_conds = @{ $conds }; # work with a copy | |||||||||||||||||||||||||||
| 82 | 37 | ▶ | while ( my $cond = shift @cp_conds ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | my ( $child_combining_count, @child_statment ) = $self->_dispatch_refkind($cond, { | ||||||||||||||||||||||||||||
| 84 | 3 | ▶ | ARRAYREF => sub { $self->_recurse_cond($cond, $combining_count) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 85 | 13 | ▶ | HASHREF => sub { $self->_recurse_cond($cond, $combining_count) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 86 | 0 | ▶ | UNDEF => sub { croak "not supported : UNDEF in arrayref" }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 87 | 68 | ▶ | SCALAR => sub { $self->_recurse_cond( { $cond => shift(@cp_conds) } , $combining_count ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 88 | 84 | }); | |||||||||||||||||||||||||||
| 89 | 84 | push @statment, @child_statment; | |||||||||||||||||||||||||||
| 90 | 84 | $combining_count = $child_combining_count; | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 37 | ▶ | print STDERR "#OUT _cond_ARRAYREF $conds $combining_count\n" if $TRACE > 9 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | 37 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | 107 | ▶ | sub _cond_HASHREF { | ||||||||||||||||||||||||||
|
Subroutine
_cond_HASHREF: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||
| 97 | 107 | my $self = shift; | |||||||||||||||||||||||||||
| 98 | 107 | my $cond = shift; | |||||||||||||||||||||||||||
| 99 | 107 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 100 | 107 | ▶ | print STDERR "#IN _cond_HASHREF $cond $combining_count\n" if $TRACE > 9 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 107 | my @all_statment = (); | |||||||||||||||||||||||||||
| 102 | 107 | my $child_combining_count = 0; | |||||||||||||||||||||||||||
| 103 | 107 | my @child_statment = (); | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 107 | foreach my $key ( keys %{ $cond } ){ | |||||||||||||||||||||||||||
| 106 | 107 | my $value = $cond->{$key}; | |||||||||||||||||||||||||||
| 107 | 107 | my $method ; | |||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 107 | ▶ | if ( $key =~ /^-/ ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | # Child key for combining filters ( -and / -or ) | ||||||||||||||||||||||||||||
| 111 | 22 | ( $child_combining_count, @child_statment ) = $self->_cond_op_in_hash($key, $value, $combining_count); | |||||||||||||||||||||||||||
| 112 | 22 | $combining_count = $child_combining_count; | |||||||||||||||||||||||||||
| 113 | } else{ | ||||||||||||||||||||||||||||
| 114 | 85 | $method = $self->_METHOD_FOR_refkind("_cond_hashpair",$value); | |||||||||||||||||||||||||||
| 115 | 85 | ( $child_combining_count, @child_statment ) = $self->$method($key, $value, undef ,$combining_count); | |||||||||||||||||||||||||||
| 116 | 85 | $combining_count = $child_combining_count; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 107 | push @all_statment, @child_statment; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | 107 | ▶ | print STDERR "#OUT _cond_HASHREF $cond $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 107 | return ( $combining_count, @all_statment ); | |||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | 2 | ▶ | sub _cond_hashpair_UNDEF { | ||||||||||||||||||||||||||
|
Subroutine
_cond_hashpair_UNDEF: called CC=5 SCAR=16.7
| |||||||||||||||||||||||||||||
| 126 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 127 | 2 | ▶ | my $key = shift || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 128 | 2 | my $value = shift; | |||||||||||||||||||||||||||
| 129 | 2 | ▶ | my $operator = shift || '='; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || '='
MC/DC0%0/1
shift() || '='
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 130 | 2 | ▶ | print STDERR "# _cond_hashpair_UNDEF\n" if $TRACE > 9 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 2 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 133 | 2 | my @statment = ( | |||||||||||||||||||||||||||
| 134 | sprintf("%s: %s %s",$self->mode,$key,$operator) | ||||||||||||||||||||||||||||
| 135 | ); | ||||||||||||||||||||||||||||
| 136 | 2 | $combining_count++; | |||||||||||||||||||||||||||
| 137 | 2 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 138 | }; | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 55 | ▶ | sub _cond_hashpair_SCALAR { | ||||||||||||||||||||||||||
|
Subroutine
_cond_hashpair_SCALAR: called CC=5 SCAR=16.2
| |||||||||||||||||||||||||||||
| 141 | 55 | my $self = shift; | |||||||||||||||||||||||||||
| 142 | 55 | ▶ | my $key = shift || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 143 | 55 | my $value = shift; | |||||||||||||||||||||||||||
| 144 | 55 | ▶ | my $operator = shift || '='; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || '='
MC/DC100%1/1
shift() || '='
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 145 | 55 | ▶ | print STDERR "# _cond_hashpair_SCALAR\n" if $TRACE > 9 ; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | 55 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 148 | 55 | my @statment = ( | |||||||||||||||||||||||||||
| 149 | sprintf("%s: %s %s %s",$self->mode,$key,$operator,$value) | ||||||||||||||||||||||||||||
| 150 | ); | ||||||||||||||||||||||||||||
| 151 | 55 | $combining_count++; | |||||||||||||||||||||||||||
| 152 | 55 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 153 | }; | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 19 | ▶ | sub _cond_hashpair_ARRAYREF { | ||||||||||||||||||||||||||
|
Subroutine
_cond_hashpair_ARRAYREF: called CC=8 SCAR=21.1
| |||||||||||||||||||||||||||||
| 156 | 19 | my $self = shift; | |||||||||||||||||||||||||||
| 157 | 19 | ▶ | my $key = shift || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 158 | 19 | ▶ | my $values = shift || []; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || []
MC/DC0%0/1
shift() || []
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 159 | 19 | ▶ | my $operator = shift || '='; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || '='
MC/DC100%1/1
shift() || '='
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 160 | 19 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 161 | 19 | ▶ | print STDERR "#IN _cond_hashpair_ARRAYREF $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 19 | my @statment = (); | |||||||||||||||||||||||||||
| 164 | 19 | foreach my $value ( @{ $values }){ | |||||||||||||||||||||||||||
| 165 | 40 | push @statment, sprintf("%s: %s %s %s",$self->mode,$key,$operator,$value); | |||||||||||||||||||||||||||
| 166 | 40 | $combining_count++; | |||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||
| 168 | 19 | ▶ | print STDERR "#OUT _cond_hashpair_ARRAYREF $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 19 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 37 | ▶ | sub _cond_hashpair_HASHREF { | ||||||||||||||||||||||||||
|
Subroutine
_cond_hashpair_HASHREF: called CC=10 SCAR=24.5
| |||||||||||||||||||||||||||||
| 173 | 37 | my $self = shift; | |||||||||||||||||||||||||||
| 174 | 37 | ▶ | my $key = shift || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 175 | 37 | ▶ | my $values = shift || {}; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 176 | 37 | ▶ | my $combining = shift || undef; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || undef
MC/DC0%0/1
shift() || undef
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 177 | 37 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||
| 179 | 37 | ▶ | print STDERR "#IN Abstract::_cond_hashpair_HASHREF $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 180 | 37 | my @statment = (); | |||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | 37 | foreach my $child_key ( keys %{ $values } ){ | |||||||||||||||||||||||||||
| 183 | 37 | my $child_value = $values->{ $child_key }; | |||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||
| 185 | 37 | ▶ | if ( $child_key =~ /^-/ ){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 186 | 9 | my ( $child_combining_count, @child_statment ) = $self->_cond_op_in_hash($child_key, { $key => $child_value } , 0); | |||||||||||||||||||||||||||
| 187 | 9 | $combining_count += $child_combining_count; | |||||||||||||||||||||||||||
| 188 | 9 | push @statment, @child_statment; | |||||||||||||||||||||||||||
| 189 | } elsif ( $child_key =~ /^[!<>=~]/ ){ | ||||||||||||||||||||||||||||
| 190 | # Child key is a operator like: | ||||||||||||||||||||||||||||
| 191 | # = equality | ||||||||||||||||||||||||||||
| 192 | # ~ match regular expression (substring match) | ||||||||||||||||||||||||||||
| 193 | # =~ equality ignoring case | ||||||||||||||||||||||||||||
| 194 | # ~~ regular expression ignoring case | ||||||||||||||||||||||||||||
| 195 | # < less than | ||||||||||||||||||||||||||||
| 196 | # > greater than | ||||||||||||||||||||||||||||
| 197 | # <= less or equal | ||||||||||||||||||||||||||||
| 198 | # >= greater or equal | ||||||||||||||||||||||||||||
| 199 | 28 | my $method = $self->_METHOD_FOR_refkind("_cond_hashpair",$child_value); | |||||||||||||||||||||||||||
| 200 | 28 | my ( $child_combining_count, @child_statment ) = $self->$method($key, $child_value,$child_key); | |||||||||||||||||||||||||||
| 201 | 28 | $combining_count += $child_combining_count; | |||||||||||||||||||||||||||
| 202 | 28 | push @statment, @child_statment; | |||||||||||||||||||||||||||
| 203 | } else { | ||||||||||||||||||||||||||||
| 204 | 0 | my $method = $self->_METHOD_FOR_refkind("_cond_hashpair",$child_value); | |||||||||||||||||||||||||||
| 205 | 0 | my ( $child_combining_count, @child_statment ) = $self->$method($key, $child_value); | |||||||||||||||||||||||||||
| 206 | 0 | $combining_count += $child_combining_count; | |||||||||||||||||||||||||||
| 207 | 0 | push @statment, @child_statment; | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | 37 | ▶ | print STDERR "#OUT Abstract::_cond_hashpair_HASHREF $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 211 | 37 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | 31 | ▶ | sub _cond_op_in_hash { | ||||||||||||||||||||||||||
|
Subroutine
_cond_op_in_hash: called CC=8 SCAR=24.8
| |||||||||||||||||||||||||||||
| 215 | 31 | my $self = shift; | |||||||||||||||||||||||||||
| 216 | 31 | my $operator = shift; | |||||||||||||||||||||||||||
| 217 | 31 | my $value = shift; | |||||||||||||||||||||||||||
| 218 | 31 | my $combining_count = shift; | |||||||||||||||||||||||||||
| 219 | 31 | ▶ | print STDERR "#IN _cond_op_in_hash $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | 31 | ▶ | if ( defined $operator and $operator =~ /^-/ ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $operator and $operator =~ /^-/
MC/DC0%0/2
defined $operator and $operator =~ /^-/
defined $operator
$operator =~ /^-/
Truth table33%1/3
A and B
A= defined $operatorB= $operator =~ /^-/
| |||||||||||||||||||||||||||||
| 222 | 31 | $operator =~ s/^-//; # remove - | |||||||||||||||||||||||||||
| 223 | 31 | $operator =~ s/^\s+|\s+$//g; # remove leading/trailing space | |||||||||||||||||||||||||||
| 224 | 31 | ▶ | $operator = 'GroupBy' if ( $operator eq 'Groupby' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 31 | ▶ | my $operator_config = first { $operator =~ $_->{regexp} } @{ $self->operators }; | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 228 | 31 | my $operator_handler = $operator_config->{handler}; | |||||||||||||||||||||||||||
| 229 | 31 | ▶ | if ( not ref $operator_handler ){ | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 230 | 31 | return $self->$operator_handler($operator,$value,$combining_count); | |||||||||||||||||||||||||||
| 231 | }elsif ( ref $operator_handler eq 'CODE' ) { | ||||||||||||||||||||||||||||
| 232 | 0 | return $operator_handler->($self,$operator,$value,$combining_count); | |||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | print STDERR "#OUT _cond_op_in_hash $operator $value $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 236 | 0 | return ( 0, () ); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | 21 | ▶ | sub _cond_compining { | ||||||||||||||||||||||||||
|
Subroutine
_cond_compining: called CC=7 SCAR=21.2
| |||||||||||||||||||||||||||||
| 239 | 21 | my $self = shift; | |||||||||||||||||||||||||||
| 240 | 21 | my $combining = shift; | |||||||||||||||||||||||||||
| 241 | 21 | my $value = shift; | |||||||||||||||||||||||||||
| 242 | 21 | ▶ | my $combining_count = shift || 0; | ||||||||||||||||||||||||||
|
Condition100%2/2
shift() || 0
MC/DC100%1/1
shift() || 0
shift()
Truth table100%2/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 243 | 21 | ▶ | print STDERR "#IN _cond_compining $combining $combining_count\n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 244 | 21 | $combining_count++; | |||||||||||||||||||||||||||
| 245 | 21 | my @statment = (); | |||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 21 | ▶ | if ( defined $combining and $combining =~ /^-/ ){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $combining and $combining =~ /^-/
MC/DC0%0/2
defined $combining and $combining =~ /^-/
defined $combining
$combining =~ /^-/
Truth table33%1/3
A and B
A= defined $combiningB= $combining =~ /^-/
| |||||||||||||||||||||||||||||
| 248 | 0 | $combining =~ s/^-//; # remove - | |||||||||||||||||||||||||||
| 249 | 0 | $combining =~ s/^\s+|\s+$//g; # remove leading/trailing space | |||||||||||||||||||||||||||
| 250 | 0 | $combining = ucfirst( $combining ); | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | 21 | my ( $child_combining_count, @child_statment )= $self->_recurse_cond($value, 0 ); | |||||||||||||||||||||||||||
| 253 | 21 | push @statment, @child_statment; | |||||||||||||||||||||||||||
| 254 | 21 | ▶ | if ( defined $combining ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 255 | 21 | push @statment, sprintf("%s%s: %d", | |||||||||||||||||||||||||||
| 256 | $self->compining_prefix, | ||||||||||||||||||||||||||||
| 257 | ucfirst( $combining ), | ||||||||||||||||||||||||||||
| 258 | $child_combining_count, | ||||||||||||||||||||||||||||
| 259 | ); | ||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 21 | ▶ | print STDERR "#OUT _cond_compining $combining $combining_count \n" if $TRACE > 9; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 262 | 21 | return ( $combining_count, @statment ); | |||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 351 | ▶ | sub _refkind { | ||||||||||||||||||||||||||
|
Subroutine
_refkind: called CC=6 SCAR=18.3
| |||||||||||||||||||||||||||||
| 266 | 351 | my ($self, $data) = @_; | |||||||||||||||||||||||||||
| 267 | 351 | my $suffix = ''; | |||||||||||||||||||||||||||
| 268 | 351 | my $ref; | |||||||||||||||||||||||||||
| 269 | 351 | my $n_steps = 0; | |||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 351 | while (1) { | |||||||||||||||||||||||||||
| 272 | # blessed objects are treated like scalars | ||||||||||||||||||||||||||||
| 273 | 351 | ▶ | $ref = (blessed $data) ? '' : ref $data; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 274 | 351 | ▶ | $n_steps += 1 if $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 275 | 351 | ▶ | last if $ref ne 'REF'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 276 | 0 | $data = $$data; | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 351 | ▶ | my $base = $ref || (defined $data ? 'SCALAR' : 'UNDEF'); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ref || (defined $data ? 'SCALAR' : 'UNDEF')
MC/DC0%0/2
$ref || (defined $data ? 'SCALAR' : 'UNDEF')
$ref
(defined $data ? 'SCALAR' : 'UNDEF')
Truth table66%2/3
A || B
A= $refB= (defined $data ? 'SCALAR' : 'UNDEF')
| |||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 351 | return $base . ('REF' x $n_steps); | |||||||||||||||||||||||||||
| 283 | } | ||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||
| 285 | 94 | ▶ | sub _dispatch_refkind { | ||||||||||||||||||||||||||
|
Subroutine
_dispatch_refkind: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 286 | 94 | my $self = shift; | |||||||||||||||||||||||||||
| 287 | 94 | my $value = shift; | |||||||||||||||||||||||||||
| 288 | 94 | my $dispatch_table = shift; | |||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | 94 | my $type = $self->_refkind($value); | |||||||||||||||||||||||||||
| 291 | 94 | my $coderef = $dispatch_table->{$type}; | |||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | 94 | ▶ | die sprintf("No coderef for %s ( %s ) found!",$value, $type) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | unless ( ref $coderef eq 'CODE' ); | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 94 | return $coderef->(); | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 257 | ▶ | sub _METHOD_FOR_refkind { | ||||||||||||||||||||||||||
|
Subroutine
_METHOD_FOR_refkind: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||
| 300 | 257 | my $self = shift; | |||||||||||||||||||||||||||
| 301 | 257 | ▶ | my $prefix = shift || ''; | ||||||||||||||||||||||||||
|
Condition50%1/2
shift() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 302 | 257 | my $value = shift; | |||||||||||||||||||||||||||
| 303 | 257 | my $type = $self->_refkind( $value ); | |||||||||||||||||||||||||||
| 304 | 257 | my $method = sprintf("%s_%s",$prefix,$type); | |||||||||||||||||||||||||||
| 305 | 257 | return $method; | |||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | 6 | 1; | |||||||||||||||||||||||||||
| 311 | __END__ | ||||||||||||||||||||||||||||