| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 42 | if defined $YAML::SpecVersion; | ||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 158 | ▶ | $self->indent_width($YAML::Indent) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 44 | if defined $YAML::Indent; | ||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 158 | ▶ | $self->use_header($YAML::UseHeader) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | if defined $YAML::UseHeader; | ||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 158 | ▶ | $self->use_version($YAML::UseVersion) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if defined $YAML::UseVersion; | ||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 158 | ▶ | $self->sort_keys($YAML::SortKeys) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 50 | if defined $YAML::SortKeys; | ||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 158 | ▶ | $self->anchor_prefix($YAML::AnchorPrefix) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 52 | if defined $YAML::AnchorPrefix; | ||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 158 | ▶ | $self->dump_code($YAML::DumpCode || $YAML::UseCode) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%6/6
defined $YAML::DumpCode or defined $YAML::UseCode
$YAML::DumpCode || $YAML::UseCode
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
Truth table100%3/3
A || B
A= $YAML::DumpCodeB= $YAML::UseCode
| |||||||||||||||||||||||||||||||||||||||||||||||
| 54 | if defined $YAML::DumpCode or defined $YAML::UseCode; | ||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 158 | ▶ | $self->use_block($YAML::UseBlock) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 56 | if defined $YAML::UseBlock; | ||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 158 | ▶ | $self->use_fold($YAML::UseFold) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 58 | if defined $YAML::UseFold; | ||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 158 | ▶ | $self->compress_series($YAML::CompressSeries) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | if defined $YAML::CompressSeries; | ||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 158 | ▶ | $self->inline_series($YAML::InlineSeries) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | if defined $YAML::InlineSeries; | ||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 158 | ▶ | $self->use_aliases($YAML::UseAliases) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 64 | if defined $YAML::UseAliases; | ||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 158 | ▶ | $self->purity($YAML::Purity) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 66 | if defined $YAML::Purity; | ||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 158 | ▶ | $self->stringify($YAML::Stringify) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 68 | if defined $YAML::Stringify; | ||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 158 | ▶ | $self->quote_numeric_strings($YAML::QuoteNumericStrings) | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | my (undef, undef, $node_id) = YAML::Mo::Object->node_info($ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | ▶ | if (not defined $blessing) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | $ynode = YAML::Node->new($ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 95 | elsif (ref $blessing) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | ▶ | $self->die() unless ynode($blessing); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 1 | $ynode = &{$transfer}($ref); | |||||||||||||||||||||||||||||||||||||||||||||
| 104 | 1 | ▶ | $self->die() unless ynode($ynode); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 4 | $self->{blessed_map}->{$node_id} = $ynode; | |||||||||||||||||||||||||||||||||||||||||||||
| 107 | 4 | ▶ | my $object = ynode($ynode) or $self->die(); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 4 | return $object; | |||||||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 34 | 1; | |||||||||||||||||||||||||||||||||||||||||||||