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   140462 use strict;
  4         10  
  4         146  
2 4     4   16 use warnings;
  4         6  
  4         1113  
3             package YAML::PP::Schema::Failsafe;
4              
5             our $VERSION = 'v0.39.0'; # VERSION
6              
7             sub register {
8 3     3 1 32 my ($self, %args) = @_;
9 3         6 my $schema = $args{schema};
10              
11             $schema->add_resolver(
12             tag => 'tag:yaml.org,2002:str',
13 3     176   22 match => [ all => sub { $_[1]->{value} } ],
  176         625  
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         15 return;
33             }
34              
35             1;
36              
37             __END__
38              
39             =pod
40              
41             =encoding utf-8
42              
43             =head1 NAME
44              
45             YAML::PP::Schema::Failsafe - YAML 1.2 Failsafe Schema
46              
47             =head1 SYNOPSIS
48              
49             my $yp = YAML::PP->new( schema => ['Failsafe'] );
50              
51             =head1 DESCRIPTION
52              
53             With this schema, everything will be treated as a string. There are no booleans,
54             integers, floats or undefined values.
55              
56             Here you can see all Schemas and examples implemented by YAML::PP:
57             L<https://perlpunk.github.io/YAML-PP-p5/schemas.html>
58              
59             Official Schema: L<https://yaml.org/spec/1.2/spec.html#id2802346>
60              
61             =head1 METHODS
62              
63             =over
64              
65             =item register
66              
67             Called by YAML::PP::Schema
68              
69             =back
70              
71             =cut