blib/lib/Data/Format/Pretty/YAML.pm

filter: Statementstmt 81.8% 27 / 33 Branchbran 50.0% 2 / 4 Conditioncond 38.8% 7 / 18 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 60.0% 42 / 70 CC 10 SCAR 26.4
CC
10
Cov
65%
format_pretty
19.1
content_type
2.0
BEGIN
1.0
CRAP 14.0
↑ Summary
1 package Data::Format::Pretty::YAML;
2  
3 2 our $DATE = '2014-12-10'; # DATE
4 2 our $VERSION = '0.08'; # VERSION
5  
6 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 2 require Exporter;
11 2 our @ISA = qw(Exporter);
12 2 our @EXPORT_OK = qw(format_pretty);
13  
14 0 ▶sub content_type { "text/yaml" }
Subroutine content_type: not called CC=1 SCAR=6.9
Pod documented
15  
16 1 ▶sub format_pretty {
Subroutine format_pretty: called CC=10 SCAR=29.5
Pod documented
17 1 my ($data, $opts) = @_;
18 1 ▶ $opts //= {};
Condition50%1/2
$opts //= {}
l!l
10
MC/DC0%0/1
$opts //= {}
$opts
Truth table50%1/2
A
A= $opts
Aresult
11
00
19  
20 1 my $interactive = (-t STDOUT);
21 1 ▶ my $pretty = $opts->{pretty} // 1;
Condition50%1/2
$opts->{"pretty"} // 1
l!l
01
MC/DC0%0/1
$opts->{"pretty"} // 1
$opts->{"pretty"}
Truth table50%1/2
A
A= $opts->{"pretty"}
Aresult
11
00
22 my $color = $opts->{color} // $ENV{COLOR} // $interactive //
23 1 ▶ $opts->{pretty};
Condition33%3/9
(($opts->{"color"} // $ENV{"COLOR"}) // $interactive) // $opts->{"pretty"}
l!l&&r!l&&!r
100
($opts->{"color"} // $ENV{"COLOR"}) // $interactive
l!l&&r!l&&!r
010
$opts->{"color"} // $ENV{"COLOR"}
l!l&&r!l&&!r
001
MC/DC0%0/4
(($opts->{"color"} // $ENV{"COLOR"}) // $interactive) // $opts->{"pretty"}
$opts->{"color"} $ENV{"COLOR"} $interactive $opts->{"pretty"}
Truth table20%1/5
A // B // C // D
A= $opts->{"color"}B= $ENV{"COLOR"}C= $interactiveD= $opts->{"pretty"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
24 1 ▶ my $linum = $opts->{linum} // $ENV{LINUM} // 0;
Condition40%2/5
($opts->{"linum"} // $ENV{"LINUM"}) // 0
l!l
01
$opts->{"linum"} // $ENV{"LINUM"}
l!l&&r!l&&!r
001
MC/DC0%0/2
($opts->{"linum"} // $ENV{"LINUM"}) // 0
$opts->{"linum"} $ENV{"LINUM"}
Truth table33%1/3
A // B
A= $opts->{"linum"}B= $ENV{"LINUM"}
ABresult
1X1
011
000
25  
26 1 ▶ if ($color) {
Branch: 1 branch
BranchTrueFalseTotal
if ($color) { } 0 1 1
27 0 require YAML::Tiny::Color;
28 0 local $YAML::Tiny::Color::LineNumber = $linum;
29 0 YAML::Tiny::Color::Dump($data);
30 } else {
31 1 require YAML::Syck;
32 1 local $YAML::Syck::ImplicitTyping = 1;
33 1 local $YAML::Syck::SortKeys = 1;
34 1 local $YAML::Syck::Headless = 1;
35 1 ▶ if ($linum) {
Branch: 1 branch
BranchTrueFalseTotal
if ($linum) { } 0 1 1
36 0 require String::LineNumber;
37 0 String::LineNumber::linenum(YAML::Syck::Dump($data));
38 } else {
39 1 YAML::Syck::Dump($data);
40 }
41 }
42 }
43  
44 2 1;
45 # ABSTRACT: Pretty-print data structure as YAML
46  
47 __END__
↑ Summary