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 46     46   254 use strict;
  46         78  
  46         1524  
2 46     46   184 use warnings;
  46         72  
  46         3096  
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.641';
8              
9 46     46   609 use 5.020;
  46         144  
10 46     46   152 use Moo;
  46         78  
  46         219  
11             with 'JSON::Schema::Modern::ResultNode';
12 46     46   12994 use strictures 2;
  46         258  
  46         1381  
13 46     46   14478 use stable 0.031 'postderef';
  46         548  
  46         208  
14 46     46   5368 use experimental 'signatures';
  46         86  
  46         145  
15 46     46   1782 no autovivification warn => qw(fetch store exists delete);
  46         69  
  46         225  
16 46     46   2359 use if "$]" >= 5.022, experimental => 're_strict';
  46         76  
  46         747  
17 46     46   2427 no if "$]" >= 5.031009, feature => 'indirect';
  46         68  
  46         2098  
18 46     46   185 no if "$]" >= 5.033001, feature => 'multidimensional';
  46         65  
  46         1981  
19 46     46   214 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  46         75  
  46         1857  
20 46     46   201 no if "$]" >= 5.041009, feature => 'smartmatch';
  46         89  
  46         1386  
21 46     46   165 no feature 'switch';
  46         62  
  46         1017  
22 46     46   152 use MooX::TypeTiny;
  46         66  
  46         296  
23 46     46   29272 use Types::Standard 'Bool';
  46         74  
  46         295  
24 46     46   95629 use Carp 'croak';
  46         108  
  46         2507  
25 46     46   250 use namespace::clean;
  46         101  
  46         432  
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   151 sub __thing { 'annotation' }
52              
53             1;
54              
55             __END__