AsType/Annotations.pm

filter: Statementstmt 100% 33 / 33 Branchbran n/a Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 7 totaltotal 88.1% 52 / 59 CC 3 SCAR 2.4
CC
3
Cov
100%
annotation_for
2.0
add_annotation
2.0
BEGIN
1.0
CRAP 1.3
« AsType/Draft7/Types.pm ↑ Summary AsType/Draft2020_12/Vocabulary/Validation.pm »
1 package JSON::Schema::AsType::Annotations;
2 46 our $AUTHORITY = 'cpan:YANICK';
3 46 $JSON::Schema::AsType::Annotations::VERSION = '1.0.0';
4 # ABSTRACT: Manage scope annotations for schema
5  
6  
7 46 ▶use 5.42.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 46 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 46 ▶use feature qw/ signatures module_true /;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 46 ▶use List::Util qw/ uniq /;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 46 ▶use Hash::Merge qw/ merge /;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 46 ▶use base qw/ Exporter::Tiny /;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 46 our @EXPORT = qw/ add_annotation annotation_scope annotations annotation_for
18 annotation_properties annotation_items annotation_merge /;
19  
20 46 our %ANNOTATIONS;
21  
22 2283 ▶sub annotations {
Subroutine annotations: called CC=1 SCAR=0.0
Pod undocumented
23 2283 return {%ANNOTATIONS};
24 }
25  
26 109949 ▶sub annotation_scope($sub) {
Subroutine annotation_scope: called CC=1 SCAR=0.0
Pod undocumented
27 109949 local %ANNOTATIONS = ();
28 109949 return $sub->();
29 }
30  
31 2382 ▶sub annotation_for($cat) {
Subroutine annotation_for: called CC=2 SCAR=6.9
Pod undocumented
32 2382 ▶ return $ANNOTATIONS{$cat} // [];
Condition100%2/2
$JSON::Schema::AsType::Annotations::ANNOTATIONS{$cat} // []
l!l
5151867
MC/DC100%1/1
$JSON::Schema::AsType::Annotations::ANNOTATIONS{$cat} // []
$JSON::Schema::AsType::Annotations::ANNOTATIONS{$cat}
Truth table100%2/2
A
A= $JSON::Schema::AsType::Annotations::ANNOTATIONS{$cat}
Aresult
11
00
33 }
34  
35 319 ▶sub annotation_properties() {
Subroutine annotation_properties: called CC=1 SCAR=0.0
Pod undocumented
36 319 return uniq map { annotation_for($_)->@* }
37 qw/ properties patternProperties additionalProperties unevaluatedProperties /;
38  
39 }
40  
41 213 ▶sub annotation_items() {
Subroutine annotation_items: called CC=1 SCAR=0.0
Pod undocumented
42 213 return uniq map { annotation_for($_)->@* }
43 qw/ items patternItems prefixItems unevaluatedItems contains /;
44  
45 }
46  
47 47911 ▶sub add_annotation( $category, @values ) {
Subroutine add_annotation: called CC=2 SCAR=6.9
Pod undocumented
48 47911 ▶ $ANNOTATIONS{$category} //= [];
Condition100%2/2
$JSON::Schema::AsType::Annotations::ANNOTATIONS{$category} //= []
l!l
2406123850
MC/DC100%1/1
$JSON::Schema::AsType::Annotations::ANNOTATIONS{$category} //= []
$JSON::Schema::AsType::Annotations::ANNOTATIONS{$category}
Truth table100%2/2
A
A= $JSON::Schema::AsType::Annotations::ANNOTATIONS{$category}
Aresult
11
00
49 47911 $ANNOTATIONS{$category} = [ uniq $ANNOTATIONS{$category}->@*, @values ];
50 }
51  
52 2282 ▶sub annotation_merge($to_merge) {
Subroutine annotation_merge: called CC=1 SCAR=0.0
Pod undocumented
53 2282 %ANNOTATIONS = merge( \%ANNOTATIONS, $to_merge )->%*;
54 2282 return annotations();
55 }
56  
57 __END__
« AsType/Draft7/Types.pm ↑ Summary AsType/Draft2020_12/Vocabulary/Validation.pm »