YAML/Dumper/Base.pm

filter: Statementstmt 89.1% 90 / 101 Branchbran 76.0% 35 / 46 Conditioncond 100% 6 / 6 MC/DCmcdc 100% 4 / 4 Subroutinesub 68.7% 22 / 32 Podpod 0.0% 0 / 4 totaltotal 81.3% 157 / 193 CC 26 SCAR 20.2
CC
26
Cov
86%
set_global_options
18.3
bless
8.2
blessed
2.0
CRAP 7.5
« YAML/Dumper.pm ↑ Summary YAML/Types.pm »
1 package YAML::Dumper::Base;
2  
3 34 ▶use YAML::Mo;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 34 ▶use YAML::Node;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 # YAML Dumping options
8 0 ▶has spec_version => default => sub {'1.0'};
Subroutine __ANON__: not called CC=1 SCAR=1.2
9 155 ▶has indent_width => default => sub {2};
Subroutine __ANON__: called CC=1 SCAR=0.0
10 154 ▶has use_header => default => sub {1};
Subroutine __ANON__: called CC=1 SCAR=0.0
11 155 ▶has use_version => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
12 89 ▶has sort_keys => default => sub {1};
Subroutine __ANON__: called CC=1 SCAR=0.0
13 6 ▶has anchor_prefix => default => sub {''};
Subroutine __ANON__: called CC=1 SCAR=0.0
14 1 ▶has dump_code => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
15 23 ▶has use_block => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
16 23 ▶has use_fold => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
17 11 ▶has compress_series => default => sub {1};
Subroutine __ANON__: called CC=1 SCAR=0.0
18 43 ▶has inline_series => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
19 152 ▶has use_aliases => default => sub {1};
Subroutine __ANON__: called CC=1 SCAR=0.0
20 122 ▶has purity => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
21 156 ▶has stringify => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
22 118 ▶has quote_numeric_strings => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
23  
24 # Properties
25 0 ▶has stream => default => sub {''};
Subroutine __ANON__: not called CC=1 SCAR=1.2
26 0 ▶has document => default => sub {0};
Subroutine __ANON__: not called CC=1 SCAR=1.2
27 0 ▶has transferred => default => sub {{}};
Subroutine __ANON__: not called CC=1 SCAR=1.2
28 0 ▶has id_refcnt => default => sub {{}};
Subroutine __ANON__: not called CC=1 SCAR=1.2
29 0 ▶has id_anchor => default => sub {{}};
Subroutine __ANON__: not called CC=1 SCAR=1.2
30 0 ▶has anchor => default => sub {1};
Subroutine __ANON__: not called CC=1 SCAR=1.2
31 0 ▶has level => default => sub {0};
Subroutine __ANON__: not called CC=1 SCAR=1.2
32 158 ▶has offset => default => sub {[]};
Subroutine __ANON__: called CC=1 SCAR=0.0
33 110 ▶has headless => default => sub {0};
Subroutine __ANON__: called CC=1 SCAR=0.0
34 0 ▶has blessed_map => default => sub {{}};
Subroutine __ANON__: not called CC=1 SCAR=1.2
35  
36 # Global Options are an idea taken from Data::Dumper. Really they are just
37 # sugar on top of real OO properties. They make the simple Dump/Load API
38 # easy to configure.
39 158 ▶sub set_global_options {
Subroutine set_global_options: called CC=18 SCAR=29.1
Pod undocumented
40 158 my $self = shift;
41 158 ▶ $self->spec_version($YAML::SpecVersion)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::SpecVersion 0 158 158
42 if defined $YAML::SpecVersion;
43 158 ▶ $self->indent_width($YAML::Indent)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::Indent 3 155 158
44 if defined $YAML::Indent;
45 158 ▶ $self->use_header($YAML::UseHeader)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::UseHeader 4 154 158
46 if defined $YAML::UseHeader;
47 158 ▶ $self->use_version($YAML::UseVersion)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::UseVersion 0 158 158
48 if defined $YAML::UseVersion;
49 158 ▶ $self->sort_keys($YAML::SortKeys)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::SortKeys 1 157 158
50 if defined $YAML::SortKeys;
51 158 ▶ $self->anchor_prefix($YAML::AnchorPrefix)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::AnchorPrefix 0 158 158
52 if defined $YAML::AnchorPrefix;
53 158 ▶ $self->dump_code($YAML::DumpCode || $YAML::UseCode)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::DumpCode or defined $YAML::UseCode 25 133 158
Condition100%6/6
defined $YAML::DumpCode or defined $YAML::UseCode
l!l&&r!l&&!r
1510133
$YAML::DumpCode || $YAML::UseCode
l!l&&r!l&&!r
14101
MC/DC100%2/2
defined $YAML::DumpCode or defined $YAML::UseCode
defined $YAML::DumpCode defined $YAML::UseCode
MC/DC100%2/2
$YAML::DumpCode || $YAML::UseCode
$YAML::DumpCode $YAML::UseCode
Truth table100%3/3
A or B
A= defined $YAML::DumpCodeB= defined $YAML::UseCode
ABresult
1X1
011
000
Truth table100%3/3
A || B
A= $YAML::DumpCodeB= $YAML::UseCode
ABresult
1X1
011
000
54 if defined $YAML::DumpCode or defined $YAML::UseCode;
55 158 ▶ $self->use_block($YAML::UseBlock)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::UseBlock 1 157 158
56 if defined $YAML::UseBlock;
57 158 ▶ $self->use_fold($YAML::UseFold)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::UseFold 0 158 158
58 if defined $YAML::UseFold;
59 158 ▶ $self->compress_series($YAML::CompressSeries)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::CompressSeries 4 154 158
60 if defined $YAML::CompressSeries;
61 158 ▶ $self->inline_series($YAML::InlineSeries)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::InlineSeries 1 157 158
62 if defined $YAML::InlineSeries;
63 158 ▶ $self->use_aliases($YAML::UseAliases)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::UseAliases 1 157 158
64 if defined $YAML::UseAliases;
65 158 ▶ $self->purity($YAML::Purity)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::Purity 0 158 158
66 if defined $YAML::Purity;
67 158 ▶ $self->stringify($YAML::Stringify)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::Stringify 2 156 158
68 if defined $YAML::Stringify;
69 158 ▶ $self->quote_numeric_strings($YAML::QuoteNumericStrings)
Branch: 1 branch
BranchTrueFalseTotal
if defined $YAML::QuoteNumericStrings 3 155 158
70 if defined $YAML::QuoteNumericStrings;
71 }
72  
73 0 ▶sub dump {
Subroutine dump: not called CC=1 SCAR=6.9
Pod undocumented
74 0 my $self = shift;
75 0 $self->die('dump() not implemented in this class.');
76 }
77  
78 1 ▶sub blessed {
Subroutine blessed: called CC=2 SCAR=7.0
Pod undocumented
79 1 my $self = shift;
80 1 my ($ref) = @_;
81 1 ▶ $ref = \$_[0] unless ref $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ref 0 1 1
82 1 my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref);
83 1 $self->{blessed_map}->{$node_id};
84 }
85  
86 4 ▶sub bless {
Subroutine bless: called CC=8 SCAR=21.0
Pod undocumented
87 4 my $self = shift;
88 4 my ($ref, $blessing) = @_;
89 4 my $ynode;
90 4 ▶ $ref = \$_[0] unless ref $ref;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $ref 0 4 4
91 4 my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref);
92 4 ▶ if (not defined $blessing) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $blessing) { } 2 2 4
elsif (ref $blessing) { } 1 1 2
93 2 $ynode = YAML::Node->new($ref);
94 }
95 elsif (ref $blessing) {
96 1 ▶ $self->die() unless ynode($blessing);
Branch: 1 branch
BranchTrueFalseTotal
unless ynode($blessing) 0 1 1
97 1 $ynode = $blessing;
98 }
99 else {
100 34 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
101 1 my $transfer = $blessing . "::yaml_dump";
102 1 ▶ $self->die() unless defined &{$transfer};
Branch: 1 branch
BranchTrueFalseTotal
unless defined &{$transfer;} 0 1 1
103 1 $ynode = &{$transfer}($ref);
104 1 ▶ $self->die() unless ynode($ynode);
Branch: 1 branch
BranchTrueFalseTotal
unless ynode($ynode) 0 1 1
105 }
106 4 $self->{blessed_map}->{$node_id} = $ynode;
107 4 ▶ my $object = ynode($ynode) or $self->die();
Branch: 1 branch
BranchTrueFalseTotal
my $object = ynode($ynode) or $self->die 4 0 4
108 4 return $object;
109 }
110  
111 34 1;
« YAML/Dumper.pm ↑ Summary YAML/Types.pm »