File Coverage

blib/lib/YAML/PP/Perl.pm
Criterion Covered Total %
statement 29 29 100.0
branch n/a
condition 2 2 100.0
subroutine 11 11 100.0
pod 5 5 100.0
total 47 47 100.0


line stmt bran cond sub pod time code
1 3     3   158652 use strict;
  3         4  
  3         105  
2 3     3   11 use warnings;
  3         3  
  3         226  
3             package YAML::PP::Perl;
4              
5             our $VERSION = 'v0.39.0'; # VERSION
6              
7 3     3   15 use base 'Exporter';
  3         6  
  3         278  
8 3     3   12 use base 'YAML::PP';
  3         4  
  3         694  
9             our @EXPORT_OK = qw/ Load Dump LoadFile DumpFile /;
10              
11 3     3   14 use YAML::PP;
  3         4  
  3         86  
12 3     3   1315 use YAML::PP::Schema::Perl;
  3         6  
  3         420  
13              
14             sub new {
15 14     14 1 114 my ($class, %args) = @_;
16 14   100     62 $args{schema} ||= [qw/ Core Perl /];
17 14         67 $class->SUPER::new(%args);
18             }
19              
20             sub Load {
21 2     2 1 5898 my ($yaml) = @_;
22 2         12 __PACKAGE__->new->load_string($yaml);
23             }
24              
25             sub LoadFile {
26 2     2 1 232 my ($file) = @_;
27 2         6 __PACKAGE__->new->load_file($file);
28             }
29              
30             sub Dump {
31 1     1 1 2079 my (@data) = @_;
32 1         6 __PACKAGE__->new->dump_string(@data);
33             }
34              
35             sub DumpFile {
36 1     1 1 930 my ($file, @data) = @_;
37 1         4 __PACKAGE__->new->dump_file($file, @data);
38             }
39              
40             1;
41              
42             __END__
43              
44             =pod
45              
46             =encoding utf-8
47              
48             =head1 NAME
49              
50             YAML::PP::Perl - Convenience module for loading and dumping Perl objects
51              
52             =head1 SYNOPSIS
53              
54             use YAML::PP::Perl;
55             my @docs = YAML::PP::Perl->new->load_string($yaml);
56             my @docs = YAML::PP::Perl::Load($yaml);
57              
58             # same as
59             use YAML::PP;
60             my $yp = YAML::PP->new( schema => [qw/ Core Perl /] );
61             my @docs = $yp->load_string($yaml);
62              
63             =head1 DESCRIPTION
64              
65             This is just for convenience. It will create a YAML::PP object using the
66             default schema (C<Core>) and the L<YAML::PP::Schema::Perl> schema.
67              
68             See L<YAML::PP::Schema::Perl> for documentation.
69              
70             =head1 METHODS
71              
72             =over
73              
74             =item Load, Dump, LoadFile, DumpFile
75              
76             These work like the functions in L<YAML::PP>, just adding the C<Perl> schema.
77              
78             =item new
79              
80             Constructor, works like in L<YAML::PP>, just adds the C<Perl> schema to the
81             list of arguments.
82              
83             =back