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   325 use strict;
  45         110  
  45         2090  
2 45     45   285 use warnings;
  45         91  
  45         4139  
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.634';
8              
9 45     45   826 use 5.020;
  45         182  
10 45     45   251 use Moo;
  45         98  
  45         310  
11             with 'JSON::Schema::Modern::ResultNode';
12 45     45   19549 use strictures 2;
  45         414  
  45         1951  
13 45     45   23253 use stable 0.031 'postderef';
  45         899  
  45         361  
14 45     45   8665 use experimental 'signatures';
  45         110  
  45         195  
15 45     45   2988 no autovivification warn => qw(fetch store exists delete);
  45         124  
  45         334  
16 45     45   3735 use if "$]" >= 5.022, experimental => 're_strict';
  45         105  
  45         1197  
17 45     45   3842 no if "$]" >= 5.031009, feature => 'indirect';
  45         115  
  45         3149  
18 45     45   291 no if "$]" >= 5.033001, feature => 'multidimensional';
  45         94  
  45         2825  
19 45     45   268 no if "$]" >= 5.033006, feature => 'bareword_filehandles';
  45         98  
  45         2685  
20 45     45   257 no if "$]" >= 5.041009, feature => 'smartmatch';
  45         94  
  45         2137  
21 45     45   276 no feature 'switch';
  45         100  
  45         1446  
22 45     45   248 use MooX::TypeTiny;
  45         96  
  45         383  
23 45     45   44911 use Types::Standard 'Bool';
  45         115  
  45         418  
24 45     45   135904 use Carp 'croak';
  45         130  
  45         3717  
25 45     45   337 use namespace::clean;
  45         109  
  45         500  
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   187 sub __thing { 'annotation' }
52              
53             1;
54              
55             __END__