File Coverage

blib/lib/YAML/PP/Schema/Failsafe.pm
Criterion Covered Total %
statement 13 18 72.2
branch n/a
condition n/a
subroutine 4 6 66.6
pod 1 1 100.0
total 18 25 72.0


line stmt bran cond sub pod time code
1 4     4   141726 use strict;
  4         6  
  4         161  
2 4     4   18 use warnings;
  4         7  
  4         1072  
3             package YAML::PP::Schema::Failsafe;
4              
5             our $VERSION = 'v0.40.0'; # VERSION
6              
7             sub register {
8 3     3 1 12 my ($self, %args) = @_;
9 3         26 my $schema = $args{schema};
10              
11             $schema->add_resolver(
12             tag => 'tag:yaml.org,2002:str',
13 3     176   20 match => [ all => sub { $_[1]->{value} } ],
  176         631  
14             );
15             $schema->add_sequence_resolver(
16             tag => 'tag:yaml.org,2002:seq',
17             on_data => sub {
18 0     0   0 my ($constructor, $ref, $list) = @_;
19 0         0 push @$$ref, @$list;
20             },
21 3         17 );
22             $schema->add_mapping_resolver(
23             tag => 'tag:yaml.org,2002:map',
24             on_data => sub {
25 0     0   0 my ($constructor, $ref, $list) = @_;
26 0         0 for (my $i = 0; $i < @$list; $i += 2) {
27 0         0 $$ref->{ $list->[ $i ] } = $list->[ $i + 1 ];
28             }
29             },
30 3         14 );
31              
32 3         16 return;
33             }
34              
35             1;
36              
37             __END__