| 1 | package JSON::Schema::Fit; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 2 | $JSON::Schema::Fit::VERSION = '0.05'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: adjust data structure according to json-schema | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use 5.010; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 2 | ▶ | use utf8; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | 2 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 2 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 2 | ▶ | use Scalar::Util qw/reftype/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | 2 | ▶ | use List::Util qw/first/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | 2 | ▶ | use Math::Round qw/round nearest/; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | ▶ | sub booleans { return _attr('booleans', @_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
booleans: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 45 | ▶ | sub numbers { return _attr('numbers', @_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
numbers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 26 | ▶ | sub round_numbers { return _attr('round_numbers', @_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
round_numbers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | 26 | ▶ | sub clamp_numbers { return _attr('clamp_numbers', @_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
clamp_numbers: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 10 | ▶ | sub strings { return _attr('strings', @_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
strings: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 11 | ▶ | sub hash_keys { return _attr('hash_keys', @_); } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
hash_keys: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | # Store valid options as well as default values | ||||||||||||||||||||||||||||||||||||||||||
| 39 | my %valid_option =( | ||||||||||||||||||||||||||||||||||||||||||
| 40 | 10 | ( map { ($_ => 1) } qw!booleans numbers round_numbers strings hash_keys! ), | |||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | ( map { ($_ => 0) } qw!clamp_numbers! ), | |||||||||||||||||||||||||||||||||||||||||
| 42 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | sub new { | ||||||||||||||||||||||||||||||||||||||||||
| 45 | 10 | ▶ | my ($class, %opts) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 10 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 47 | 10 | for my $k (keys %opts) { | |||||||||||||||||||||||||||||||||||||||||
| 48 | 13 | ▶ | next unless exists $valid_option{$k}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 49 | 13 | _attr($k, $self, $opts{$k}); | |||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||
| 51 | 10 | return $self | |||||||||||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | sub _attr { | ||||||||||||||||||||||||||||||||||||||||||
| 55 | 142 | ▶ | my $attr = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attr: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 56 | 142 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | 142 | ▶ | if (@_) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 59 | 13 | return $self->{$attr} = shift; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 129 | ▶ | return $self->{$attr} //= $valid_option{$attr}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$self->{$attr} //= $valid_option{$attr}
MC/DC100%2/2
$self->{$attr} //= $valid_option{$attr}
$self->{$attr}
$valid_option{$attr}
Truth table100%3/3
A //= B
A= $self->{$attr}B= $valid_option{$attr}
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||
| 66 | sub get_adjusted { | ||||||||||||||||||||||||||||||||||||||||||
| 67 | 66 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_adjusted: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 66 | ▶ | return $struc if !ref $schema || reftype $schema ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not ref $schema or builtin::reftype($schema) ne "HASH"
MC/DC50%1/2
not ref $schema or builtin::reftype($schema) ne "HASH"
not ref $schema
builtin::reftype($schema) ne "HASH"
Truth table66%2/3
not(A) or B
A= not ref $schemaB= builtin::reftype($schema) ne "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 63 | my $method = $self->_adjuster_by_type($schema->{type}); | |||||||||||||||||||||||||||||||||||||||||
| 71 | 63 | ▶ | return $struc if !$method; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 63 | return $self->$method($struc, $schema, $jpath); | |||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | sub _adjuster_by_type { | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 63 | ▶ | my ($self, $type) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_adjuster_by_type: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 63 | ▶ | return if !$type; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 63 | my $method = "_get_adjusted_$type"; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 63 | ▶ | return $method if $self->can($method); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | sub _get_adjusted_boolean { | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 11 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_adjusted_boolean: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 11 | ▶ | return $struc if !$self->booleans(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 9 | ▶ | return JSON::true if $struc; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | return JSON::false; | |||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | sub _get_adjusted_integer { | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 17 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_adjusted_integer: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 17 | ▶ | return $struc if !$self->numbers(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 15 | my $result = $self->_get_adjusted_number($struc, $schema, $jpath); | |||||||||||||||||||||||||||||||||||||||||
| 100 | 15 | return round($result); | |||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | sub _get_adjusted_number { | ||||||||||||||||||||||||||||||||||||||||||
| 105 | 28 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_adjusted_number: called CC=10 SCAR=23.0
| |||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 28 | ▶ | return $struc if !$self->numbers(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 26 | my $result = 0+$struc; | |||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | 26 | ▶ | if ($self->round_numbers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 24 | ▶ | my $quantum = $schema->{multipleOf} || $schema->{divisibleBy}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$schema->{'multipleOf'} || $schema->{'divisibleBy'}
MC/DC50%1/2
$schema->{'multipleOf'} || $schema->{'divisibleBy'}
$schema->{'multipleOf'}
$schema->{'divisibleBy'}
Truth table66%2/3
A || B
A= $schema->{'multipleOf'}B= $schema->{'divisibleBy'}
| |||||||||||||||||||||||||||||||||||||||||||
| 112 | 24 | ▶ | $result = nearest $quantum, $result if $quantum; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 26 | ▶ | if ($self->clamp_numbers) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 16 | ▶ | $result = $schema->{maximum} if exists $schema->{maximum} and $result > $schema->{maximum}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $schema->{"maximum"} and $result > $schema->{"maximum"}
MC/DC100%2/2
exists $schema->{"maximum"} and $result > $schema->{"maximum"}
exists $schema->{"maximum"}
$result > $schema->{"maximum"}
Truth table100%3/3
A and B
A= exists $schema->{"maximum"}B= $result > $schema->{"maximum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | 16 | ▶ | $result = $schema->{minimum} if exists $schema->{minimum} and $result < $schema->{minimum}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
exists $schema->{"minimum"} and $result < $schema->{"minimum"}
MC/DC100%2/2
exists $schema->{"minimum"} and $result < $schema->{"minimum"}
exists $schema->{"minimum"}
$result < $schema->{"minimum"}
Truth table100%3/3
A and B
A= exists $schema->{"minimum"}B= $result < $schema->{"minimum"}
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | 26 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | sub _get_adjusted_string { | ||||||||||||||||||||||||||||||||||||||||||
| 125 | 10 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_adjusted_string: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 10 | ▶ | return $struc if !$self->strings(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 8 | return "$struc"; | |||||||||||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | sub _get_adjusted_array { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 1 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_adjusted_array: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 1 | ▶ | croak "Structure is not ARRAY at $jpath" if reftype $struc ne 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 1 | my $result = []; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 1 | for my $i ( 0 .. $#$struc ) { | |||||||||||||||||||||||||||||||||||||||||
| 139 | 3 | push @$result, $self->get_adjusted($struc->[$i], $schema->{items}, $self->_jpath($jpath, $i)); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 1 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||||||||||||||||
| 147 | sub _get_adjusted_object { | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 11 | ▶ | my ($self, $struc, $schema, $jpath) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_get_adjusted_object: called CC=12 SCAR=25.6
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 11 | ▶ | croak "Structure is not HASH at $jpath" if reftype $struc ne 'HASH'; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 11 | my $result = {}; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 11 | my $keys_re; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 11 | ▶ | my $properties = $schema->{properties} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$schema->{'properties'} || {}
MC/DC0%0/1
$schema->{'properties'} || {}
$schema->{'properties'}
Truth table50%1/2
A
A= $schema->{'properties'}
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 11 | ▶ | my $p_properties = $schema->{patternProperties} || {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$schema->{'patternProperties'} || {}
MC/DC0%0/1
$schema->{'patternProperties'} || {}
$schema->{'patternProperties'}
Truth table50%1/2
A
A= $schema->{'patternProperties'}
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 11 | ▶ | if ($self->hash_keys() && exists $schema->{additionalProperties} && !$schema->{additionalProperties}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->hash_keys and exists $schema->{"additionalProperties"} and not $schema->{"additionalProperties"}
$self->hash_keys and exists $schema->{"additionalProperties"}
MC/DC66%2/3
$self->hash_keys and exists $schema->{"additionalProperties"} and not $schema->{"additionalProperties"}
$self->hash_keys
exists $schema->{"additionalProperties"}
not $schema->{"additionalProperties"}
Truth table75%3/4
A and B and not(C)
A= $self->hash_keysB= exists $schema->{"additionalProperties"}C= not $schema->{"additionalProperties"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | my $keys_re_text = join q{|}, ( | ||||||||||||||||||||||||||||||||||||||||||
| 160 | keys %$p_properties, | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 8 | map {quotemeta} keys %$properties, | |||||||||||||||||||||||||||||||||||||||||
| 162 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 163 | 8 | $keys_re = qr{^$keys_re_text$}x; | |||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 11 | for my $key (keys %$struc) { | |||||||||||||||||||||||||||||||||||||||||
| 167 | 49 | ▶ | next if $keys_re && $key !~ $keys_re; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$keys_re and not $key =~ /$keys_re/x
MC/DC100%2/2
$keys_re and not $key =~ /$keys_re/x
$keys_re
not $key =~ /$keys_re/x
Truth table100%3/3
A and not(B)
A= $keys_reB= not $key =~ /$keys_re/x
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 41 | my $subschema = $properties->{$key}; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 41 | ▶ | if (my $re_key = !$subschema && first {$key =~ /$_/x} keys %$p_properties) { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=0.8
Branch: 1 branch
Condition66%2/3
!$subschema && &first(sub {
$key =~ /$_/x;
}
, keys %$p_properties)
MC/DC0%0/2
!$subschema && &first(sub {
$key =~ /$_/x;
}
, keys %$p_properties)
!$subschema
&first(sub {
$key =~ /$_/x;
}
, keys %$p_properties)
Truth table66%2/3
not(A) && B
A= !$subschemaB= &first(sub {
$key =~ /$_/x;
}
, keys %$p_properties)
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | $subschema = $p_properties->{$re_key}; | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | 41 | $result->{$key} = $self->get_adjusted($struc->{$key}, $subschema, $self->_jpath($jpath, $key)); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 11 | return $result; | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | sub _jpath { | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 44 | ▶ | my ($self, $path, $key) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_jpath: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 44 | ▶ | $path //= q{$}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$path //= "\$"
MC/DC0%0/1
$path //= "\$"
$path
Truth table50%1/2
A
A= $path
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | 44 | ▶ | return "$path.$key" if $key =~ /^[_A-Za-z]\w*$/x; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | $key =~ s/(['\\])/\\$1/gx; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | return $path . "['$key']"; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | __END__ | ||||||||||||||||||||||||||||||||||||||||||