File Coverage

blib/lib/JSON/Schema/Modern/Annotation.pm
Criterion Covered Total %
statement 54 54 100.0
branch n/a
condition n/a
subroutine 19 19 100.0
pod n/a
total 73 73 100.0


line stmt bran cond sub pod time code
1 45     45   255 use strict;
  45         83  
  45         1543  
2 45     45   234 use warnings;
  45         76  
  45         3244  
3             package JSON::Schema::Modern::Annotation;
4             # vim: set ts=8 sts=2 sw=2 tw=100 et :
5             # ABSTRACT: Contains a single annotation from a JSON Schema evaluation
6              
7             our $VERSION = '0.638';
8              
9 45     45   613 use 5.020;
  45         134  
10 45     45   160 use Moo;
  45         69  
  45         242  
11             with 'JSON::Schema::Modern::ResultNode';
12 45     45   13619 use strictures 2;
  45         343  
  45         1462  
13 45     45   15789 use stable 0.031 'postderef';
  45         582  
  45         229  
14 45     45   6315 use experimental 'signatures';
  45         105  
  45         143  
15 45     45   2000 no autovivification warn => qw(fetch store exists delete);
  45         71  
  45         248  
16 45     45   2651 use if "$]" >= 5.022, experimental => 're_strict';
  45         85  
  45         847  
17 45     45   2592 no if "$]" >= 5.031009, feature => 'indirect';
  45         101  
  45         2182  
18 45     45   190 no if "$]" >= 5.033001, feature => 'multidimensional';
  45         67  
  45         1907  
19 45     45   181 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  45         72  
  45         1823  
20 45     45   187 no if "$]" >= 5.041009, feature => 'smartmatch';
  45         79  
  45         1675  
21 45     45   215 no feature 'switch';
  45         77  
  45         1079  
22 45     45   165 use MooX::TypeTiny;
  45         86  
  45         313  
23 45     45   33161 use Types::Standard 'Bool';
  45         109  
  45         330  
24 45     45   101886 use Carp 'croak';
  45         96  
  45         2825  
25 45     45   240 use namespace::clean;
  45         69  
  45         428  
26              
27             has '+instance_location' => (
28             required => 1,
29             );
30              
31             # https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.7.7.1
32             has annotation => (
33             is => 'ro',
34             required => 1,
35             );
36              
37             has unknown => (
38             is => 'ro',
39             isa => Bool,
40             default => 0,
41             );
42              
43             around BUILDARGS => sub ($orig, $class, @args) {
44             my $args = $class->$orig(@args);
45              
46             # undef is not okay for annotations
47             croak 'keyword must be defined' if exists $args->{keyword} and not defined $args->{keyword};
48             return $args;
49             };
50              
51 77     77   163 sub __thing { 'annotation' }
52              
53             1;
54              
55             __END__