| 1 | 46 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 46 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | package JSON::Schema::Modern::ResultNode; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # vim: set ts=8 sts=2 sw=2 tw=100 et : | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Common code for nodes of a JSON::Schema::Modern::Result | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 46 | our $VERSION = '0.654'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 46 | ▶ | use 5.020; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 46 | ▶ | use Moo::Role; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 46 | ▶ | use strictures 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 46 | ▶ | use stable 0.031 'postderef'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 46 | ▶ | use experimental 'signatures'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 46 | ▶ | no autovivification warn => qw(fetch store exists delete); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 46 | ▶ | use if "$]" >= 5.022, experimental => 're_strict'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 46 | ▶ | no if "$]" >= 5.031009, feature => 'indirect'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 46 | ▶ | no if "$]" >= 5.033001, feature => 'multidimensional'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 46 | ▶ | no if "$]" >= 5.033006, feature => 'bareword_filehandles'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 46 | ▶ | no if "$]" >= 5.041009, feature => 'smartmatch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 46 | ▶ | no feature 'switch'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 46 | ▶ | use Types::Standard qw(Str Undef InstanceOf); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 46 | ▶ | use Types::Common::Numeric 'PositiveOrZeroInt'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 46 | ▶ | use JSON::Schema::Modern::Utilities qw(jsonp json_pointer_type); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 46 | ▶ | use namespace::clean; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # not provided when Error and mode = traverse | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 46 | has instance_location => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | isa => json_pointer_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 46 | has keyword_location => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | isa => json_pointer_type, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | has absolute_keyword_location => ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | isa => InstanceOf['Mojo::URL']|Undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | lazy => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 12754 | ▶ | default => sub ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=14 SCAR=26.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | # _uri contains data as populated from A() and E(): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | # [ $state->{initial_schema_uri}, $state->{keyword_path}, @extra_path ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | # we do the equivalent of: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | # canonical_uri($state, @extra_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 12754 | ▶ | if (my $uri_bits = delete $self->{_uri}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 12743 | my ($initial_schema_uri, $keyword_path, @extra_path) = @$uri_bits; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 12743 | ▶ | return($initial_schema_uri eq '' && $self->{keyword_location} eq '' ? undef : $initial_schema_uri) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%6/6
@extra_path or length $keyword_path
$initial_schema_uri eq "" and $$self{"keyword_location"} eq ""
MC/DC100%2/2
@extra_path or length $keyword_path
@extra_path
length $keyword_path
MC/DC100%2/2
$initial_schema_uri eq "" and $$self{"keyword_location"} eq ""
$initial_schema_uri eq ""
$$self{"keyword_location"} eq ""
Truth table100%3/3
A or B
A= @extra_pathB= length $keyword_path
Truth table100%3/3
A and B
A= $initial_schema_uri eq ""B= $$self{"keyword_location"} eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | if not @extra_path and not length($keyword_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 12619 | my $uri = $initial_schema_uri->clone; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 12619 | ▶ | my $fragment = ($uri->fragment//'').(@extra_path ? jsonp($keyword_path, @extra_path) : $keyword_path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%2/2
$uri->fragment // ""
MC/DC100%1/1
$uri->fragment // ""
$uri->fragment
Truth table100%2/2
A
A= $uri->fragment
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 12619 | ▶ | undef $fragment if not length($fragment); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 12619 | $uri->fragment($fragment); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | undef $uri if $uri eq '' and $self->{keyword_location} eq '' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12619 | ▶ | or ($uri->fragment // '') eq $self->{keyword_location} and $uri->clone->fragment(undef) eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition63%7/11
$uri eq "" and $$self{"keyword_location"} eq "" or ($uri->fragment // "") eq $$self{"keyword_location"} and $uri->clone->fragment(undef) eq ""
$uri eq "" and $$self{"keyword_location"} eq ""
($uri->fragment // "") eq $$self{"keyword_location"} and $uri->clone->fragment(undef) eq ""
$uri->fragment // ""
MC/DC25%1/4
$uri eq "" and $$self{"keyword_location"} eq "" or ($uri->fragment // "") eq $$self{"keyword_location"} and $uri->clone->fragment(undef) eq ""
$uri eq ""
$$self{"keyword_location"} eq ""
$uri->fragment
$uri->clone->fragment(undef) eq ""
Truth table28%2/7
A and B or C and D
A= $uri eq ""B= $$self{"keyword_location"} eq ""C= $uri->fragmentD= $uri->clone->fragment(undef) eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 12619 | return $uri; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 11 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 46 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 46 | has keyword => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | isa => Str|Undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 46 | has depth => ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | is => 'ro', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | isa => PositiveOrZeroInt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | required => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | # TODO: maybe need to support being passed an already-blessed object | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 14201 | ▶ | sub BUILD ($self, $args) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BUILD: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 14201 | ▶ | $self->{_uri} = $args->{_uri} if exists $args->{_uri}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 18861 | ▶ | sub TO_JSON ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
TO_JSON: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 18861 | my $thing = $self->__thing; # annotation or error | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | return +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # note that locations are JSON pointers, not uri fragments! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 18861 | ▶ | !defined($self->instance_location) ? () : (instanceLocation => $self->instance_location), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | keywordLocation => $self->keyword_location, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | !defined($self->absolute_keyword_location) ? () | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | : (absoluteKeywordLocation => $self->absolute_keyword_location->to_string), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | $thing => $self->$thing, # TODO: allow localization in error message | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | sub dump ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | my $encoder = JSON::Schema::Modern::_JSON_BACKEND()->new | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | ->utf8(0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ->convert_blessed(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ->canonical(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ->indent(1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ->space_after(1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | $encoder->indent_length(2) if $encoder->can('indent_length'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | $encoder->encode($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 46 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||