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   326 use strict;
  45         79  
  45         1447  
2 45     45   172 use warnings;
  45         70  
  45         2823  
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.635';
8              
9 45     45   620 use 5.020;
  45         130  
10 45     45   168 use Moo;
  45         60  
  45         205  
11             with 'JSON::Schema::Modern::ResultNode';
12 45     45   12427 use strictures 2;
  45         240  
  45         1256  
13 45     45   14270 use stable 0.031 'postderef';
  45         543  
  45         191  
14 45     45   5225 use experimental 'signatures';
  45         64  
  45         129  
15 45     45   1807 no autovivification warn => qw(fetch store exists delete);
  45         59  
  45         185  
16 45     45   2317 use if "$]" >= 5.022, experimental => 're_strict';
  45         68  
  45         727  
17 45     45   2496 no if "$]" >= 5.031009, feature => 'indirect';
  45         68  
  45         1887  
18 45     45   158 no if "$]" >= 5.033001, feature => 'multidimensional';
  45         82  
  45         1557  
19 45     45   191 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  45         66  
  45         1651  
20 45     45   159 no if "$]" >= 5.041009, feature => 'smartmatch';
  45         52  
  45         1146  
21 45     45   162 no feature 'switch';
  45         78  
  45         792  
22 45     45   138 use MooX::TypeTiny;
  45         77  
  45         228  
23 45     45   43674 use Types::Standard 'Bool';
  45         74  
  45         304  
24 45     45   94635 use Carp 'croak';
  45         81  
  45         2569  
25 45     45   223 use namespace::clean;
  45         71  
  45         433  
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   158 sub __thing { 'annotation' }
52              
53             1;
54              
55             __END__