| 1 | package Net::Hadoop::YARN::Roles::JMX; | ||||||||||||||||||||||||||||
| 2 | 1 | $Net::Hadoop::YARN::Roles::JMX::VERSION = '0.203'; | |||||||||||||||||||||||||||
| 3 | 1 | ▶ | use 5.10.0; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use Carp qw( confess ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Clone qw( clone ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Constant::FromGlobal DEBUG => { int => 1, default => 0, env => 1 }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use JSON::XS (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use Ref::Util qw( | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | is_arrayref | ||||||||||||||||||||||||||||
| 14 | is_coderef | ||||||||||||||||||||||||||||
| 15 | is_hashref | ||||||||||||||||||||||||||||
| 16 | is_ref | ||||||||||||||||||||||||||||
| 17 | 1 | ); | |||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Time::HiRes qw( time ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | has 'target_host_port' => ( | ||||||||||||||||||||||||||||
| 22 | is => 'rw', | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 25 | 0 | return join q{:}, $self->target_host, $self->target_port; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | 1 | ); | |||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | has 'target_host' => ( | ||||||||||||||||||||||||||||
| 30 | is => 'rw', | ||||||||||||||||||||||||||||
| 31 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 32 | 0 | confess "target_host is not defined"; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | 1 | ); | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | has 'target_port' => ( | ||||||||||||||||||||||||||||
| 37 | is => 'rw', | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 39 | 0 | confess "target_port is not defined"; | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | 1 | ); | |||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | has stats => ( | ||||||||||||||||||||||||||||
| 44 | is => 'rw', | ||||||||||||||||||||||||||||
| 45 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 46 | 0 | shift->all_available_stats; | |||||||||||||||||||||||||||
| 47 | }, | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | isa => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 49 | 0 | my $thing = shift; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ( ref $thing ne 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | confess "$thing must be an ARRAY"; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | # TODO: verify somehow | ||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||
| 55 | 1 | lazy => 1, | |||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | has flat => ( | ||||||||||||||||||||||||||||
| 59 | is => 'rw', | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 61 | 1 | lazy => 1, | |||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | has decode_json_substrings => ( | ||||||||||||||||||||||||||||
| 65 | is => 'rw', | ||||||||||||||||||||||||||||
| 66 | 0 | ▶ | default => sub { 0 }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 67 | 1 | lazy => 1, | |||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub all_available_stats { | ||||||||||||||||||||||||||
|
Subroutine
all_available_stats: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 71 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 72 | 0 | my $c = $self->clone; | |||||||||||||||||||||||||||
| 73 | 0 | $c->stats( ['all'] ); | |||||||||||||||||||||||||||
| 74 | 0 | $c->decode_json_substrings( 0 ); | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | 0 | my @names; | |||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | $c->_looper( | ||||||||||||||||||||||||||||
| 79 | $c->collect, | ||||||||||||||||||||||||||||
| 80 | 0 | ▶ | sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 81 | 0 | my($thing, $name_or_index, $is_hash) = @_; | |||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ( $is_hash && $name_or_index eq 'ObjectName' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$is_hash and $name_or_index eq "ObjectName"
MC/DC0%0/2
$is_hash and $name_or_index eq "ObjectName"
$is_hash
$name_or_index eq "ObjectName"
Truth table0%0/3
A and B
A= $is_hashB= $name_or_index eq "ObjectName"
| |||||||||||||||||||||||||||||
| 83 | 0 | push @names, $thing->{$name_or_index}; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | }, | ||||||||||||||||||||||||||||
| 86 | 0 | ); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | ▶ | if ( ! @names ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | confess "Failed to collect the avaialble stat names!"; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | return [ @names ]; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 0 | ▶ | sub collect { | ||||||||||||||||||||||||||
|
Subroutine
collect: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||
| 96 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 97 | 0 | my $user_defined_stats = shift; | |||||||||||||||||||||||||||
| 98 | 0 | my $host_port = $self->target_host_port; | |||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | my @stats = is_arrayref $user_defined_stats | ||||||||||||||||||||||||||||
| 101 | 0 | ? @{ $user_defined_stats } | |||||||||||||||||||||||||||
| 102 | 0 | ▶ | : @{ $self->stats } | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | ; | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 0 | my $has_all = grep { $_ eq 'all'} @stats; | |||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | 0 | ▶ | @stats = qw( all ) if $has_all; # ignore the rest, if any | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $uri_tmpl = $has_all ? 'http://%s/jmx' : 'http://%s/jmx?qry=%s'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 110 | 0 | my $is_flat = $self->flat; | |||||||||||||||||||||||||||
| 111 | 0 | my %rv; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 0 | STATS: foreach my $stat ( @stats ) { | |||||||||||||||||||||||||||
| 114 | 0 | ▶ | my $uri = sprintf $uri_tmpl, $host_port, ( $has_all ? () : ( $stat ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | 0 | my $resp; | |||||||||||||||||||||||||||
| 116 | eval { | ||||||||||||||||||||||||||||
| 117 | 0 | my $start = time; | |||||||||||||||||||||||||||
| 118 | 0 | ▶ | $resp = $self->agent_request( $uri ) || next STATS; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->agent_request($uri) || (next STATS)
MC/DC0%0/1
$self->agent_request($uri) || (next STATS)
$self->agent_request($uri)
Truth table0%0/2
A
A= $self->agent_request($uri)
| |||||||||||||||||||||||||||||
| 119 | 0 | DEBUG && sprintf "[ %s REST ] Took %.2f seconds\n", ref $self, time - $start; | |||||||||||||||||||||||||||
| 120 | 0 | 1; | |||||||||||||||||||||||||||
| 121 | 0 | ▶ | } or do { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | my $eval_error = $@ || 'Zombie error'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'Zombie error'
MC/DC0%0/1
$@ || 'Zombie error'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||
| 123 | 0 | my $msg = "Error from $host_port: $eval_error"; | |||||||||||||||||||||||||||
| 124 | 0 | die $msg; | |||||||||||||||||||||||||||
| 125 | }; | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | next if ! keys %{ $resp }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( $is_flat ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ( $has_all ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | foreach my $bean ( @{ $resp->{beans} } ) { | |||||||||||||||||||||||||||
| 132 | 0 | ▶ | my $name = $bean->{ObjectName} || $bean->{name}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$bean->{'ObjectName'} || $bean->{'name'}
MC/DC0%0/2
$bean->{'ObjectName'} || $bean->{'name'}
$bean->{'ObjectName'}
$bean->{'name'}
Truth table0%0/3
A || B
A= $bean->{'ObjectName'}B= $bean->{'name'}
| |||||||||||||||||||||||||||||
| 133 | 0 | $rv{ $name } = $bean; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||
| 136 | else { | ||||||||||||||||||||||||||||
| 137 | 0 | $rv{ $stat } = $resp; | |||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||
| 139 | 0 | next STATS; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ( $has_all ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 143 | 0 | foreach my $bean ( @{ $resp->{beans} } ) { | |||||||||||||||||||||||||||
| 144 | 0 | ▶ | my $name = $bean->{ObjectName} || $bean->{name}; | ||||||||||||||||||||||||||
|
Condition0%0/3
$bean->{'ObjectName'} || $bean->{'name'}
MC/DC0%0/2
$bean->{'ObjectName'} || $bean->{'name'}
$bean->{'ObjectName'}
$bean->{'name'}
Truth table0%0/3
A || B
A= $bean->{'ObjectName'}B= $bean->{'name'}
| |||||||||||||||||||||||||||||
| 145 | 0 | $self->_expand( $name, $bean, \%rv ); | |||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | else { | ||||||||||||||||||||||||||||
| 149 | 0 | $self->_expand( $stat, $resp, \%rv ); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | 0 | ▶ | if ( $self->decode_json_substrings ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 154 | 0 | $self->_expand_json_substrings_in_place( \%rv ); | |||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||
| 157 | 0 | return \%rv; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 0 | ▶ | sub _expand { | ||||||||||||||||||||||||||
|
Subroutine
_expand: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 161 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 162 | 0 | my $stat_name = shift; | |||||||||||||||||||||||||||
| 163 | 0 | my $response = shift; | |||||||||||||||||||||||||||
| 164 | 0 | my $rv = shift; | |||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||
| 166 | 0 | my @names = split m{ [.,=:] }xms, $stat_name; | |||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||
| 168 | 0 | ▶ | if ( @names > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 169 | 0 | ▶ | my $slot = $rv->{ shift @names } ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$$rv{shift @names} ||= {}
MC/DC0%0/1
$$rv{shift @names} ||= {}
$$rv{shift @names}
Truth table0%0/2
A
A= $$rv{shift @names}
| |||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||
| 171 | 0 | ▶ | while ( my $name = shift @names ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ( @names ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $slot = $slot->{ $name } ||= {}; | ||||||||||||||||||||||||||
|
Condition0%0/2
$slot->{$name} ||= {}
MC/DC0%0/1
$slot->{$name} ||= {}
$slot->{$name}
Truth table0%0/2
A
A= $slot->{$name}
| |||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | else { | ||||||||||||||||||||||||||||
| 176 | 0 | $slot->{$name} = $response; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | else { | ||||||||||||||||||||||||||||
| 181 | 0 | $rv->{ $stat_name } = $response; | |||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | return; | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | ▶ | sub _expand_json_substrings_in_place { | ||||||||||||||||||||||||||
|
Subroutine
_expand_json_substrings_in_place: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 188 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 189 | 0 | ▶ | my $rv = shift || die "No data set specified!"; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die('No data set specified!')
MC/DC0%0/1
shift() || die('No data set specified!')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 0 | my $re_json = qr{ \A \{\" }xms; | |||||||||||||||||||||||||||
| 192 | 0 | ▶ | my $callback = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||
| 193 | 0 | my($thing, $name_or_index, $is_hash) = @_; | |||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( $is_hash ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 195 | 0 | my $item = $thing->{ $name_or_index }; | |||||||||||||||||||||||||||
| 196 | 0 | ▶ | if ( $item =~ $re_json ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | $thing->{ $name_or_index } = JSON::XS::decode_json( $item ); # loop? | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||
| 200 | else { | ||||||||||||||||||||||||||||
| 201 | 0 | my $item = $thing->[ $name_or_index ]; | |||||||||||||||||||||||||||
| 202 | # Array: We don't seem to have such a thing, but you can never know | ||||||||||||||||||||||||||||
| 203 | 0 | ▶ | if ( $item =~ $re_json ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 204 | 0 | $thing->[ $name_or_index ] = JSON::XS::decode_json( $item ); # loop? | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||
| 207 | 0 | return; | |||||||||||||||||||||||||||
| 208 | 0 | }; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | $self->_looper( $rv, $callback ); | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | return; | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub _looper { | ||||||||||||||||||||||||||
|
Subroutine
_looper: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 216 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 217 | 0 | ▶ | my $rv = shift || die 'No data was specified!'; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || die('No data was specified!')
MC/DC0%0/1
shift() || die('No data was specified!')
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 218 | 0 | my $callback = shift; | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | if ( ! is_coderef $callback ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 221 | 0 | die "callback needs to be a CODE ref"; | |||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | 0 | my $looper; | |||||||||||||||||||||||||||
| 225 | 0 | ▶ | $looper = sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=11 SCAR=48.8
| |||||||||||||||||||||||||||||
| 226 | 0 | my $thing = shift; | |||||||||||||||||||||||||||
| 227 | 0 | my $cb = shift; | |||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ( is_hashref $thing ) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 230 | 0 | LOOPH: foreach my $name ( keys %{ $thing } ) { | |||||||||||||||||||||||||||
| 231 | 0 | ▶ | my $item = $thing->{ $name } || next; | ||||||||||||||||||||||||||
|
Condition0%0/2
$thing->{$name} || (next)
MC/DC0%0/1
$thing->{$name} || (next)
$thing->{$name}
Truth table0%0/2
A
A= $thing->{$name}
| |||||||||||||||||||||||||||||
| 232 | 0 | ▶ | if ( is_ref $item ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 233 | 0 | $looper->( $item ); | |||||||||||||||||||||||||||
| 234 | 0 | next LOOPH; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | 0 | $callback->( $thing, $name, 1 ); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | elsif ( is_arrayref $thing ) { | ||||||||||||||||||||||||||||
| 240 | 0 | LOOPA: foreach my $i ( 0.. $#{ $thing } ) { | |||||||||||||||||||||||||||
| 241 | 0 | my $item = $thing->[ $i ]; | |||||||||||||||||||||||||||
| 242 | 0 | ▶ | if ( ref $item ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 243 | 0 | $looper->( $item ); | |||||||||||||||||||||||||||
| 244 | 0 | next LOOPA; | |||||||||||||||||||||||||||
| 245 | } | ||||||||||||||||||||||||||||
| 246 | 0 | $callback->( $thing, $i ); | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | elsif ( is_ref $thing ) { | ||||||||||||||||||||||||||||
| 250 | 0 | ▶ | if ( blessed $thing && $thing->isa('JSON::PP::Boolean') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($thing) and $thing->isa("JSON::PP::Boolean")
MC/DC0%0/2
builtin::blessed($thing) and $thing->isa("JSON::PP::Boolean")
builtin::blessed($thing)
$thing->isa("JSON::PP::Boolean")
Truth table0%0/3
A and B
A= builtin::blessed($thing)B= $thing->isa("JSON::PP::Boolean")
| |||||||||||||||||||||||||||||
| 251 | 0 | return; | |||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||
| 253 | 0 | die "Unknown key: $thing"; | |||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||
| 255 | else { | ||||||||||||||||||||||||||||
| 256 | 0 | die "$thing is not a reference!"; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 0 | }; | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 0 | $looper->( $rv, $callback ); | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||
| 263 | 1 | 1; | |||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | __END__ | ||||||||||||||||||||||||||||