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   321 use strict;
  45         111  
  45         3357  
2 45     45   270 use warnings;
  45         95  
  45         4241  
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.632';
8              
9 45     45   866 use 5.020;
  45         232  
10 45     45   277 use Moo;
  45         93  
  45         313  
11             with 'JSON::Schema::Modern::ResultNode';
12 45     45   19046 use strictures 2;
  45         438  
  45         1869  
13 45     45   22625 use stable 0.031 'postderef';
  45         820  
  45         305  
14 45     45   8329 use experimental 'signatures';
  45         111  
  45         188  
15 45     45   3001 no autovivification warn => qw(fetch store exists delete);
  45         98  
  45         303  
16 45     45   6432 use if "$]" >= 5.022, experimental => 're_strict';
  45         101  
  45         1161  
17 45     45   3937 no if "$]" >= 5.031009, feature => 'indirect';
  45         93  
  45         3051  
18 45     45   359 no if "$]" >= 5.033001, feature => 'multidimensional';
  45         117  
  45         2816  
19 45     45   270 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  45         92  
  45         2717  
20 45     45   264 no if "$]" >= 5.041009, feature => 'smartmatch';
  45         102  
  45         2208  
21 45     45   288 no feature 'switch';
  45         87  
  45         1367  
22 45     45   222 use MooX::TypeTiny;
  45         87  
  45         370  
23 45     45   43222 use Types::Standard 'Bool';
  45         102  
  45         425  
24 45     45   134426 use Carp 'croak';
  45         133  
  45         3613  
25 45     45   322 use namespace::clean;
  45         97  
  45         580  
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   177 sub __thing { 'annotation' }
52              
53             1;
54              
55             __END__