| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# ABSTRACT: Load YAML into data with Parser and Constructor |
|
2
|
42
|
|
|
42
|
|
332952
|
use strict; |
|
|
42
|
|
|
|
|
68
|
|
|
|
42
|
|
|
|
|
1356
|
|
|
3
|
42
|
|
|
42
|
|
176
|
use warnings; |
|
|
42
|
|
|
|
|
206
|
|
|
|
42
|
|
|
|
|
2607
|
|
|
4
|
|
|
|
|
|
|
package YAML::PP::Loader; |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 'v0.39.0'; # VERSION |
|
7
|
|
|
|
|
|
|
|
|
8
|
42
|
|
|
42
|
|
18533
|
use YAML::PP::Parser; |
|
|
42
|
|
|
|
|
131
|
|
|
|
42
|
|
|
|
|
1584
|
|
|
9
|
42
|
|
|
42
|
|
18522
|
use YAML::PP::Constructor; |
|
|
42
|
|
|
|
|
111
|
|
|
|
42
|
|
|
|
|
1195
|
|
|
10
|
42
|
|
|
42
|
|
240
|
use YAML::PP::Reader; |
|
|
42
|
|
|
|
|
55
|
|
|
|
42
|
|
|
|
|
18858
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
756
|
|
|
756
|
0
|
352499
|
my ($class, %args) = @_; |
|
14
|
|
|
|
|
|
|
|
|
15
|
756
|
|
100
|
|
|
2222
|
my $cyclic_refs = delete $args{cyclic_refs} || 'fatal'; |
|
16
|
756
|
|
100
|
|
|
1852
|
my $default_yaml_version = delete $args{default_yaml_version} || '1.2'; |
|
17
|
756
|
|
|
|
|
1213
|
my $preserve = delete $args{preserve}; |
|
18
|
756
|
|
|
|
|
1261
|
my $duplicate_keys = delete $args{duplicate_keys}; |
|
19
|
756
|
|
|
|
|
1133
|
my $require_footer = delete $args{require_footer}; |
|
20
|
756
|
|
|
|
|
1123
|
my $schemas = delete $args{schemas}; |
|
21
|
756
|
|
100
|
|
|
1360
|
$schemas ||= { |
|
22
|
|
|
|
|
|
|
'1.2' => YAML::PP->default_schema( |
|
23
|
|
|
|
|
|
|
boolean => 'perl', |
|
24
|
|
|
|
|
|
|
) |
|
25
|
|
|
|
|
|
|
}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
756
|
|
66
|
|
|
3979
|
my $constructor = delete $args{constructor} || YAML::PP::Constructor->new( |
|
28
|
|
|
|
|
|
|
schemas => $schemas, |
|
29
|
|
|
|
|
|
|
cyclic_refs => $cyclic_refs, |
|
30
|
|
|
|
|
|
|
default_yaml_version => $default_yaml_version, |
|
31
|
|
|
|
|
|
|
preserve => $preserve, |
|
32
|
|
|
|
|
|
|
duplicate_keys => $duplicate_keys, |
|
33
|
|
|
|
|
|
|
require_footer => $require_footer, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
755
|
|
|
|
|
1084
|
my $parser = delete $args{parser}; |
|
36
|
755
|
50
|
|
|
|
1530
|
unless ($parser) { |
|
37
|
755
|
|
|
|
|
2784
|
$parser = YAML::PP::Parser->new( |
|
38
|
|
|
|
|
|
|
default_yaml_version => $default_yaml_version, |
|
39
|
|
|
|
|
|
|
); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
755
|
50
|
|
|
|
1683
|
unless ($parser->receiver) { |
|
42
|
755
|
|
|
|
|
1725
|
$parser->set_receiver($constructor); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
|
|
45
|
755
|
100
|
|
|
|
1564
|
if (keys %args) { |
|
46
|
1
|
|
|
|
|
51
|
die "Unexpected arguments: " . join ', ', sort keys %args; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
754
|
|
|
|
|
1924
|
my $self = bless { |
|
49
|
|
|
|
|
|
|
parser => $parser, |
|
50
|
|
|
|
|
|
|
constructor => $constructor, |
|
51
|
|
|
|
|
|
|
}, $class; |
|
52
|
754
|
|
|
|
|
1810
|
return $self; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub clone { |
|
56
|
9
|
|
|
9
|
0
|
14
|
my ($self) = @_; |
|
57
|
9
|
|
|
|
|
18
|
my $clone = { |
|
58
|
|
|
|
|
|
|
parser => $self->parser->clone, |
|
59
|
|
|
|
|
|
|
constructor => $self->constructor->clone, |
|
60
|
|
|
|
|
|
|
}; |
|
61
|
9
|
|
|
|
|
23
|
bless $clone, ref $self; |
|
62
|
9
|
|
|
|
|
15
|
$clone->parser->set_receiver($clone->constructor); |
|
63
|
9
|
|
|
|
|
20
|
return $clone; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
4415
|
|
|
4415
|
0
|
10487
|
sub parser { return $_[0]->{parser} } |
|
67
|
2219
|
|
|
2219
|
0
|
3166
|
sub constructor { return $_[0]->{constructor} } |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub filename { |
|
70
|
3
|
|
|
3
|
0
|
107
|
my ($self) = @_; |
|
71
|
3
|
|
|
|
|
5
|
my $reader = $self->parser->reader; |
|
72
|
3
|
50
|
|
|
|
19
|
if ($reader->isa('YAML::PP::Reader::File')) { |
|
73
|
3
|
|
|
|
|
10
|
return $reader->input; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
0
|
|
|
|
|
0
|
die "Reader is not a YAML::PP::Reader::File"; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub load_string { |
|
79
|
2178
|
|
|
2178
|
0
|
6527
|
my ($self, $yaml) = @_; |
|
80
|
2178
|
|
|
|
|
4497
|
$self->parser->set_reader(YAML::PP::Reader->new( input => $yaml )); |
|
81
|
2178
|
|
|
|
|
5347
|
$self->load(); |
|
82
|
|
|
|
|
|
|
} |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub load_file { |
|
85
|
19
|
|
|
19
|
0
|
32
|
my ($self, $file) = @_; |
|
86
|
19
|
|
|
|
|
33
|
$self->parser->set_reader(YAML::PP::Reader::File->new( input => $file )); |
|
87
|
19
|
|
|
|
|
45
|
$self->load(); |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub load { |
|
91
|
2197
|
|
|
2197
|
0
|
3203
|
my ($self) = @_; |
|
92
|
2197
|
|
|
|
|
3146
|
my $parser = $self->parser; |
|
93
|
2197
|
|
|
|
|
3877
|
my $constructor = $self->constructor; |
|
94
|
|
|
|
|
|
|
|
|
95
|
2197
|
|
|
|
|
6062
|
$constructor->init; |
|
96
|
2197
|
|
|
|
|
5753
|
$parser->parse(); |
|
97
|
|
|
|
|
|
|
|
|
98
|
2166
|
|
|
|
|
3749
|
my $docs = $constructor->docs; |
|
99
|
2166
|
100
|
|
|
|
10666
|
return wantarray ? @$docs : $docs->[0]; |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
1; |