Old/Dumper/Base.pm

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