blib/lib/Tags/Output/Indent.pm

filter: Statementstmt 97.4% 263 / 270 Branchbran 79.0% 68 / 86 Conditioncond 56.1% 23 / 41 MC/DCmcdc 26.9% 7 / 26 Subroutinesub 96.6% 29 / 30 Podpod 100% 2 / 2 totaltotal 86.1% 392 / 455 CC 60 SCAR 20.4
CC
60
Cov
89%
_print_tag
19.3
_put_end_of_tag
13.0
_put_attribute
6.6
CRAP 7.7
↑ Summary
1 package Tags::Output::Indent;
2  
3 20 ▶use base qw(Tags::Output);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 20 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 20 ▶use Indent;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 20 ▶use Indent::Word;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 20 ▶use Indent::Block;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 20 ▶use List::Util qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 20 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 20 ▶use Tags::Utils qw(encode_attr_entities encode_char_entities);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 20 ▶use Tags::Utils::Preserve;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # Constants.
17 20 Readonly::Scalar my $EMPTY_STR => q{};
18 20 Readonly::Scalar my $LAST_INDEX => -1;
19 20 Readonly::Scalar my $LINE_SIZE => 79;
20 20 Readonly::Scalar my $SPACE => q{ };
21  
22 20 our $VERSION = 0.12;
23  
24 # Finalize Tags output.
25 sub finalize {
26 4 ▶ my $self = shift;
Subroutine finalize: called CC=4 SCAR=13.9
Pod documented
27  
28 # XML mode.
29 4 ▶ if ($self->{'xml'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'xml'}) { } 1 3 4
30  
31 # Add ending of all opened tags.
32 1 ▶ while (@{$self->{'printed_tags'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"printed_tags"};}) 1 1 2
33 1 $self->put(['e', $self->{'printed_tags'}->[0]]);
34 }
35  
36 # SGML mode.
37 } else {
38  
39 # Flush tmp code.
40 3 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 3 0 3
41 3 $self->_print_tag('>');
42 }
43 3 $self->{'printed_tags'} = [];
44 }
45 4 return;
46 }
47  
48 # Resets internal variables.
49 sub reset {
50 56 ▶ my $self = shift;
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
51  
52 # Comment flag.
53 56 $self->{'comment_flag'} = 0;
54  
55 # Indent object.
56 $self->{'indent'} = Indent->new(
57 56 'next_indent' => $self->{'next_indent'},
58 );
59  
60 # Indent::Word object.
61 $self->{'indent_word'} = Indent::Word->new(
62 56 'line_size' => $self->{'line_size'},
63 'next_indent' => $EMPTY_STR,
64 );
65  
66 # Indent::Block object.
67 $self->{'indent_block'} = Indent::Block->new(
68 'line_size' => $self->{'line_size'},
69 56 'next_indent' => $self->{'next_indent'},
70 'strict' => 0,
71 );
72  
73 # Flush code.
74 56 $self->_reset_flush;
75  
76 # Tmp code.
77 56 $self->{'tmp_code'} = [];
78 56 $self->{'tmp_comment_code'} = [];
79  
80 # Printed tags.
81 56 $self->{'printed_tags'} = [];
82  
83 # Non indent flag.
84 56 $self->{'non_indent'} = 0;
85  
86 # Flag, that means raw tag.
87 56 $self->{'raw_tag'} = 0;
88  
89 # Preserved object.
90 $self->{'preserve_obj'} = Tags::Utils::Preserve->new(
91 56 'preserved' => $self->{'preserved'},
92 );
93  
94 # Process flag.
95 56 $self->{'process'} = 0;
96  
97 56 return;
98 }
99  
100 # Check parameters to rigth values.
101 sub _check_params {
102 35 ▶ my $self = shift;
Subroutine _check_params: called CC=3 SCAR=11.0
103  
104 # Check params from SUPER.
105 35 $self->SUPER::_check_params();
106  
107 # Check 'attr_delimeter'.
108 33 ▶ if ($self->{'attr_delimeter'} ne q{"}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"attr_delimeter"} ne "\"" and $self->{"attr_delimeter"} ne "'") 1 32 33
Condition66%2/3
$self->{"attr_delimeter"} ne "\"" and $self->{"attr_delimeter"} ne "'"
!ll&&!rl&&r
3201
MC/DC50%1/2
$self->{"attr_delimeter"} ne "\"" and $self->{"attr_delimeter"} ne "'"
$self->{"attr_delimeter"} ne "\"" $self->{"attr_delimeter"} ne "'"
Truth table66%2/3
A and B
A= $self->{"attr_delimeter"} ne "\""B= $self->{"attr_delimeter"} ne "'"
ABresult
0X0
100
111
109 && $self->{'attr_delimeter'} ne q{'}) {
110  
111 1 err "Bad attribute delimeter '$self->{'attr_delimeter'}'.";
112 }
113  
114 32 return;
115 }
116  
117 # Default parameters.
118 sub _default_parameters {
119 37 ▶ my $self = shift;
Subroutine _default_parameters: called CC=1 SCAR=0.0
120  
121 # Default parameters from SUPER.
122 37 $self->SUPER::_default_parameters();
123  
124 # Attribute callback.
125 37 $self->{'attr_callback'} = \&encode_attr_entities;
126  
127 # Attribute delimeter.
128 37 $self->{'attr_delimeter'} = '"';
129  
130 # Indent CDATA section.
131 37 $self->{'cdata_indent'} = 0;
132  
133 # CDATA callback.
134 37 $self->{'cdata_callback'} = undef;
135  
136 # Data callback.
137 37 $self->{'data_callback'} = \&encode_char_entities;
138  
139 # Callback to instruction.
140 37 $self->{'instruction'} = $EMPTY_STR;
141  
142 # Indent line size.
143 37 $self->{'line_size'} = $LINE_SIZE;
144  
145 # Next indent string.
146 37 $self->{'next_indent'} = $SPACE x 2;
147  
148 # No data callback.
149 37 $self->{'no_data_callback'} = ['script', 'style'];
150  
151 # No simple tags.
152 37 $self->{'no_simple'} = [];
153  
154 # Preserved tags.
155 37 $self->{'preserved'} = [];
156  
157 # Raw data callback.
158 37 $self->{'raw_callback'} = undef;
159  
160 # XML output.
161 37 $self->{'xml'} = 0;
162  
163 37 return;
164 }
165  
166 # Helper for flush data.
167 sub _flush_code {
168 269 ▶ my ($self, $code) = @_;
Subroutine _flush_code: called CC=2 SCAR=6.9
169 269 ▶ if (! $self->{'process'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"process"}) 55 214 269
170 55 $self->{'process'} = 1;
171 }
172 269 $self->{'flush_code'} .= $code;
173 269 return;
174 }
175  
176 # Print newline if need.
177 sub _newline {
178 162 ▶ my $self = shift;
Subroutine _newline: called CC=4 SCAR=13.9
179  
180 # Null raw tag (normal tag processing).
181 162 ▶ if ($self->{'raw_tag'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'raw_tag'}) { } 9 153 162
182 9 $self->{'raw_tag'} = 0;
183  
184 # Adding newline if flush_code.
185 } else {
186 153 my (undef, $pre_pre) = $self->{'preserve_obj'}->get;
187 153 ▶ if ($self->{'process'} && $pre_pre == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"process"} and $pre_pre == 0) 96 57 153
Condition100%3/3
$self->{"process"} and $pre_pre == 0
!ll&&!rl&&r
54396
MC/DC100%2/2
$self->{"process"} and $pre_pre == 0
$self->{"process"} $pre_pre == 0
Truth table100%3/3
A and B
A= $self->{"process"}B= $pre_pre == 0
ABresult
0X0
100
111
188 96 $self->_flush_code($self->{'output_sep'});
189 }
190 }
191  
192 162 return;
193 }
194  
195 # Print indented tag from @{$self->{'tmp_code'}}.
196 sub _print_tag {
197 67 ▶ my ($self, $string) = @_;
Subroutine _print_tag: called CC=17 SCAR=29.6
198 67 ▶ if ($string) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string) 67 0 67
199 67 ▶ if ($string =~ /^\/>$/ms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ m[^/>$]ms) 9 58 67
200 9 push @{$self->{'tmp_code'}}, $SPACE;
201 }
202 67 push @{$self->{'tmp_code'}}, $string;
203 }
204  
205 # Flush comment code before tag.
206 # TODO Optimalization.
207 67 ▶ if ($self->{'comment_flag'} == 0
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'comment_flag'} == 0 and scalar @{$self->{'tmp_comment_code'};}) { } 4 63 67
Condition100%2/2
$self->{"comment_flag"} == 0 and scalar @{$self->{"tmp_comment_code"};}
!ll
562
MC/DC100%1/1
$self->{"comment_flag"} == 0 and scalar @{$self->{"tmp_comment_code"};}
$self->{"comment_flag"} == 0
Truth table100%2/2
A
A= $self->{"comment_flag"} == 0
Aresult
00
11
208 62 && scalar @{$self->{'tmp_comment_code'}}) {
209  
210 # Comment from tmp place.
211 4 foreach my $tmp_comment (@{$self->{'tmp_comment_code'}}) {
212 4 $self->_newline;
213 my $indent_tmp_comment = $self->{'indent_block'}
214 4 ->indent($tmp_comment, $self->{'indent'}->get);
215 4 $self->_flush_code($indent_tmp_comment);
216 }
217  
218 4 my $pre = $self->{'preserve_obj'}->get;
219 4 my $act_indent;
220 4 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 4 0 4
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->{"non_indent"} or $pre
$self->{"non_indent"} $pre
Truth table33%1/3
A or B
A= $self->{"non_indent"}B= $pre
ABresult
1X1
011
000
221 4 $act_indent = $self->{'indent'}->get;
222 }
223 4 $self->_newline;
224  
225 # Get indent string and put to flush.
226 my $tmp = $self->{'indent_block'}->indent(
227 4 ▶ $self->{'tmp_code'}, $act_indent, $pre ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$pre ? : 0 4 4
228 );
229 4 $self->_flush_code($tmp);
230  
231 4 $self->{'tmp_code'} = [];
232 4 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 4 0 4
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->{"non_indent"} or $pre
$self->{"non_indent"} $pre
Truth table33%1/3
A or B
A= $self->{"non_indent"}B= $pre
ABresult
1X1
011
000
233 4 $self->{'indent'}->add;
234 }
235 4 $self->{'preserve_obj'}->begin($self->{'printed_tags'}->[0]);
236 } else {
237 63 my $pre = $self->{'preserve_obj'}->get;
238 63 my $act_indent;
239 63 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 63 0 63
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
0063
MC/DC0%0/2
$self->{"non_indent"} or $pre
$self->{"non_indent"} $pre
Truth table33%1/3
A or B
A= $self->{"non_indent"}B= $pre
ABresult
1X1
011
000
240 63 $act_indent = $self->{'indent'}->get;
241 }
242 63 $self->_newline;
243  
244 # Get indent string and put to flush.
245 my $tmp = $self->{'indent_block'}->indent(
246 63 ▶ $self->{'tmp_code'}, $act_indent, $pre ? 1 : 0
Branch: 1 branch
BranchTrueFalseTotal
$pre ? : 0 63 63
247 );
248 63 $self->_flush_code($tmp);
249  
250 63 $self->{'tmp_code'} = [];
251 63 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 63 0 63
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
0063
MC/DC0%0/2
$self->{"non_indent"} or $pre
$self->{"non_indent"} $pre
Truth table33%1/3
A or B
A= $self->{"non_indent"}B= $pre
ABresult
1X1
011
000
252 63 $self->{'indent'}->add;
253 }
254 63 $self->{'preserve_obj'}->begin($self->{'printed_tags'}->[0]);
255  
256 # Comment from tmp place.
257 63 foreach my $tmp_comment (@{$self->{'tmp_comment_code'}}) {
258 4 $self->_newline;
259 my $indent_tmp_comment = $self->{'indent_block'}
260 4 ->indent($tmp_comment, $self->{'indent'}->get);
261 4 $self->_flush_code($indent_tmp_comment);
262 }
263 }
264 67 $self->{'tmp_comment_code'} = [];
265 67 return;
266 }
267  
268 # Print indented end of tag.
269 sub _print_end_tag {
270 52 ▶ my ($self, $string) = @_;
Subroutine _print_end_tag: called CC=5 SCAR=16.5
271 52 my $act_indent;
272 52 my ($pre, $pre_pre) = $self->{'preserve_obj'}->get;
273 52 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 52 0 52
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
0052
MC/DC0%0/2
$self->{"non_indent"} or $pre
$self->{"non_indent"} $pre
Truth table33%1/3
A or B
A= $self->{"non_indent"}B= $pre
ABresult
1X1
011
000
274 52 $self->{'indent'}->remove;
275 52 ▶ if (! $pre_pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pre_pre) 49 3 52
276 49 $act_indent = $self->{'indent'}->get;
277 }
278 }
279 52 $self->_newline;
280 52 ▶ my $indent_end = $self->{'indent_block'}->indent(
Branch: 1 branch
BranchTrueFalseTotal
$pre ? : 0 52 52
281 ['</'.$string, '>'], $act_indent, $pre ? 1 : 0,
282 );
283 52 $self->_flush_code($indent_end);
284 52 return;
285 }
286  
287 # Attributes.
288 sub _put_attribute {
289 20 ▶ my ($self, $attr, $value) = @_;
Subroutine _put_attribute: called CC=6 SCAR=18.8
290  
291 # Check to 'tmp_code'.
292 20 ▶ if (! @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$self->{"tmp_code"};}) 0 20 20
293 0 err 'Bad tag type \'a\'.';
294 }
295  
296 # Check to pairs in XML mode.
297 20 ▶ if ($self->{'xml'} && ! defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"xml"} and not defined $value) 0 20 20
Condition66%2/3
$self->{"xml"} and not defined $value
!ll&&!rl&&r
9110
MC/DC0%0/2
$self->{"xml"} and not defined $value
$self->{"xml"} not defined $value
Truth table66%2/3
A and not(B)
A= $self->{"xml"}B= not defined $value
ABresult
0X0
100
111
298 0 err 'In XML mode must be a attribute value.';
299 }
300  
301 # Process data callback.
302 20 my @attr = ($attr);
303 20 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 20 0 20
304 20 push @attr, $value;
305 }
306 20 $self->_process_callback(\@attr, 'attr_callback');
307  
308 # Process attribute.
309 20 push @{$self->{'tmp_code'}}, $SPACE, $attr[0];
310 20 ▶ if (defined $attr[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attr[1]) 20 0 20
311 20 push @{$self->{'tmp_code'}}, q{=}, $self->{'attr_delimeter'}.
312 20 $attr[1].$self->{'attr_delimeter'};
313 }
314  
315 # Reset comment flag.
316 20 $self->{'comment_flag'} = 0;
317  
318 20 return;
319 }
320  
321 # Begin of tag.
322 sub _put_begin_of_tag {
323 67 ▶ my ($self, $tag) = @_;
Subroutine _put_begin_of_tag: called CC=2 SCAR=6.9
324  
325 # Flush tmp code.
326 67 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 12 55 67
327 12 $self->_print_tag('>');
328 }
329  
330 # TODO Add checking of XML element name.
331 # if ($self->{'xml'} && _check(element_name)) {
332 # err 'This is not XML format.';
333 # }
334  
335 # Push begin of tag to tmp code.
336 67 push @{$self->{'tmp_code'}}, "<$tag";
337  
338 # Added tag to printed tags.
339 67 unshift @{$self->{'printed_tags'}}, $tag;
340  
341 67 return;
342 }
343  
344 # CData.
345 sub _put_cdata {
346 6 ▶ my ($self, @cdata) = @_;
Subroutine _put_cdata: called CC=4 SCAR=13.9
347  
348 # Flush tmp code.
349 6 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 5 1 6
350 5 $self->_print_tag('>');
351 }
352  
353 # Added begin of cdata section.
354 6 unshift @cdata, '<![CDATA[';
355  
356 # Check to bad cdata.
357 6 ▶ if ((join $EMPTY_STR, @cdata) =~ /]]>$/ms) {
Branch: 1 branch
BranchTrueFalseTotal
if (join($EMPTY_STR, @cdata) =~ /]]>$/ms) 1 5 6
358 1 err 'Bad CDATA section.';
359 }
360  
361 # Added end of cdata section.
362 5 push @cdata, ']]>';
363  
364 # Process data callback.
365 5 $self->_process_callback(\@cdata, 'cdata_callback');
366  
367 5 $self->_newline;
368 5 $self->{'preserve_obj'}->save_previous;
369  
370 # TODO Proc tohle nejde volat primo?
371 my $tmp = $self->{'indent_block'}->indent(
372 \@cdata, $self->{'indent'}->get,
373 5 ▶ $self->{'cdata_indent'} == 1 ? 0 : 1,
Branch: 1 branch
BranchTrueFalseTotal
$self->{'cdata_indent'} == 1 ? : 1 4 5
374 );
375  
376 # To flush code.
377 5 $self->_flush_code($tmp);
378  
379 5 return;
380 }
381  
382 # Comment.
383 sub _put_comment {
384 12 ▶ my ($self, @comments) = @_;
Subroutine _put_comment: called CC=3 SCAR=11.0
385  
386 # Comment string.
387 12 unshift @comments, '<!--';
388 12 ▶ if (substr($comments[$LAST_INDEX], $LAST_INDEX) eq '-') {
Branch: 1 branch
BranchTrueFalseTotal
if (substr($comments[$LAST_INDEX], $LAST_INDEX) eq '-') { } 1 11 12
389 1 push @comments, ' -->';
390 } else {
391 11 push @comments, '-->';
392 }
393  
394 # Process comment.
395 12 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{'tmp_code'};}) { } 8 4 12
396 8 push @{$self->{'tmp_comment_code'}}, \@comments;
397  
398 # Flag, that means comment is last.
399 8 $self->{'comment_flag'} = 1;
400 } else {
401 4 $self->_newline;
402 my $indent_comment = $self->{'indent_block'}->indent(
403 4 \@comments, $self->{'indent'}->get,
404 );
405 4 $self->_flush_code($indent_comment);
406 }
407 12 return;
408 }
409  
410 # Data.
411 sub _put_data {
412 25 ▶ my ($self, @data) = @_;
Subroutine _put_data: called CC=5 SCAR=16.1
413  
414 # Flush tmp code.
415 25 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 22 3 25
416 22 $self->_print_tag('>');
417 }
418  
419 # Process data callback.
420 25 ▶ if (none { defined $self->{'printed_tags'}->[0] && $_ eq $self->{'printed_tags'}->[0] }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 2 branches
BranchTrueFalseTotal
if (&none(sub { defined $self->{"printed_tags"}[0] and $_ eq $self->{"printed_tags"}[0]; } , @{$$self{"no_data_callback"};})) 24 1 25
defined $self->{"printed_tags"}[0] and $_ eq $self->{"printed_tags"}[0] 47 1 48
421 25 @{$self->{'no_data_callback'}}) {
422  
423 24 $self->_process_callback(\@data, 'data_callback');
424 }
425  
426 25 $self->_newline;
427 25 $self->{'preserve_obj'}->save_previous;
428 25 my $pre = $self->{'preserve_obj'}->get;
429 my $indent_data = $self->{'indent_word'}->indent(
430 (join $EMPTY_STR, @data),
431 25 ▶ $pre ? $EMPTY_STR : $self->{'indent'}->get,
Branch: 2 branches
BranchTrueFalseTotal
$pre ? : 3 22 25
$pre ? : 3 22 25
432 $pre ? 1 : 0
433 );
434  
435 25 $self->_flush_code($indent_data);
436 25 return;
437 }
438  
439 # End of tag.
440 sub _put_end_of_tag {
441 61 ▶ my ($self, $tag) = @_;
Subroutine _put_end_of_tag: called CC=12 SCAR=25.7
442 61 my $printed = shift @{$self->{'printed_tags'}};
443 61 ▶ if ($self->{'xml'} && $printed ne $tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"xml"} and $printed ne $tag) 0 61 61
Condition66%2/3
$self->{"xml"} and $printed ne $tag
!ll&&!rl&&r
38230
MC/DC0%0/2
$self->{"xml"} and $printed ne $tag
$self->{"xml"} $printed ne $tag
Truth table66%2/3
A and B
A= $self->{"xml"}B= $printed ne $tag
ABresult
0X0
100
111
444 0 err "Ending bad tag: '$tag' in block of tag '$printed'.";
445 }
446  
447 # Tag can be simple.
448 61 ▶ if ($self->{'xml'} && (! scalar @{$self->{'no_simple'}}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'xml'} and !scalar(@{$self->{'no_simple'};}) || &none(sub { $_ eq $tag; } , @{$$self{'no_simple'};})) { } 23 38 61
Condition50%3/6
$self->{"xml"} and !scalar(@{$self->{"no_simple"};}) || &none(sub { $_ eq $tag; } , @{$$self{"no_simple"};})
!ll&&!rl&&r
38023
not scalar @{$self->{"no_simple"};} or &none(sub { $_ eq $tag; } , @{$$self{"no_simple"};})
l!l&&r!l&&!r
2300
MC/DC33%1/3
$self->{"xml"} and !scalar(@{$self->{"no_simple"};}) || &none(sub { $_ eq $tag; } , @{$$self{"no_simple"};})
$self->{"xml"} not scalar @{$self->{"no_simple"};} &none(sub { $_ eq $tag; } , @{$$self{"no_simple"};})
Truth table50%2/4
A and not(B) or C
A= $self->{"xml"}B= not scalar @{$self->{"no_simple"};}C= &none(sub { $_ eq $tag; } , @{$$self{"no_simple"};})
ABCresult
0XX0
1000
11X1
1011
449 0 ▶ || none { $_ eq $tag } @{$self->{'no_simple'}})) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
450  
451 23 my $pre = $self->{'preserve_obj'}->end($tag);
452 23 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{'tmp_code'};}) { } 12 11 23
453 12 ▶ if (scalar @{$self->{'tmp_comment_code'}}
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{'tmp_comment_code'};} and $self->{'comment_flag'} == 1) { } 3 9 12
Condition100%3/3
scalar @{$self->{"tmp_comment_code"};} and $self->{"comment_flag"} == 1
!ll&&!rl&&r
813
MC/DC100%2/2
scalar @{$self->{"tmp_comment_code"};} and $self->{"comment_flag"} == 1
scalar @{$self->{"tmp_comment_code"};} $self->{"comment_flag"} == 1
Truth table100%3/3
A and B
A= scalar @{$self->{"tmp_comment_code"};}B= $self->{"comment_flag"} == 1
ABresult
0X0
100
111
454 && $self->{'comment_flag'} == 1) {
455  
456 3 $self->_print_tag('>');
457 # XXX $self->{'preserve_obj'}->end($tag);
458 3 $self->_print_end_tag($tag);
459 } else {
460 9 $self->_print_tag('/>');
461 9 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 9 0 9
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
009
MC/DC0%0/2
$self->{"non_indent"} or $pre
$self->{"non_indent"} $pre
Truth table33%1/3
A or B
A= $self->{"non_indent"}B= $pre
ABresult
1X1
011
000
462 9 $self->{'indent'}->remove;
463 }
464 }
465 } else {
466 11 $self->_print_end_tag($tag);
467 }
468  
469 # Tag cannot be simple.
470 } else {
471 38 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 7 31 38
472 7 unshift @{$self->{'printed_tags'}}, $tag;
473 7 $self->_print_tag('>');
474 7 shift @{$self->{'printed_tags'}};
475 # XXX $self->_newline;
476 }
477 38 $self->{'preserve_obj'}->end($tag);
478 38 $self->_print_end_tag($tag);
479 }
480 61 return;
481 }
482  
483 # Instruction.
484 sub _put_instruction {
485 1 ▶ my ($self, $target, $code) = @_;
Subroutine _put_instruction: called CC=3 SCAR=11.5
486  
487 # Flush tmp code.
488 1 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 0 1 1
489 0 $self->_print_tag('>');
490 }
491  
492 # Process instruction code.
493 1 ▶ if (ref $self->{'instruction'} eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'instruction'} eq 'CODE') { } 0 1 1
494 0 $self->{'instruction'}->($self, $target, $code);
495  
496 # Print instruction.
497 } else {
498 1 $self->_newline;
499 1 $self->{'preserve_obj'}->save_previous;
500 my $indent_instr = $self->{'indent_block'}->indent(
501 ['<?'.$target, $SPACE, $code, '?>',
502 1 $self->{'indent'}->get],
503 );
504 1 $self->_flush_code($indent_instr);
505 }
506  
507 1 return;
508 }
509  
510 # Raw data.
511 sub _put_raw {
512 11 ▶ my ($self, @raw_data) = @_;
Subroutine _put_raw: called CC=2 SCAR=6.9
513  
514 # Flush tmp code.
515 11 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 6 5 11
516 6 $self->_print_tag('>');
517 }
518  
519 # Process data callback.
520 11 $self->_process_callback(\@raw_data, 'raw_callback');
521  
522 # Added raw data to flush code.
523 11 $self->_flush_code(join $EMPTY_STR, @raw_data);
524  
525 # Set raw flag.
526 11 $self->{'raw_tag'} = 1;
527  
528 11 return;
529 }
530  
531 # Reset flush code.
532 sub _reset_flush {
533 66 ▶ my $self = shift;
Subroutine _reset_flush: called CC=1 SCAR=0.0
534 66 $self->{'flush_code'} = $EMPTY_STR;
535 66 return;
536 }
537  
538 20 1;
539  
540 __END__
↑ Summary