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   248 use strict;
  45         73  
  45         1473  
2 45     45   175 use warnings;
  45         66  
  45         3143  
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.637';
8              
9 45     45   630 use 5.020;
  45         137  
10 45     45   150 use Moo;
  45         67  
  45         212  
11             with 'JSON::Schema::Modern::ResultNode';
12 45     45   12679 use strictures 2;
  45         275  
  45         1369  
13 45     45   14636 use stable 0.031 'postderef';
  45         559  
  45         237  
14 45     45   5511 use experimental 'signatures';
  45         65  
  45         122  
15 45     45   1829 no autovivification warn => qw(fetch store exists delete);
  45         72  
  45         217  
16 45     45   2498 use if "$]" >= 5.022, experimental => 're_strict';
  45         72  
  45         814  
17 45     45   2535 no if "$]" >= 5.031009, feature => 'indirect';
  45         89  
  45         1970  
18 45     45   169 no if "$]" >= 5.033001, feature => 'multidimensional';
  45         69  
  45         1709  
19 45     45   162 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  45         73  
  45         1554  
20 45     45   173 no if "$]" >= 5.041009, feature => 'smartmatch';
  45         59  
  45         1204  
21 45     45   163 no feature 'switch';
  45         69  
  45         814  
22 45     45   136 use MooX::TypeTiny;
  45         69  
  45         249  
23 45     45   30371 use Types::Standard 'Bool';
  45         76  
  45         289  
24 45     45   94788 use Carp 'croak';
  45         78  
  45         2633  
25 45     45   216 use namespace::clean;
  45         85  
  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   146 sub __thing { 'annotation' }
52              
53             1;
54              
55             __END__