| 1 | 50 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 2 | 50 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | package YAML::PP::Schema; | ||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||
| 5 | 50 | our $VERSION = 'v0.43.0'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||
| 7 | 50 | ▶ | use YAML::PP::Common qw/ YAML_PLAIN_SCALAR_STYLE /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 50 | ▶ | use Carp qw/ croak /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 50 | ▶ | use Scalar::Util qw/ blessed /; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | 772 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=15 SCAR=32.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 772 | my ($class, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | 772 | my $yaml_version = delete $args{yaml_version}; | |||||||||||||||||||||||||||||||||||||||||
| 16 | 772 | my $bool = delete $args{boolean}; | |||||||||||||||||||||||||||||||||||||||||
| 17 | 772 | ▶ | $bool = 'perl' unless defined $bool; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 18 | 772 | ▶ | if (keys %args) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | die "Unexpected arguments: " . join ', ', sort keys %args; | |||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 772 | my $true; | |||||||||||||||||||||||||||||||||||||||||
| 22 | my $false; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | 772 | my @bool_class; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 772 | my @bools = split m/,/, $bool; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 772 | for my $b (@bools) { | |||||||||||||||||||||||||||||||||||||||||
| 26 | 765 | ▶ | if ($b eq '*') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | push @bool_class, ('boolean', 'JSON::PP::Boolean'); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||||||||||||
| 30 | elsif ($b eq 'JSON::PP') { | ||||||||||||||||||||||||||||||||||||||||||
| 31 | 595 | require JSON::PP; | |||||||||||||||||||||||||||||||||||||||||
| 32 | 595 | ▶ | $true ||= \&_bool_jsonpp_true; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$true ||= \&YAML::PP::Schema::_bool_jsonpp_true
MC/DC0%0/1
$true ||= \&YAML::PP::Schema::_bool_jsonpp_true
$true
Truth table50%1/2
A
A= $true
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 595 | ▶ | $false ||= \&_bool_jsonpp_false; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$false ||= \&YAML::PP::Schema::_bool_jsonpp_false
MC/DC0%0/1
$false ||= \&YAML::PP::Schema::_bool_jsonpp_false
$false
Truth table50%1/2
A
A= $false
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 595 | push @bool_class, 'JSON::PP::Boolean'; | |||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||
| 36 | elsif ($b eq 'boolean') { | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | require boolean; | |||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | $true ||= \&_bool_booleanpm_true; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$true ||= \&YAML::PP::Schema::_bool_booleanpm_true
MC/DC0%0/1
$true ||= \&YAML::PP::Schema::_bool_booleanpm_true
$true
Truth table0%0/2
A
A= $true
| |||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | $false ||= \&_bool_booleanpm_false; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$false ||= \&YAML::PP::Schema::_bool_booleanpm_false
MC/DC0%0/1
$false ||= \&YAML::PP::Schema::_bool_booleanpm_false
$false
Truth table0%0/2
A
A= $false
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | 0 | push @bool_class, 'boolean'; | |||||||||||||||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||||||||||||||||
| 42 | ▶ | elsif ($b eq 'perl' or $b eq 'perl_experimental') { | |||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$b eq "perl" or $b eq "perl_experimental"
MC/DC0%0/2
$b eq "perl" or $b eq "perl_experimental"
$b eq "perl"
$b eq "perl_experimental"
Truth table66%2/3
A or B
A= $b eq "perl"B= $b eq "perl_experimental"
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 170 | push @bool_class, 'perl'; | |||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||
| 45 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | die "Invalid value for 'boolean': '$b'. Allowed: ('perl', 'boolean', 'JSON::PP')"; | |||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # Ensure booleans are resolved | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 772 | ▶ | $true ||= \&_bool_perl_true; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$true ||= \&YAML::PP::Schema::_bool_perl_true
MC/DC100%1/1
$true ||= \&YAML::PP::Schema::_bool_perl_true
$true
Truth table100%2/2
A
A= $true
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 772 | ▶ | $false ||= \&_bool_perl_false; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$false ||= \&YAML::PP::Schema::_bool_perl_false
MC/DC100%1/1
$false ||= \&YAML::PP::Schema::_bool_perl_false
$false
Truth table100%2/2
A
A= $false
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 772 | my %representers = ( | |||||||||||||||||||||||||||||||||||||||||
| 54 | 'undef' => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | flags => [], | ||||||||||||||||||||||||||||||||||||||||||
| 56 | equals => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | regex => [], | ||||||||||||||||||||||||||||||||||||||||||
| 58 | class_equals => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | class_matches => [], | ||||||||||||||||||||||||||||||||||||||||||
| 60 | class_isa => [], | ||||||||||||||||||||||||||||||||||||||||||
| 61 | scalarref => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | refref => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | coderef => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | glob => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | tied_equals => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 66 | bool => undef, | ||||||||||||||||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 772 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 69 | yaml_version => $yaml_version, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | resolvers => {}, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | representers => \%representers, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | true => $true, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | false => $false, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | bool_class => \@bool_class, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 76 | 772 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 52812 | ▶ | sub resolvers { return $_[0]->{resolvers} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resolvers: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 25077 | ▶ | sub representers { return $_[0]->{representers} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
representers: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 2293 | ▶ | sub true { return $_[0]->{true} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
true: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 2293 | ▶ | sub false { return $_[0]->{false} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
false: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1604 | ▶ | sub bool_class { return @{ $_[0]->{bool_class} } ? $_[0]->{bool_class} : undef } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
bool_class: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 790 | ▶ | sub yaml_version { return $_[0]->{yaml_version} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
yaml_version: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 50 | my %LOADED_SCHEMA = ( | |||||||||||||||||||||||||||||||||||||||||
| 88 | JSON => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 89 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 90 | my %DEFAULT_SCHEMA = ( | ||||||||||||||||||||||||||||||||||||||||||
| 91 | 453 | ▶ | '1.2' => sub { require YAML::PP::Schema::Core; return 'YAML::PP::Schema::Core' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | ▶ | '1.1' => sub { require YAML::PP::Schema::YAML1_1; return 'YAML::PP::Schema::YAML1_1' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | 50 | ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | my %AVAILABLE_SCHEMAS = ( | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 286 | ▶ | 'Core' => sub { require YAML::PP::Schema::Core; return 'YAML::PP::Schema::Core' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 22 | ▶ | 'JSON' => sub { require YAML::PP::Schema::JSON; return 'YAML::PP::Schema::JSON' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 3 | ▶ | 'Failsafe' => sub { require YAML::PP::Schema::Failsafe; return 'YAML::PP::Schema::Failsafe' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 1 | ▶ | 'Merge' => sub { require YAML::PP::Schema::Merge; return 'YAML::PP::Schema::Merge' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | 18 | ▶ | 'Perl' => sub { require YAML::PP::Schema::Perl; return 'YAML::PP::Schema::Perl' }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 100 | 50 | ); | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 772 | ▶ | sub load_subschemas { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_subschemas: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 772 | my ($self, @schemas) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 772 | my $yaml_version = $self->yaml_version; | |||||||||||||||||||||||||||||||||||||||||
| 105 | 772 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 106 | 772 | ▶ | while ($i < @schemas) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | 1391 | my $item = $schemas[ $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 1391 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 1391 | my $class; | |||||||||||||||||||||||||||||||||||||||||
| 110 | 1391 | ▶ | if ($item eq '+') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 457 | my $code = $DEFAULT_SCHEMA{ $yaml_version }; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 457 | $class = $code->(); | |||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | elsif ($AVAILABLE_SCHEMAS{ $item }) { | ||||||||||||||||||||||||||||||||||||||||||
| 115 | 330 | my $code = $AVAILABLE_SCHEMAS{ $item }; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 330 | $class = $code->(); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | elsif (blessed($item)) { | ||||||||||||||||||||||||||||||||||||||||||
| 119 | 10 | $item->register( | |||||||||||||||||||||||||||||||||||||||||
| 120 | schema => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 121 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 10 | next; | |||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 1381 | my @options; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 1381 | ▶ | while ($i < @schemas | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
$i < @schemas and $schemas[$i] =~ /^[^A-Za-z]/ || $schemas[$i] =~ /^[a-zA-Z0-9]+=/
$schemas[$i] =~ /^[^A-Za-z]/ or $schemas[$i] =~ /^[a-zA-Z0-9]+=/
MC/DC100%3/3
$i < @schemas and $schemas[$i] =~ /^[^A-Za-z]/ || $schemas[$i] =~ /^[a-zA-Z0-9]+=/
$i < @schemas
$schemas[$i] =~ /^[^A-Za-z]/
$schemas[$i] =~ /^[a-zA-Z0-9]+=/
Truth table100%4/4
A and B or C
A= $i < @schemasB= $schemas[$i] =~ /^[^A-Za-z]/C= $schemas[$i] =~ /^[a-zA-Z0-9]+=/
| |||||||||||||||||||||||||||||||||||||||||||
| 126 | and ( | ||||||||||||||||||||||||||||||||||||||||||
| 127 | $schemas[ $i ] =~ m/^[^A-Za-z]/ | ||||||||||||||||||||||||||||||||||||||||||
| 128 | or | ||||||||||||||||||||||||||||||||||||||||||
| 129 | $schemas[ $i ] =~ m/^[a-zA-Z0-9]+=/ | ||||||||||||||||||||||||||||||||||||||||||
| 130 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 131 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 14 | push @options, $schemas[ $i ]; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 14 | $i++; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 1381 | ▶ | unless ($class) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | 594 | require Module::Load; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 594 | ▶ | if ($item =~ m/^\:(.*)/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 2 | $class = "$1"; | |||||||||||||||||||||||||||||||||||||||||
| 140 | 2 | ▶ | unless ($class =~ m/\A[A-Za-z0-9_:]+\z/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1 | die "Module name '$class' is invalid"; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 1 | Module::Load::load $class; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 592 | $class = "YAML::PP::Schema::$item"; | |||||||||||||||||||||||||||||||||||||||||
| 147 | 592 | ▶ | unless ($class =~ m/\A[A-Za-z0-9_:]+\z/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 148 | 1 | die "Module name '$class' is invalid"; | |||||||||||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||||||||||||
| 150 | 591 | ▶ | $LOADED_SCHEMA{ $item } ||= Module::Load::load $class; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$LOADED_SCHEMA{$item} ||= $class->Module::Load::load
MC/DC0%0/2
$LOADED_SCHEMA{$item} ||= $class->Module::Load::load
$LOADED_SCHEMA{$item}
$class->Module::Load::load
Truth table33%1/3
A ||= B
A= $LOADED_SCHEMA{$item}B= $class->Module::Load::load
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||
| 153 | $class->register( | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 1379 | schema => $self, | |||||||||||||||||||||||||||||||||||||||||
| 155 | options => \@options, | ||||||||||||||||||||||||||||||||||||||||||
| 156 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | 21820 | ▶ | sub add_resolver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_resolver: called CC=13 SCAR=25.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 21820 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 21820 | my $tag = $args{tag}; | |||||||||||||||||||||||||||||||||||||||||
| 164 | 21820 | my $rule = $args{match}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | 21820 | my $resolvers = $self->resolvers; | |||||||||||||||||||||||||||||||||||||||||
| 166 | 21820 | my ($type, @rule) = @$rule; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 21820 | my $implicit = $args{implicit}; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 21820 | ▶ | $implicit = 1 unless defined $implicit; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 21820 | my $resolver_list = []; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 21820 | ▶ | if ($tag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 21820 | ▶ | if (ref $tag eq 'Regexp') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 681 | ▶ | my $res = $resolvers->{tags} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$resolvers->{"tags"} ||= []
MC/DC100%1/1
$resolvers->{"tags"} ||= []
$resolvers->{"tags"}
Truth table100%2/2
A
A= $resolvers->{"tags"}
| |||||||||||||||||||||||||||||||||||||||||||
| 173 | 681 | push @$res, [ $tag, {} ]; | |||||||||||||||||||||||||||||||||||||||||
| 174 | 681 | push @$resolver_list, $res->[-1]->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 177 | 21139 | ▶ | my $res = $resolvers->{tag}->{ $tag } ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$resolvers->{"tag"}{$tag} ||= {}
MC/DC100%1/1
$resolvers->{"tag"}{$tag} ||= {}
$resolvers->{"tag"}{$tag}
Truth table100%2/2
A
A= $resolvers->{"tag"}{$tag}
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 21139 | push @$resolver_list, $res; | |||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 21820 | ▶ | if ($implicit) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 21073 | ▶ | push @$resolver_list, $resolvers->{value} ||= {}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$resolvers->{"value"} ||= {}
MC/DC100%1/1
$resolvers->{"value"} ||= {}
$resolvers->{"value"}
Truth table100%2/2
A
A= $resolvers->{"value"}
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 21820 | for my $res (@$resolver_list) { | |||||||||||||||||||||||||||||||||||||||||
| 185 | 42893 | ▶ | if ($type eq 'equals') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | 34554 | my ($match, $value) = @rule; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 34554 | ▶ | unless (exists $res->{equals}->{ $match }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 34554 | $res->{equals}->{ $match } = $value; | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | 34554 | next; | |||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||
| 192 | elsif ($type eq 'regex') { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 6066 | my ($match, $value) = @rule; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 6066 | push @{ $res->{regex} }, [ $match => $value ]; | |||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||
| 196 | elsif ($type eq 'all') { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 2273 | my ($value) = @rule; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 2273 | $res->{all} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | } | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | 669 | ▶ | sub add_sequence_resolver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_sequence_resolver: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 204 | 669 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 205 | 669 | return $self->add_collection_resolver(sequence => %args); | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 874 | ▶ | sub add_mapping_resolver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_mapping_resolver: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 874 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 210 | 874 | return $self->add_collection_resolver(mapping => %args); | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 1543 | ▶ | sub add_collection_resolver { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_collection_resolver: called CC=6 SCAR=18.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 1543 | my ($self, $type, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 215 | 1543 | my $tag = $args{tag}; | |||||||||||||||||||||||||||||||||||||||||
| 216 | 1543 | my $implicit = $args{implicit}; | |||||||||||||||||||||||||||||||||||||||||
| 217 | 1543 | my $resolvers = $self->resolvers; | |||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 1543 | ▶ | if ($tag and ref $tag eq 'Regexp') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$tag and ref $tag eq "Regexp"
MC/DC50%1/2
$tag and ref $tag eq "Regexp"
$tag
ref $tag eq "Regexp"
Truth table66%2/3
A and B
A= $tagB= ref $tag eq "Regexp"
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 1394 | ▶ | my $res = $resolvers->{ $type }->{tags} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$resolvers->{$type}{"tags"} ||= []
MC/DC100%1/1
$resolvers->{$type}{"tags"} ||= []
$resolvers->{$type}{"tags"}
Truth table100%2/2
A
A= $resolvers->{$type}{"tags"}
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | push @$res, [ $tag, { | ||||||||||||||||||||||||||||||||||||||||||
| 222 | on_create => $args{on_create}, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | on_data => $args{on_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 224 | 1394 | } ]; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | elsif ($tag) { | ||||||||||||||||||||||||||||||||||||||||||
| 227 | my $res = $resolvers->{ $type }->{tag}->{ $tag } ||= { | ||||||||||||||||||||||||||||||||||||||||||
| 228 | on_create => $args{on_create}, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | on_data => $args{on_data}, | ||||||||||||||||||||||||||||||||||||||||||
| 230 | 149 | ▶ | }; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$resolvers->{$type}{"tag"}{$tag} ||= {"on_create", $args{"on_create"}, "on_data", $args{"on_data"}}
MC/DC0%0/1
$resolvers->{$type}{"tag"}{$tag} ||= {"on_create", $args{"on_create"}, "on_data", $args{"on_data"}}
$resolvers->{$type}{"tag"}{$tag}
Truth table50%1/2
A
A= $resolvers->{$type}{"tag"}{$tag}
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 21226 | ▶ | sub add_representer { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
add_representer: called CC=15 SCAR=27.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 235 | 21226 | my ($self, %args) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 21226 | my $representers = $self->representers; | |||||||||||||||||||||||||||||||||||||||||
| 238 | 21226 | ▶ | if (my $flags = $args{flags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1530 | my $rep = $representers->{flags}; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 1530 | push @$rep, \%args; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 1530 | return; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | 19696 | ▶ | if (my $regex = $args{regex}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | 766 | my $rep = $representers->{regex}; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 766 | push @$rep, \%args; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 766 | return; | |||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||
| 248 | 18930 | ▶ | if (my $regex = $args{class_matches}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 26 | my $rep = $representers->{class_matches}; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 26 | push @$rep, [ $args{class_matches}, $args{code} ]; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 18904 | ▶ | if (my $bool = $args{bool} and $] >= 5.036000) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
my $bool = $args{"bool"} and $] >= "5.036"
MC/DC50%1/2
my $bool = $args{"bool"} and $] >= "5.036"
my $bool = $args{"bool"}
$] >= "5.036"
Truth table66%2/3
A and B
A= my $bool = $args{"bool"}B= $] >= "5.036"
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | $representers->{bool} = { | ||||||||||||||||||||||||||||||||||||||||||
| 255 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 256 | 165 | }; | |||||||||||||||||||||||||||||||||||||||||
| 257 | 165 | return; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | 18739 | ▶ | if (my $class_equals = $args{class_equals}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 595 | my $rep = $representers->{class_equals}; | |||||||||||||||||||||||||||||||||||||||||
| 261 | $rep->{ $class_equals } = { | ||||||||||||||||||||||||||||||||||||||||||
| 262 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 595 | }; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 595 | return; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 18144 | ▶ | if (my $class_isa = $args{class_isa}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 2 | my $rep = $representers->{class_isa}; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 2 | push @$rep, [ $args{class_isa}, $args{code} ]; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 18142 | ▶ | if (my $tied_equals = $args{tied_equals}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | my $rep = $representers->{tied_equals}; | |||||||||||||||||||||||||||||||||||||||||
| 273 | $rep->{ $tied_equals } = { | ||||||||||||||||||||||||||||||||||||||||||
| 274 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | }; | |||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||
| 278 | 18142 | ▶ | if (defined(my $equals = $args{equals})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | 17281 | my $rep = $representers->{equals}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | $rep->{ $equals } = { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 17281 | }; | |||||||||||||||||||||||||||||||||||||||||
| 283 | 17281 | return; | |||||||||||||||||||||||||||||||||||||||||
| 284 | } | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 861 | ▶ | if (defined(my $scalarref = $args{scalarref})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 286 | $representers->{scalarref} = { | ||||||||||||||||||||||||||||||||||||||||||
| 287 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 837 | ▶ | if (defined(my $refref = $args{refref})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | $representers->{refref} = { | ||||||||||||||||||||||||||||||||||||||||||
| 293 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 813 | ▶ | if (defined(my $coderef = $args{coderef})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | $representers->{coderef} = { | ||||||||||||||||||||||||||||||||||||||||||
| 299 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | 789 | ▶ | if (defined(my $glob = $args{glob})) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | $representers->{glob} = { | ||||||||||||||||||||||||||||||||||||||||||
| 305 | code => $args{code}, | ||||||||||||||||||||||||||||||||||||||||||
| 306 | 24 | }; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 24 | return; | |||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||
| 309 | 765 | ▶ | if (my $undef = $args{undefined}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 765 | $representers->{undef} = $undef; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 765 | return; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | 26588 | ▶ | sub load_scalar { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
load_scalar: called CC=16 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 26588 | my ($self, $constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 26588 | my $tag = $event->{tag}; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 26588 | my $value = $event->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 26588 | my $resolvers = $self->resolvers; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 26588 | my $res; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 26588 | ▶ | if ($tag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | 697 | ▶ | if ($tag eq '!') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 324 | 7 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 325 | } | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 690 | $res = $resolvers->{tag}->{ $tag }; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 690 | ▶ | if (not $res and my $matches = $resolvers->{tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $res and my $matches = $resolvers->{"tags"}
MC/DC50%1/2
not $res and my $matches = $resolvers->{"tags"}
not $res
my $matches = $resolvers->{"tags"}
Truth table66%2/3
not(A) and B
A= not $resB= my $matches = $resolvers->{"tags"}
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 56 | for my $match (@$matches) { | |||||||||||||||||||||||||||||||||||||||||
| 329 | 76 | my ($re, $rule) = @$match; | |||||||||||||||||||||||||||||||||||||||||
| 330 | 76 | ▶ | if ($tag =~ $re) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 56 | $res = $rule; | |||||||||||||||||||||||||||||||||||||||||
| 332 | 56 | last; | |||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | #unless ($res) { | ||||||||||||||||||||||||||||||||||||||||||
| 337 | # croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags"; | ||||||||||||||||||||||||||||||||||||||||||
| 338 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||
| 340 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 25891 | $res = $resolvers->{value}; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 25891 | ▶ | if ($event->{style} ne YAML_PLAIN_SCALAR_STYLE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 2658 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 344 | } | ||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 23923 | ▶ | if (my $equals = $res->{equals}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 23303 | ▶ | if (exists $equals->{ $value }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | 426 | my $res = $equals->{ $value }; | |||||||||||||||||||||||||||||||||||||||||
| 350 | 426 | ▶ | if (ref $res eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 82 | return $res->($constructor, $event); | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 344 | return $res; | |||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 23497 | ▶ | if (my $regex = $res->{regex}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 357 | 22864 | for my $item (@$regex) { | |||||||||||||||||||||||||||||||||||||||||
| 358 | 61704 | my ($re, $sub) = @$item; | |||||||||||||||||||||||||||||||||||||||||
| 359 | 61704 | my @matches = $value =~ $re; | |||||||||||||||||||||||||||||||||||||||||
| 360 | 61704 | ▶ | if (@matches) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 9875 | return $sub->($constructor, $event, \@matches); | |||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||
| 363 | } | ||||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 13622 | ▶ | if (my $catch_all = $res->{all}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 13595 | ▶ | if (ref $catch_all eq 'CODE') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 13595 | return $catch_all->($constructor, $event); | |||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | return $catch_all; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 27 | return $value; | |||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 1230 | ▶ | sub create_sequence { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_sequence: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 1230 | my ($self, $constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 376 | 1230 | my $tag = $event->{tag}; | |||||||||||||||||||||||||||||||||||||||||
| 377 | 1230 | my $data = []; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 1230 | my $on_data; | |||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1230 | my $resolvers = $self->resolvers->{sequence}; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 1230 | ▶ | if ($tag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 382 | 35 | ▶ | if (my $equals = $resolvers->{tag}->{ $tag }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 6 | my $on_create = $equals->{on_create}; | |||||||||||||||||||||||||||||||||||||||||
| 384 | 6 | $on_data = $equals->{on_data}; | |||||||||||||||||||||||||||||||||||||||||
| 385 | 6 | ▶ | $on_create and $data = $on_create->($constructor, $event); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 386 | 6 | return ($data, $on_data); | |||||||||||||||||||||||||||||||||||||||||
| 387 | } | ||||||||||||||||||||||||||||||||||||||||||
| 388 | 29 | ▶ | if (my $matches = $resolvers->{tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 29 | for my $match (@$matches) { | |||||||||||||||||||||||||||||||||||||||||
| 390 | 31 | my ($re, $actions) = @$match; | |||||||||||||||||||||||||||||||||||||||||
| 391 | 31 | my $on_create = $actions->{on_create}; | |||||||||||||||||||||||||||||||||||||||||
| 392 | 31 | ▶ | if ($tag =~ $re) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 393 | 29 | $on_data = $actions->{on_data}; | |||||||||||||||||||||||||||||||||||||||||
| 394 | 29 | ▶ | $on_create and $data = $on_create->($constructor, $event); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 395 | 29 | return ($data, $on_data); | |||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | #croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags"; | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 1195 | return ($data, $on_data); | |||||||||||||||||||||||||||||||||||||||||
| 403 | } | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | 1631 | ▶ | sub create_mapping { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_mapping: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | 1631 | my ($self, $constructor, $event) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 407 | 1631 | my $tag = $event->{tag}; | |||||||||||||||||||||||||||||||||||||||||
| 408 | 1631 | my $data = {}; | |||||||||||||||||||||||||||||||||||||||||
| 409 | 1631 | my $on_data; | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 1631 | my $resolvers = $self->resolvers->{mapping}; | |||||||||||||||||||||||||||||||||||||||||
| 412 | 1631 | ▶ | if ($tag) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 83 | ▶ | if (my $equals = $resolvers->{tag}->{ $tag }) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 414 | 24 | my $on_create = $equals->{on_create}; | |||||||||||||||||||||||||||||||||||||||||
| 415 | 24 | $on_data = $equals->{on_data}; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 24 | ▶ | $on_create and $data = $on_create->($constructor, $event); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 24 | return ($data, $on_data); | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | 59 | ▶ | if (my $matches = $resolvers->{tags}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 420 | 59 | for my $match (@$matches) { | |||||||||||||||||||||||||||||||||||||||||
| 421 | 146 | my ($re, $actions) = @$match; | |||||||||||||||||||||||||||||||||||||||||
| 422 | 146 | my $on_create = $actions->{on_create}; | |||||||||||||||||||||||||||||||||||||||||
| 423 | 146 | ▶ | if ($tag =~ $re) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 59 | $on_data = $actions->{on_data}; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 59 | ▶ | $on_create and $data = $on_create->($constructor, $event); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 59 | return ($data, $on_data); | |||||||||||||||||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||
| 430 | #croak "Unknown tag '$tag'. Use schema 'Catchall' to ignore unknown tags"; | ||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||
| 433 | 1548 | return ($data, $on_data); | |||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||
| 436 | 31 | ▶ | sub _bool_jsonpp_true { JSON::PP::true() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bool_jsonpp_true: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | ▶ | sub _bool_booleanpm_true { boolean::true() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bool_booleanpm_true: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||
| 440 | 16 | ▶ | sub _bool_perl_true { !!1 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bool_perl_true: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||
| 442 | 33 | ▶ | sub _bool_jsonpp_false { JSON::PP::false() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bool_jsonpp_false: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | sub _bool_booleanpm_false { boolean::false() } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bool_booleanpm_false: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | 2 | ▶ | sub _bool_perl_false { !!0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_bool_perl_false: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||
| 448 | 50 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||||||||||||||||
| 450 | __END__ | ||||||||||||||||||||||||||||||||||||||||||