lib/MKDoc/XML/Dumper.pm

filter: Statementstmt 99.4% 194 / 195 Branchbran 82.9% 68 / 82 Conditioncond 77.5% 69 / 89 MC/DCmcdc 32.5% 13 / 40 Subroutinesub 100% 27 / 27 Podpod 5.0% 1 / 20 totaltotal 82.1% 372 / 453 CC 76 SCAR 17.7
CC
76
Cov
90%
xml_to_perl
9.2
xml_to_perl_hash
9.0
xml2perl
9.0
CRAP 5.9
« lib/MKDoc/XML/TreePrinter.pm ↑ Summary lib/MKDoc/XML/Stripper.pm »
1 # -------------------------------------------------------------------------------------
2 # MKDoc::XML::Dumper
3 # -------------------------------------------------------------------------------------
4 # Author : Jean-Michel Hiver.
5 # Copyright : (c) MKDoc Holdings Ltd, 2003
6 #
7 # This module serializes / dumps / freezes Perl structures to a well-formed XML string
8 # and deserializes / undumps / thaws them back from XML to Perl.
9 #
10 # This module is distributed under the same license as Perl itself.
11 # -------------------------------------------------------------------------------------
12 package MKDoc::XML::Dumper;
13 5 ▶use MKDoc::XML::Encode;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 5 ▶use MKDoc::XML::Decode;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 5 ▶use MKDoc::XML::TreeBuilder;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 5 ▶use Scalar::Util;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 5 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 5 ▶use vars qw /$IndentLevel $BackRef/;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 5 our $Compat = 0;
22  
23 sub xml2perl
24 20 ▶{
Subroutine xml2perl: called CC=8 SCAR=22.0
Pod undocumented
25 20 my $class = shift;
26 20 my $xml = shift;
27 20 my (@tree) = MKDoc::XML::TreeBuilder->process_data ($xml);
28 20 ▶ while ( (@tree and not ref $tree[0] and $tree[0] =~ /^(\s|\n|\r)*$/) or
Branch: 1 branch
BranchTrueFalseTotal
if (@tree and not ref $tree[0] and $tree[0] =~ /^(\s|\n|\r)*$/ or @tree and ref $tree[0] and $tree[0]{"_tag"} and $tree[0]{"_tag"} eq "~pi") 2 20 22
Condition61%11/18
@tree and not ref $tree[0] and $tree[0] =~ /^(\s|\n|\r)*$/ or @tree and ref $tree[0] and $tree[0]{"_tag"} and $tree[0]{"_tag"} eq "~pi"
l!l&&r!l&&!r
1120
@tree and not ref $tree[0] and $tree[0] =~ /^(\s|\n|\r)*$/
!ll&&!rl&&r
2101
@tree and not ref $tree[0]
!ll&&!rl&&r
0211
@tree and ref $tree[0] and $tree[0]{"_tag"} and $tree[0]{"_tag"} eq "~pi"
!ll&&!rl&&r
0201
@tree and ref $tree[0] and $tree[0]{"_tag"}
!ll&&!rl&&r
0021
@tree and ref $tree[0]
!ll&&!rl&&r
0021
MC/DC28%2/7
@tree and not ref $tree[0] and $tree[0] =~ /^(\s|\n|\r)*$/ or @tree and ref $tree[0] and $tree[0]{"_tag"} and $tree[0]{"_tag"} eq "~pi"
@tree not ref $tree[0] $tree[0] =~ /^(\s|\n|\r)*$/ @tree ref $tree[0] $tree[0]{"_tag"} $tree[0]{"_tag"} eq "~pi"
Truth table18%3/16
A and not(B) and C or D and E and F and G
A= @treeB= not ref $tree[0]C= $tree[0] =~ /^(\s|\n|\r)*$/D= @treeE= ref $tree[0]F= $tree[0]{"_tag"}G= $tree[0]{"_tag"} eq "~pi"
ABCDEFGresult
111XXXX1
0XX11111
10X11111
11011111
0XX0XXX0
0XX10XX0
0XX110X0
0XX11100
10X0XXX0
10X10XX0
10X110X0
10X11100
1100XXX0
11010XX0
110110X0
11011100
29 2 (@tree and ref $tree[0] and $tree[0]->{_tag} and $tree[0]->{_tag} eq '~pi') ) { shift (@tree) }
30  
31 20 local $BackRef = {};
32 20 local $IndentLevel = 0;
33
34 20 return $class->xml_to_perl ($tree[0]);
35 }
36  
37  
38 # SECTION THAT UNDUMPS PERL FROM XML NODE
39 sub xml_to_perl
40 130 ▶{
Subroutine xml_to_perl: called CC=9 SCAR=22.2
Pod undocumented
41 130 my $class = shift;
42 130 ▶ @_ = map { ref $_ ? $_ : () } @_;
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 130 188 318
43
44 my @res = map {
45 130 ▶ $class->xml_to_perl_backwards_compat_perl_tag ($_) ||
Condition88%16/18
$class->xml_to_perl_backwards_compat_perl_tag($_) || $class->xml_to_perl_backref($_) || $class->xml_to_perl_ref($_) || $class->xml_to_perl_scalar($_) || $class->xml_to_perl_hash($_) || $class->xml_to_perl_array($_) || $class->xml_to_perl_litteral($_)
l!l&&r!l&&!r
97330
$class->xml_to_perl_backwards_compat_perl_tag($_) or $class->xml_to_perl_backref($_) or $class->xml_to_perl_ref($_) or $class->xml_to_perl_scalar($_) or $class->xml_to_perl_hash($_) or $class->xml_to_perl_array($_)
l!l&&r!l&&!r
90337
$class->xml_to_perl_backwards_compat_perl_tag($_) or $class->xml_to_perl_backref($_) or $class->xml_to_perl_ref($_) or $class->xml_to_perl_scalar($_) or $class->xml_to_perl_hash($_)
l!l&&r!l&&!r
761143
$class->xml_to_perl_backwards_compat_perl_tag($_) or $class->xml_to_perl_backref($_) or $class->xml_to_perl_ref($_) or $class->xml_to_perl_scalar($_)
l!l&&r!l&&!r
71059
$class->xml_to_perl_backwards_compat_perl_tag($_) or $class->xml_to_perl_backref($_) or $class->xml_to_perl_ref($_)
l!l&&r!l&&!r
111118
$class->xml_to_perl_backwards_compat_perl_tag($_) or $class->xml_to_perl_backref($_)
l!l&&r!l&&!r
101119
MC/DC0%0/7
$class->xml_to_perl_backwards_compat_perl_tag($_) || $class->xml_to_perl_backref($_) || $class->xml_to_perl_ref($_) || $class->xml_to_perl_scalar($_) || $class->xml_to_perl_hash($_) || $class->xml_to_perl_array($_) || $class->xml_to_perl_litteral($_)
$class->xml_to_perl_backwards_compat_perl_tag($_) $class->xml_to_perl_backref($_) $class->xml_to_perl_ref($_) $class->xml_to_perl_scalar($_) $class->xml_to_perl_hash($_) $class->xml_to_perl_array($_) $class->xml_to_perl_litteral($_)
Truth table75%6/8
A or B or C or D or E or F || G
A= $class->xml_to_perl_backwards_compat_perl_tag($_)B= $class->xml_to_perl_backref($_)C= $class->xml_to_perl_ref($_)D= $class->xml_to_perl_scalar($_)E= $class->xml_to_perl_hash($_)F= $class->xml_to_perl_array($_)G= $class->xml_to_perl_litteral($_)
ABCDEFGresult
1XXXXXX1
01XXXXX1
001XXXX1
0001XXX1
00001XX1
000001X1
00000011
00000000
46 $class->xml_to_perl_backref ($_) ||
47 $class->xml_to_perl_ref ($_) ||
48 $class->xml_to_perl_scalar ($_) ||
49 $class->xml_to_perl_hash ($_) ||
50 $class->xml_to_perl_array ($_) ||
51 $class->xml_to_perl_litteral ($_)
52 } @_;
53
54 130 ▶ return pop (@res) if (@res == 1);
Branch: 1 branch
BranchTrueFalseTotal
if @res == 1 130 0 130
55 0 return @res;
56 }
57  
58  
59 sub xml_to_perl_backwards_compat_perl_tag
60 130 ▶{
Subroutine xml_to_perl_backwards_compat_perl_tag: called CC=3 SCAR=11.0
Pod undocumented
61 130 my ($class, $tree) = @_;
62 130 ▶ ref $tree || return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 130 0 130
63 130 ▶ $tree->{_tag} eq 'perl' || return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "perl" or return () 10 120 130
64
65 10 local ($Compat) = 1;
66 10 return $class->xml_to_perl (@{$tree->{_content}});
67 }
68  
69  
70 sub xml_to_perl_backref
71 122 ▶{
Subroutine xml_to_perl_backref: called CC=5 SCAR=16.2
Pod undocumented
72 122 my ($class, $tree) = @_;
73 122 ▶ ref $tree || return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 122 0 122
74 122 ▶ $tree->{_tag} eq 'backref' || return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "backref" or return () 3 119 122
75 3 ▶ my $ref_id = $tree->{id} || return ();
Condition50%1/2
$tree->{'id'} || (return ())
l!l
30
MC/DC0%0/1
$tree->{'id'} || (return ())
$tree->{'id'}
Truth table50%1/2
A
A= $tree->{'id'}
Aresult
11
00
76 3 ▶ exists $BackRef->{$ref_id} || return ();
Branch: 1 branch
BranchTrueFalseTotal
exists $MKDoc::XML::Dumper::BackRef->{$ref_id} or return () 2 1 3
77 2 return $BackRef->{$ref_id};
78 }
79  
80  
81 sub xml_to_perl_ref
82 119 ▶{
Subroutine xml_to_perl_ref: called CC=5 SCAR=16.3
Pod undocumented
83 119 my ($class, $tree) = @_;
84 119 ▶ ref $tree || return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 119 0 119
85 119 ▶ $tree->{_tag} eq 'ref' || return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "ref" or return () 60 59 119
86 60 ▶ my $ref_id = $tree->{id} || return ();
Condition50%1/2
$tree->{'id'} || (return ())
l!l
600
MC/DC0%0/1
$tree->{'id'} || (return ())
$tree->{'id'}
Truth table50%1/2
A
A= $tree->{'id'}
Aresult
11
00
87
88 60 my $ref = \\undef;
89 60 ▶ bless $ref, $tree->{bless} if (defined $tree->{bless});
Branch: 1 branch
BranchTrueFalseTotal
if defined $tree->{"bless"} 0 60 60
90 60 $BackRef->{$ref_id} = $ref;
91
92 60 ($$ref) = $class->xml_to_perl ( @{$tree->{_content}} );
93 60 return $ref;
94 }
95  
96  
97 sub xml_to_perl_scalar
98 61 ▶{
Subroutine xml_to_perl_scalar: called CC=5 SCAR=16.2
Pod undocumented
99 61 my ($class, $tree) = @_;
100 61 ▶ ref $tree or return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 61 0 61
101 61 ▶ $tree->{_tag} eq 'scalar' or return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "scalar" or return () 7 54 61
102 7 ▶ my $ref_id = $tree->{id} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $ref_id = $tree->{"id"} or return () 7 0 7
103
104 7 my $ref = \\undef;
105 7 ▶ bless $ref, $tree->{bless} if (defined $tree->{bless});
Branch: 1 branch
BranchTrueFalseTotal
if defined $tree->{"bless"} 1 6 7
106 7 $BackRef->{$ref_id} = $ref;
107  
108 7 ($$ref) = $class->xml_to_perl ( @{$tree->{_content}} );
109 7 return $ref;
110 }
111  
112  
113 sub xml_to_perl_hash
114 60 ▶{
Subroutine xml_to_perl_hash: called CC=9 SCAR=22.0
Pod undocumented
115 60 my ($class, $tree) = @_;
116 60 ▶ ref $tree or return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 60 0 60
117 60 ▶ $tree->{_tag} eq 'hash' or return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "hash" or return () 20 40 60
118 20 ▶ my $ref_id = $tree->{id} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $ref_id = $tree->{"id"} or return () 20 0 20
119  
120 20 my $ref = {};
121 20 ▶ bless $ref, $tree->{bless} if (defined $tree->{bless});
Branch: 1 branch
BranchTrueFalseTotal
if defined $tree->{"bless"} 13 7 20
122 20 $BackRef->{$ref_id} = $ref;
123
124 20 ▶ my @items = map { ref $_ ? $_ : () } @{$tree->{_content}};
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 70 78 148
125 20 foreach my $item (@items)
126 {
127 70 my $key = $item->{key};
128 70 ▶ if ($Compat)
Branch: 1 branch
BranchTrueFalseTotal
if ($MKDoc::XML::Dumper::Compat) { } 58 12 70
129 {
130 58 $ref->{$key} = do {
131 58 ▶ my $stuff = $item->{_content}->[0] || '';
Condition100%2/2
$item->{'_content'}[0] || ''
l!l
499
MC/DC100%1/1
$item->{'_content'}[0] || ''
$item->{'_content'}[0]
Truth table100%2/2
A
A= $item->{'_content'}[0]
Aresult
11
00
132 58 my $decode = new MKDoc::XML::Decode ('xml');
133 58 $decode->process ($stuff);
134 }
135 }
136 else
137 {
138 12 my ($val) = $class->xml_to_perl ( @{$item->{_content}} );
139 12 $ref->{$key} = $val;
140 }
141 }
142
143 20 return $ref;
144 }
145  
146  
147 sub xml_to_perl_array
148 46 ▶{
Subroutine xml_to_perl_array: called CC=7 SCAR=19.5
Pod undocumented
149 46 my ($class, $tree) = @_;
150 46 ▶ ref $tree or return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 46 0 46
151 46 ▶ $tree->{_tag} eq 'array' or return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "array" or return () 13 33 46
152 13 ▶ my $ref_id = $tree->{id} or return ();
Branch: 1 branch
BranchTrueFalseTotal
my $ref_id = $tree->{"id"} or return () 13 0 13
153  
154 13 my $ref = [];
155 13 ▶ bless $ref, $tree->{bless} if (defined $tree->{bless});
Branch: 1 branch
BranchTrueFalseTotal
if defined $tree->{"bless"} 3 10 13
156 13 $BackRef->{$ref_id} = $ref;
157
158 13 ▶ my @items = map { ref $_ ? $_ : () } @{$tree->{_content}};
Branch: 1 branch
BranchTrueFalseTotal
ref $_ ? : 20 21 41
159 13 foreach my $item (@items)
160 {
161 20 my $key = $item->{key};
162 20 my ($val) = $class->xml_to_perl ( @{$item->{_content}} );
163 20 $ref->[$key] = $val;
164 }
165
166 13 return $ref;
167 }
168  
169  
170 sub xml_to_perl_litteral
171 37 ▶{
Subroutine xml_to_perl_litteral: called CC=5 SCAR=16.5
Pod undocumented
172 37 my ($class, $tree) = @_;
173 37 ▶ ref $tree or return ();
Branch: 1 branch
BranchTrueFalseTotal
ref $tree or return () 37 0 37
174 37 ▶ $tree->{_tag} eq 'litteral' or return ();
Branch: 1 branch
BranchTrueFalseTotal
$tree->{"_tag"} eq "litteral" or return () 37 0 37
175 37 ▶ return undef if ($tree->{undef} and $tree->{undef} eq 'true');
Branch: 1 branch
BranchTrueFalseTotal
if $tree->{"undef"} and $tree->{"undef"} eq "true" 1 36 37
Condition66%2/3
$tree->{"undef"} and $tree->{"undef"} eq "true"
!ll&&!rl&&r
3601
MC/DC50%1/2
$tree->{"undef"} and $tree->{"undef"} eq "true"
$tree->{"undef"} $tree->{"undef"} eq "true"
Truth table66%2/3
A and B
A= $tree->{"undef"}B= $tree->{"undef"} eq "true"
ABresult
0X0
100
111
176
177 36 my $decode = new MKDoc::XML::Decode ('xml');
178 36 return $decode->process ($tree->{_content}->[0]);
179 }
180  
181  
182 #####################################################################
183 # DUMPS PERL STRUCTURE TO XML DATA #
184 #####################################################################
185  
186  
187 sub perl2xml
188 10 ▶{
Subroutine perl2xml: called CC=1 SCAR=0.0
Pod documented
189 10 my $class = shift;
190 10 my $ref = shift;
191
192 10 local $BackRef = {};
193 10 local $IndentLevel = 0;
194
195 10 return $class->perl_to_xml ($ref);
196 }
197  
198  
199 sub perl_to_xml
200 116 ▶{
Subroutine perl_to_xml: called CC=7 SCAR=19.5
Pod undocumented
201 116 my ($class, $ref) = @_;
202 116 ▶ $_ = Scalar::Util::reftype ($ref) || '';
Condition100%2/2
builtin::reftype($ref) || ''
l!l
7739
MC/DC100%1/1
builtin::reftype($ref) || ''
builtin::reftype($ref)
Truth table100%2/2
A
A= builtin::reftype($ref)
Aresult
11
00
203  
204 116 ▶ return $class->perl_to_xml_backref ($ref) ||
Condition86%13/15
$class->perl_to_xml_backref($ref) || $class->perl_to_xml_ref($ref) || $class->perl_to_xml_scalar($ref) || $class->perl_to_xml_hash($ref) || $class->perl_to_xml_array($ref) || $class->perl_to_xml_litteral($ref)
l!l&&r!l&&!r
77390
$class->perl_to_xml_backref($ref) or $class->perl_to_xml_ref($ref) or $class->perl_to_xml_scalar($ref) or $class->perl_to_xml_hash($ref) or $class->perl_to_xml_array($ref)
l!l&&r!l&&!r
70343
$class->perl_to_xml_backref($ref) or $class->perl_to_xml_ref($ref) or $class->perl_to_xml_scalar($ref) or $class->perl_to_xml_hash($ref)
l!l&&r!l&&!r
66149
$class->perl_to_xml_backref($ref) or $class->perl_to_xml_ref($ref) or $class->perl_to_xml_scalar($ref)
l!l&&r!l&&!r
61055
$class->perl_to_xml_backref($ref) or $class->perl_to_xml_ref($ref)
l!l&&r!l&&!r
11114
MC/DC0%0/6
$class->perl_to_xml_backref($ref) || $class->perl_to_xml_ref($ref) || $class->perl_to_xml_scalar($ref) || $class->perl_to_xml_hash($ref) || $class->perl_to_xml_array($ref) || $class->perl_to_xml_litteral($ref)
$class->perl_to_xml_backref($ref) $class->perl_to_xml_ref($ref) $class->perl_to_xml_scalar($ref) $class->perl_to_xml_hash($ref) $class->perl_to_xml_array($ref) $class->perl_to_xml_litteral($ref)
Truth table71%5/7
A or B or C or D or E || F
A= $class->perl_to_xml_backref($ref)B= $class->perl_to_xml_ref($ref)C= $class->perl_to_xml_scalar($ref)D= $class->perl_to_xml_hash($ref)E= $class->perl_to_xml_array($ref)F= $class->perl_to_xml_litteral($ref)
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
205 $class->perl_to_xml_ref ($ref) ||
206 $class->perl_to_xml_scalar ($ref) ||
207 $class->perl_to_xml_hash ($ref) ||
208 $class->perl_to_xml_array ($ref) ||
209 $class->perl_to_xml_litteral ($ref);
210 }
211  
212  
213 sub perl_to_xml_backref
214 118 ▶{
Subroutine perl_to_xml_backref: called CC=4 SCAR=13.9
Pod undocumented
215 118 my ($class, $ref) = @_;
216 118 ▶ $ref && ref $ref || return;
Branch: 1 branch
BranchTrueFalseTotal
$ref and ref $ref or return 79 39 118
Condition66%2/3
$ref and ref $ref
!ll&&!rl&&r
03979
MC/DC50%1/2
$ref and ref $ref
$ref ref $ref
Truth table66%2/3
A and B
A= $refB= ref $ref
ABresult
0X0
100
111
217
218 79 my $ref_id = 0 + $ref;
219 79 ▶ $BackRef->{$ref_id} || return;
Branch: 1 branch
BranchTrueFalseTotal
$MKDoc::XML::Dumper::BackRef->{$ref_id} or return 2 77 79
220
221 2 return $class->indent() . qq |<backref id="$ref_id" />| . "\n";
222 }
223  
224  
225 sub perl_to_xml_litteral
226 43 ▶{
Subroutine perl_to_xml_litteral: called CC=2 SCAR=6.9
Pod undocumented
227 43 my ($class, $ref) = @_;
228 43 ▶ (defined $ref) ?
Branch: 1 branch
BranchTrueFalseTotal
defined $ref ? : 42 1 43
229 $class->indent() . qq |<litteral>| . MKDoc::XML::Encode->process ($ref) . qq |</litteral>| . "\n" :
230 $class->indent() . qq |<litteral undef="true" />| . "\n";
231 }
232  
233  
234 sub perl_to_xml_scalar
235 57 ▶{
Subroutine perl_to_xml_scalar: called CC=5 SCAR=16.1
Pod undocumented
236 57 my ($class, $ref) = @_;
237 57 ▶ $ref && ref $ref && Scalar::Util::reftype ($ref) eq 'SCALAR' || return;
Branch: 1 branch
BranchTrueFalseTotal
$ref and ref $ref and builtin::reftype($ref) eq "SCALAR" or return 7 50 57
Condition83%5/6
$ref and ref $ref and builtin::reftype($ref) eq "SCALAR"
!ll&&!rl&&r
39117
$ref and ref $ref
!ll&&!rl&&r
03918
MC/DC66%2/3
$ref and ref $ref and builtin::reftype($ref) eq "SCALAR"
$ref ref $ref builtin::reftype($ref) eq "SCALAR"
Truth table75%3/4
A and B and C
A= $refB= ref $refC= builtin::reftype($ref) eq "SCALAR"
ABCresult
0XX0
10X0
1100
1111
238
239 7 my $ref_id = 0 + $ref;
240 7 $BackRef->{$ref_id} = $ref;
241
242 7 my $bless = Scalar::Util::blessed ($ref);
243 7 ▶ $bless = ($bless) ? qq | bless="$bless"| : '';
Branch: 1 branch
BranchTrueFalseTotal
$bless ? : 1 6 7
244  
245 7 my $string = '';
246 7 $string .= $class->indent() . qq |<scalar id="$ref_id"$bless>| . "\n";
247 7 $class->indent_more();
248 7 $string .= $class->perl_to_xml ($$ref);
249 7 $class->indent_less();
250 7 $string .= $class->indent() . qq |</scalar>| . "\n";
251
252 7 return $string;
253 }
254  
255  
256 sub perl_to_xml_ref
257 115 ▶{
Subroutine perl_to_xml_ref: called CC=5 SCAR=16.1
Pod undocumented
258 115 my ($class, $ref) = @_;
259 115 ▶ $ref && ref $ref && Scalar::Util::reftype ($ref) eq 'REF' || return;
Branch: 1 branch
BranchTrueFalseTotal
$ref and ref $ref and builtin::reftype($ref) eq "REF" or return 60 55 115
Condition83%5/6
$ref and ref $ref and builtin::reftype($ref) eq "REF"
!ll&&!rl&&r
391660
$ref and ref $ref
!ll&&!rl&&r
03976
MC/DC66%2/3
$ref and ref $ref and builtin::reftype($ref) eq "REF"
$ref ref $ref builtin::reftype($ref) eq "REF"
Truth table75%3/4
A and B and C
A= $refB= ref $refC= builtin::reftype($ref) eq "REF"
ABCresult
0XX0
10X0
1100
1111
260
261 60 my $ref_id = 0 + $ref;
262 60 $BackRef->{$ref_id} = $ref;
263
264 60 my $bless = Scalar::Util::blessed ($ref);
265 60 ▶ $bless = ($bless) ? qq | bless="$bless"| : '';
Branch: 1 branch
BranchTrueFalseTotal
$bless ? : 0 60 60
266  
267 60 my $string = '';
268 60 $string .= $class->indent() . qq |<ref id="$ref_id"$bless>| . "\n";
269 60 $class->indent_more();
270 60 $string .= $class->perl_to_xml ($$ref);
271 60 $class->indent_less();
272 60 $string .= $class->indent() . qq |</ref>| . "\n";
273
274 60 return $string;
275 }
276  
277  
278 sub perl_to_xml_hash
279 56 ▶{
Subroutine perl_to_xml_hash: called CC=6 SCAR=17.9
Pod undocumented
280 56 my ($class, $ref) = @_;
281 56 ▶ $ref && ref $ref && Scalar::Util::reftype ($ref) eq 'HASH' || return;
Branch: 1 branch
BranchTrueFalseTotal
$ref and ref $ref and builtin::reftype($ref) eq "HASH" or return 10 46 56
Condition83%5/6
$ref and ref $ref and builtin::reftype($ref) eq "HASH"
!ll&&!rl&&r
39710
$ref and ref $ref
!ll&&!rl&&r
03917
MC/DC66%2/3
$ref and ref $ref and builtin::reftype($ref) eq "HASH"
$ref ref $ref builtin::reftype($ref) eq "HASH"
Truth table75%3/4
A and B and C
A= $refB= ref $refC= builtin::reftype($ref) eq "HASH"
ABCresult
0XX0
10X0
1100
1111
282
283 10 my $ref_id = 0 + $ref;
284 10 $BackRef->{$ref_id} = $ref;
285
286 10 my $bless = Scalar::Util::blessed ($ref);
287 10 ▶ $bless = ($bless) ? qq | bless="$bless"| : '';
Branch: 1 branch
BranchTrueFalseTotal
$bless ? : 3 7 10
288
289 10 my $string = '';
290 10 $string .= $class->indent() . qq |<hash id="$ref_id"$bless>| . "\n";
291 10 for (keys %{$ref})
292 {
293 12 $class->indent_more();
294 12 $string .= $class->indent() . qq |<item key="$_">| . "\n" ;
295 12 $class->indent_more();
296 12 $string .= $class->perl_to_xml ($ref->{$_});
297 12 $class->indent_less();
298 12 $string .= $class->indent() . qq |</item>| . "\n";
299 12 $class->indent_less();
300 }
301 10 $string .= $class->indent() . qq |</hash>| . "\n";
302
303 10 return $string;
304 }
305  
306  
307 sub perl_to_xml_array
308 52 ▶{
Subroutine perl_to_xml_array: called CC=6 SCAR=17.9
Pod undocumented
309 52 my ($class, $ref) = @_;
310 52 ▶ $ref && ref $ref && Scalar::Util::reftype ($ref) eq 'ARRAY' || return;
Branch: 1 branch
BranchTrueFalseTotal
$ref and ref $ref and builtin::reftype($ref) eq "ARRAY" or return 13 39 52
Condition66%4/6
$ref and ref $ref and builtin::reftype($ref) eq "ARRAY"
!ll&&!rl&&r
39013
$ref and ref $ref
!ll&&!rl&&r
03913
MC/DC33%1/3
$ref and ref $ref and builtin::reftype($ref) eq "ARRAY"
$ref ref $ref builtin::reftype($ref) eq "ARRAY"
Truth table50%2/4
A and B and C
A= $refB= ref $refC= builtin::reftype($ref) eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
311
312 13 my $ref_id = 0 + $ref;
313 13 $BackRef->{$ref_id} = $ref;
314
315 13 my $bless = Scalar::Util::blessed ($ref);
316 13 ▶ $bless = ($bless) ? qq | bless="$bless"| : '';
Branch: 1 branch
BranchTrueFalseTotal
$bless ? : 3 10 13
317
318 13 my $string = '';
319 13 $string .= $class->indent() . qq |<array id="$ref_id"$bless>| . "\n";
320 13 ▶ for (my $i=0; $i < @{$ref}; $i++)
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @{$ref;}) 26 13 39
321 {
322 26 $class->indent_more();
323 26 $string .= $class->indent() . qq |<item key="$i">| . "\n" ;
324 26 $class->indent_more();
325 26 $string .= $class->perl_to_xml ($ref->[$i]);
326 26 $class->indent_less();
327 26 $string .= $class->indent() . qq |</item>| . "\n";
328 26 $class->indent_less();
329 }
330 13 $string .= $class->indent() . qq |</array>| . "\n";
331
332 13 return $string;
333 }
334  
335  
336 sub indent
337 301 ▶{
Subroutine indent: called CC=1 SCAR=0.0
Pod undocumented
338 301 return " " x $IndentLevel;
339 }
340  
341  
342 sub indent_more
343 144 ▶{
Subroutine indent_more: called CC=1 SCAR=0.0
Pod undocumented
344 144 $IndentLevel++;
345 }
346  
347  
348 sub indent_less
349 144 ▶{
Subroutine indent_less: called CC=1 SCAR=0.0
Pod undocumented
350 144 $IndentLevel--;
351 }
352  
353  
354 5 1;
355  
356  
357 __END__
« lib/MKDoc/XML/TreePrinter.pm ↑ Summary lib/MKDoc/XML/Stripper.pm »