| 1 | 36 | ▶ | use strict; use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | package YAML::Old::Node; | ||||||||||||||||||
| 3 | |||||||||||||||||||
| 4 | 36 | ▶ | use YAML::Old::Tag; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | 36 | require YAML::Old::Mo; | |||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | 36 | ▶ | use Exporter; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 8 | 36 | our @ISA = qw(Exporter YAML::Old::Mo::Object); | |||||||||||||||||
| 9 | 36 | our @EXPORT = qw(ynode); | |||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | sub ynode { | ||||||||||||||||||
| 12 | 1820 | ▶ | my $self; | ||||||||||||||||
|
Subroutine
ynode: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||
| 13 | 1820 | ▶ | if (ref($_[0]) eq 'HASH') { | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 14 | 845 | $self = tied(%{$_[0]}); | |||||||||||||||||
| 15 | } | ||||||||||||||||||
| 16 | elsif (ref($_[0]) eq 'ARRAY') { | ||||||||||||||||||
| 17 | 58 | $self = tied(@{$_[0]}); | |||||||||||||||||
| 18 | } | ||||||||||||||||||
| 19 | elsif (ref(\$_[0]) eq 'GLOB') { | ||||||||||||||||||
| 20 | 0 | $self = tied(*{$_[0]}); | |||||||||||||||||
| 21 | } | ||||||||||||||||||
| 22 | else { | ||||||||||||||||||
| 23 | 917 | $self = tied($_[0]); | |||||||||||||||||
| 24 | } | ||||||||||||||||||
| 25 | 1820 | ▶ | return (ref($self) =~ /^yaml_/) ? $self : undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 26 | } | ||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | sub new { | ||||||||||||||||||
| 29 | 90 | ▶ | my ($class, $node, $tag) = @_; | ||||||||||||||||
|
Subroutine
new: called CC=6 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||
| 30 | 90 | my $self; | |||||||||||||||||
| 31 | 90 | $self->{NODE} = $node; | |||||||||||||||||
| 32 | 90 | my (undef, $type) = YAML::Old::Mo::Object->node_info($node); | |||||||||||||||||
| 33 | 90 | ▶ | $self->{KIND} = (not defined $type) ? 'scalar' : | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 34 | ($type eq 'ARRAY') ? 'sequence' : | ||||||||||||||||||
| 35 | ($type eq 'HASH') ? 'mapping' : | ||||||||||||||||||
| 36 | $class->die("Can't create YAML::Old::Node from '$type'"); | ||||||||||||||||||
| 37 | 90 | ▶ | tag($self, ($tag || '')); | ||||||||||||||||
|
Condition100%2/2
$tag || ''
MC/DC100%1/1
$tag || ''
$tag
Truth table100%2/2
A
A= $tag
| |||||||||||||||||||
| 38 | 90 | ▶ | if ($self->{KIND} eq 'scalar') { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 39 | 13 | yaml_scalar->new($self, $_[1]); | |||||||||||||||||
| 40 | 13 | return \ $_[1]; | |||||||||||||||||
| 41 | } | ||||||||||||||||||
| 42 | 77 | my $package = "yaml_" . $self->{KIND}; | |||||||||||||||||
| 43 | 77 | $package->new($self) | |||||||||||||||||
| 44 | } | ||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 0 | ▶ | sub node { $_->{NODE} } | ||||||||||||||||
|
Subroutine
node: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 47 | 0 | ▶ | sub kind { $_->{KIND} } | ||||||||||||||||
|
Subroutine
kind: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 48 | sub tag { | ||||||||||||||||||
| 49 | 181 | ▶ | my ($self, $value) = @_; | ||||||||||||||||
|
Subroutine
tag: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||
| 50 | 181 | ▶ | if (defined $value) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 51 | 90 | $self->{TAG} = YAML::Old::Tag->new($value); | |||||||||||||||||
| 52 | 90 | return $self; | |||||||||||||||||
| 53 | } | ||||||||||||||||||
| 54 | else { | ||||||||||||||||||
| 55 | 91 | return $self->{TAG}; | |||||||||||||||||
| 56 | } | ||||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | sub keys { | ||||||||||||||||||
| 59 | 6 | ▶ | my ($self, $value) = @_; | ||||||||||||||||
|
Subroutine
keys: called CC=2 SCAR=7.4
Pod
undocumented
| |||||||||||||||||||
| 60 | 6 | ▶ | if (defined $value) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 61 | 6 | $self->{KEYS} = $value; | |||||||||||||||||
| 62 | 6 | return $self; | |||||||||||||||||
| 63 | } | ||||||||||||||||||
| 64 | else { | ||||||||||||||||||
| 65 | 0 | return $self->{KEYS}; | |||||||||||||||||
| 66 | } | ||||||||||||||||||
| 67 | } | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | #============================================================================== | ||||||||||||||||||
| 70 | package | ||||||||||||||||||
| 71 | yaml_scalar; | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 36 | @yaml_scalar::ISA = qw(YAML::Old::Node); | |||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | sub new { | ||||||||||||||||||
| 76 | 13 | ▶ | my ($class, $self) = @_; | ||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 77 | 13 | tie $_[2], $class, $self; | |||||||||||||||||
| 78 | } | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | sub TIESCALAR { | ||||||||||||||||||
| 81 | 13 | ▶ | my ($class, $self) = @_; | ||||||||||||||||
|
Subroutine
TIESCALAR: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 82 | 13 | bless $self, $class; | |||||||||||||||||
| 83 | 13 | $self | |||||||||||||||||
| 84 | } | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | sub FETCH { | ||||||||||||||||||
| 87 | 66 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 88 | $self->{NODE} | ||||||||||||||||||
| 89 | 66 | } | |||||||||||||||||
| 90 | |||||||||||||||||||
| 91 | sub STORE { | ||||||||||||||||||
| 92 | 0 | ▶ | my ($self, $value) = @_; | ||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 93 | 0 | $self->{NODE} = $value | |||||||||||||||||
| 94 | } | ||||||||||||||||||
| 95 | |||||||||||||||||||
| 96 | #============================================================================== | ||||||||||||||||||
| 97 | package | ||||||||||||||||||
| 98 | yaml_sequence; | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | 36 | @yaml_sequence::ISA = qw(YAML::Old::Node); | |||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | sub new { | ||||||||||||||||||
| 103 | 10 | ▶ | my ($class, $self) = @_; | ||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 104 | 10 | my $new; | |||||||||||||||||
| 105 | 10 | tie @$new, $class, $self; | |||||||||||||||||
| 106 | 10 | $new | |||||||||||||||||
| 107 | } | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | sub TIEARRAY { | ||||||||||||||||||
| 110 | 10 | ▶ | my ($class, $self) = @_; | ||||||||||||||||
|
Subroutine
TIEARRAY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 111 | 10 | bless $self, $class | |||||||||||||||||
| 112 | } | ||||||||||||||||||
| 113 | |||||||||||||||||||
| 114 | sub FETCHSIZE { | ||||||||||||||||||
| 115 | 52 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
FETCHSIZE: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 116 | 52 | scalar @{$self->{NODE}}; | |||||||||||||||||
| 117 | } | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | sub FETCH { | ||||||||||||||||||
| 120 | 36 | ▶ | my ($self, $index) = @_; | ||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 121 | 36 | $self->{NODE}[$index] | |||||||||||||||||
| 122 | } | ||||||||||||||||||
| 123 | |||||||||||||||||||
| 124 | sub STORE { | ||||||||||||||||||
| 125 | 0 | ▶ | my ($self, $index, $value) = @_; | ||||||||||||||||
|
Subroutine
STORE: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 126 | 0 | $self->{NODE}[$index] = $value | |||||||||||||||||
| 127 | } | ||||||||||||||||||
| 128 | |||||||||||||||||||
| 129 | sub undone { | ||||||||||||||||||
| 130 | 0 | ▶ | die "Not implemented yet"; # XXX | ||||||||||||||||
|
Subroutine
undone: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 131 | } | ||||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | 36 | *STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS = | |||||||||||||||||
| 134 | *STORESIZE = *POP = *PUSH = *SHIFT = *UNSHIFT = *SPLICE = *DELETE = *EXISTS = | ||||||||||||||||||
| 135 | *undone; # XXX Must implement before release | ||||||||||||||||||
| 136 | |||||||||||||||||||
| 137 | #============================================================================== | ||||||||||||||||||
| 138 | package | ||||||||||||||||||
| 139 | yaml_mapping; | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | 36 | @yaml_mapping::ISA = qw(YAML::Old::Node); | |||||||||||||||||
| 142 | |||||||||||||||||||
| 143 | sub new { | ||||||||||||||||||
| 144 | 67 | ▶ | my ($class, $self) = @_; | ||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 145 | 67 | @{$self->{KEYS}} = sort keys %{$self->{NODE}}; | |||||||||||||||||
| 146 | 67 | my $new; | |||||||||||||||||
| 147 | 67 | tie %$new, $class, $self; | |||||||||||||||||
| 148 | 67 | $new | |||||||||||||||||
| 149 | } | ||||||||||||||||||
| 150 | |||||||||||||||||||
| 151 | sub TIEHASH { | ||||||||||||||||||
| 152 | 67 | ▶ | my ($class, $self) = @_; | ||||||||||||||||
|
Subroutine
TIEHASH: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 153 | 67 | bless $self, $class | |||||||||||||||||
| 154 | } | ||||||||||||||||||
| 155 | |||||||||||||||||||
| 156 | sub FETCH { | ||||||||||||||||||
| 157 | 204 | ▶ | my ($self, $key) = @_; | ||||||||||||||||
|
Subroutine
FETCH: called CC=3 SCAR=11.0
| |||||||||||||||||||
| 158 | 204 | ▶ | if (exists $self->{NODE}{$key}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 159 | 311 | return (grep {$_ eq $key} @{$self->{KEYS}}) | |||||||||||||||||
| 160 | 159 | ▶ | ? $self->{NODE}{$key} : undef; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 161 | } | ||||||||||||||||||
| 162 | 45 | return $self->{HASH}{$key}; | |||||||||||||||||
| 163 | } | ||||||||||||||||||
| 164 | |||||||||||||||||||
| 165 | sub STORE { | ||||||||||||||||||
| 166 | 24 | ▶ | my ($self, $key, $value) = @_; | ||||||||||||||||
|
Subroutine
STORE: called CC=4 SCAR=13.9
| |||||||||||||||||||
| 167 | 24 | ▶ | if (exists $self->{NODE}{$key}) { | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 168 | 1 | $self->{NODE}{$key} = $value; | |||||||||||||||||
| 169 | } | ||||||||||||||||||
| 170 | elsif (exists $self->{HASH}{$key}) { | ||||||||||||||||||
| 171 | 0 | $self->{HASH}{$key} = $value; | |||||||||||||||||
| 172 | } | ||||||||||||||||||
| 173 | else { | ||||||||||||||||||
| 174 | 23 | ▶ | if (not grep {$_ eq $key} @{$self->{KEYS}}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 175 | 22 | push(@{$self->{KEYS}}, $key); | |||||||||||||||||
| 176 | } | ||||||||||||||||||
| 177 | 23 | $self->{HASH}{$key} = $value; | |||||||||||||||||
| 178 | } | ||||||||||||||||||
| 179 | 24 | $value | |||||||||||||||||
| 180 | } | ||||||||||||||||||
| 181 | |||||||||||||||||||
| 182 | sub DELETE { | ||||||||||||||||||
| 183 | 1 | ▶ | my ($self, $key) = @_; | ||||||||||||||||
|
Subroutine
DELETE: called CC=5 SCAR=16.6
| |||||||||||||||||||
| 184 | 1 | my $return; | |||||||||||||||||
| 185 | 1 | ▶ | if (exists $self->{NODE}{$key}) { | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 186 | 1 | $return = $self->{NODE}{$key}; | |||||||||||||||||
| 187 | } | ||||||||||||||||||
| 188 | elsif (exists $self->{HASH}{$key}) { | ||||||||||||||||||
| 189 | 0 | $return = delete $self->{NODE}{$key}; | |||||||||||||||||
| 190 | } | ||||||||||||||||||
| 191 | 1 | ▶ | for (my $i = 0; $i < @{$self->{KEYS}}; $i++) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 192 | 3 | ▶ | if ($self->{KEYS}[$i] eq $key) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 193 | 1 | splice(@{$self->{KEYS}}, $i, 1); | |||||||||||||||||
| 194 | } | ||||||||||||||||||
| 195 | } | ||||||||||||||||||
| 196 | 1 | return $return; | |||||||||||||||||
| 197 | } | ||||||||||||||||||
| 198 | |||||||||||||||||||
| 199 | sub CLEAR { | ||||||||||||||||||
| 200 | 0 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
CLEAR: not called CC=1 SCAR=6.9
| |||||||||||||||||||
| 201 | 0 | @{$self->{KEYS}} = (); | |||||||||||||||||
| 202 | 0 | %{$self->{HASH}} = (); | |||||||||||||||||
| 203 | } | ||||||||||||||||||
| 204 | |||||||||||||||||||
| 205 | sub FIRSTKEY { | ||||||||||||||||||
| 206 | 181 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 207 | 181 | $self->{ITER} = 0; | |||||||||||||||||
| 208 | 181 | $self->{KEYS}[0] | |||||||||||||||||
| 209 | } | ||||||||||||||||||
| 210 | |||||||||||||||||||
| 211 | sub NEXTKEY { | ||||||||||||||||||
| 212 | 301 | ▶ | my ($self) = @_; | ||||||||||||||||
|
Subroutine
NEXTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 213 | 301 | $self->{KEYS}[++$self->{ITER}] | |||||||||||||||||
| 214 | } | ||||||||||||||||||
| 215 | |||||||||||||||||||
| 216 | sub EXISTS { | ||||||||||||||||||
| 217 | 59 | ▶ | my ($self, $key) = @_; | ||||||||||||||||
|
Subroutine
EXISTS: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 218 | 59 | exists $self->{NODE}{$key} | |||||||||||||||||
| 219 | } | ||||||||||||||||||
| 220 | |||||||||||||||||||
| 221 | 36 | 1; | |||||||||||||||||