Catmandu/Importer/YAML.pm

filter: Statementstmt 100% 22 / 22 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 96.5% 28 / 29 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Catmandu/Fix/retain_field.pm ↑ Summary Catmandu/Fix/Builder.pm »
1 package Catmandu::Importer::YAML;
2  
3 5 ▶use Catmandu::Sane;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 5 our $VERSION = '1.2025';
6  
7 5 ▶use YAML::XS ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 5 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 5 ▶use Devel::Peek;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 5 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 5 with 'Catmandu::Importer';
13  
14 5 my $RE_EOF = qr'^\.\.\.$';
15 3 my $RE_SEP = qr'^---';
16  
17 5 ▶sub generator {
Subroutine generator: called CC=1 SCAR=0.0
Pod undocumented
18 7 my ($self) = @_;
19 sub {
20 state $fh = $self->fh;
21 state $yaml = "";
22 state $data;
23 state $line;
24 while (defined($line = <$fh>)) {
25 if ($line =~ $RE_EOF) {
26 last;
27 }
28 if ($line =~ $RE_SEP && $yaml) {
29 utf8::encode($yaml);
30 $data = YAML::XS::Load($yaml);
31 $yaml = $line;
32 return $data;
33 }
34 $yaml .= $line;
35 }
36 if ($yaml) {
37 utf8::encode($yaml);
38 $data = YAML::XS::Load($yaml);
39 $yaml = "";
40 return $data;
41 }
42 return;
43 7 };
44 }
45  
46 3 1;
47  
48 __END__
« Catmandu/Fix/retain_field.pm ↑ Summary Catmandu/Fix/Builder.pm »