blib/lib/Tags/Output/Indent.pm

filter: Statementstmt 97.0% 266 / 274 Branchbran 78.8% 71 / 90 Conditioncond 55.3% 26 / 47 MC/DCmcdc 26.6% 8 / 30 Subroutinesub 96.6% 29 / 30 Podpod 100% 2 / 2 totaltotal 84.9% 402 / 473 CC 64 SCAR 21.9
CC
64
Cov
88%
_print_tag
19.3
_put_end_of_tag
18.9
_put_attribute
6.6
CRAP 8.9
↑ 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.13;
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 58 ▶ my $self = shift;
Subroutine reset: called CC=1 SCAR=0.0
Pod documented
51  
52 # Comment flag.
53 58 $self->{'comment_flag'} = 0;
54  
55 # Indent object.
56 $self->{'indent'} = Indent->new(
57 58 'next_indent' => $self->{'next_indent'},
58 );
59  
60 # Indent::Word object.
61 $self->{'indent_word'} = Indent::Word->new(
62 58 '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 58 'next_indent' => $self->{'next_indent'},
70 'strict' => 0,
71 );
72  
73 # Flush code.
74 58 $self->_reset_flush;
75  
76 # Tmp code.
77 58 $self->{'tmp_code'} = [];
78 58 $self->{'tmp_comment_code'} = [];
79  
80 # Printed tags.
81 58 $self->{'printed_tags'} = [];
82  
83 # Non indent flag.
84 58 $self->{'non_indent'} = 0;
85  
86 # Flag, that means raw tag.
87 58 $self->{'raw_tag'} = 0;
88  
89 # Preserved object.
90 $self->{'preserve_obj'} = Tags::Utils::Preserve->new(
91 58 'preserved' => $self->{'preserved'},
92 );
93  
94 # Process flag.
95 58 $self->{'process'} = 0;
96  
97 58 return;
98 }
99  
100 # Check parameters to rigth values.
101 sub _check_params {
102 37 ▶ my $self = shift;
Subroutine _check_params: called CC=3 SCAR=11.0
103  
104 # Check params from SUPER.
105 37 $self->SUPER::_check_params();
106  
107 # Check 'attr_delimeter'.
108 35 ▶ if ($self->{'attr_delimeter'} ne q{"}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"attr_delimeter"} ne "\"" and $self->{"attr_delimeter"} ne "'") 1 34 35
Condition66%2/3
$self->{"attr_delimeter"} ne "\"" and $self->{"attr_delimeter"} ne "'"
!ll&&!rl&&r
3401
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 34 return;
115 }
116  
117 # Default parameters.
118 sub _default_parameters {
119 39 ▶ my $self = shift;
Subroutine _default_parameters: called CC=1 SCAR=0.0
120  
121 # Default parameters from SUPER.
122 39 $self->SUPER::_default_parameters();
123  
124 # Attribute callback.
125 39 $self->{'attr_callback'} = \&encode_attr_entities;
126  
127 # Attribute delimeter.
128 39 $self->{'attr_delimeter'} = '"';
129  
130 # Indent CDATA section.
131 39 $self->{'cdata_indent'} = 0;
132  
133 # CDATA callback.
134 39 $self->{'cdata_callback'} = undef;
135  
136 # Data callback.
137 39 $self->{'data_callback'} = \&encode_char_entities;
138  
139 # Callback to instruction.
140 39 $self->{'instruction'} = $EMPTY_STR;
141  
142 # Indent line size.
143 39 $self->{'line_size'} = $LINE_SIZE;
144  
145 # Next indent string.
146 39 $self->{'next_indent'} = $SPACE x 2;
147  
148 # No data callback.
149 39 $self->{'no_data_callback'} = ['script', 'style'];
150  
151 # No simple tags.
152 39 $self->{'no_simple'} = [];
153  
154 # Preserved tags.
155 39 $self->{'preserved'} = [];
156  
157 # Raw data callback.
158 39 $self->{'raw_callback'} = undef;
159  
160 # XML output.
161 39 $self->{'xml'} = 0;
162  
163 39 return;
164 }
165  
166 # Helper for flush data.
167 sub _flush_code {
168 290 ▶ my ($self, $code) = @_;
Subroutine _flush_code: called CC=2 SCAR=6.9
169 290 ▶ if (! $self->{'process'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"process"}) 57 233 290
170 57 $self->{'process'} = 1;
171 }
172 290 $self->{'flush_code'} .= $code;
173 290 return;
174 }
175  
176 # Print newline if need.
177 sub _newline {
178 174 ▶ my $self = shift;
Subroutine _newline: called CC=4 SCAR=13.9
179  
180 # Null raw tag (normal tag processing).
181 174 ▶ if ($self->{'raw_tag'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'raw_tag'}) { } 9 165 174
182 9 $self->{'raw_tag'} = 0;
183  
184 # Adding newline if flush_code.
185 } else {
186 165 my (undef, $pre_pre) = $self->{'preserve_obj'}->get;
187 165 ▶ if ($self->{'process'} && $pre_pre == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"process"} and $pre_pre == 0) 105 60 165
Condition100%3/3
$self->{"process"} and $pre_pre == 0
!ll&&!rl&&r
564105
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 105 $self->_flush_code($self->{'output_sep'});
189 }
190 }
191  
192 174 return;
193 }
194  
195 # Print indented tag from @{$self->{'tmp_code'}}.
196 sub _print_tag {
197 72 ▶ my ($self, $string) = @_;
Subroutine _print_tag: called CC=17 SCAR=29.6
198 72 ▶ if ($string) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string) 72 0 72
199 72 ▶ if ($string =~ /^\/>$/ms) {
Branch: 1 branch
BranchTrueFalseTotal
if ($string =~ m[^/>$]ms) 9 63 72
200 9 push @{$self->{'tmp_code'}}, $SPACE;
201 }
202 72 push @{$self->{'tmp_code'}}, $string;
203 }
204  
205 # Flush comment code before tag.
206 # TODO Optimalization.
207 72 ▶ if ($self->{'comment_flag'} == 0
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'comment_flag'} == 0 and scalar @{$self->{'tmp_comment_code'};}) { } 4 68 72
Condition100%2/2
$self->{"comment_flag"} == 0 and scalar @{$self->{"tmp_comment_code"};}
!ll
567
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 67 && 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 68 my $pre = $self->{'preserve_obj'}->get;
238 68 my $act_indent;
239 68 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 68 0 68
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
0068
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 68 $act_indent = $self->{'indent'}->get;
241 }
242 68 $self->_newline;
243  
244 # Get indent string and put to flush.
245 my $tmp = $self->{'indent_block'}->indent(
246 68 ▶ $self->{'tmp_code'}, $act_indent, $pre ? 1 : 0
Branch: 1 branch
BranchTrueFalseTotal
$pre ? : 0 68 68
247 );
248 68 $self->_flush_code($tmp);
249  
250 68 $self->{'tmp_code'} = [];
251 68 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 68 0 68
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
0068
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 68 $self->{'indent'}->add;
253 }
254 68 $self->{'preserve_obj'}->begin($self->{'printed_tags'}->[0]);
255  
256 # Comment from tmp place.
257 68 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 72 $self->{'tmp_comment_code'} = [];
265 72 return;
266 }
267  
268 # Print indented end of tag.
269 sub _print_end_tag {
270 57 ▶ my ($self, $string) = @_;
Subroutine _print_end_tag: called CC=5 SCAR=16.5
271 57 my $act_indent;
272 57 my ($pre, $pre_pre) = $self->{'preserve_obj'}->get;
273 57 ▶ if (! $self->{'non_indent'} && ! $pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"non_indent"} or $pre) 57 0 57
Condition33%1/3
$self->{"non_indent"} or $pre
l!l&&r!l&&!r
0057
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 57 $self->{'indent'}->remove;
275 57 ▶ if (! $pre_pre) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($pre_pre) 53 4 57
276 53 $act_indent = $self->{'indent'}->get;
277 }
278 }
279 57 $self->_newline;
280 57 ▶ my $indent_end = $self->{'indent_block'}->indent(
Branch: 1 branch
BranchTrueFalseTotal
$pre ? : 0 57 57
281 ['</'.$string, '>'], $act_indent, $pre ? 1 : 0,
282 );
283 57 $self->_flush_code($indent_end);
284 57 return;
285 }
286  
287 # Attributes.
288 sub _put_attribute {
289 21 ▶ my ($self, $attr, $value) = @_;
Subroutine _put_attribute: called CC=6 SCAR=18.8
290  
291 # Check to 'tmp_code'.
292 21 ▶ if (! @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@{$self->{"tmp_code"};}) 0 21 21
293 0 err 'Bad tag type \'a\'.';
294 }
295  
296 # Check to pairs in XML mode.
297 21 ▶ if ($self->{'xml'} && ! defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"xml"} and not defined $value) 0 21 21
Condition66%2/3
$self->{"xml"} and not defined $value
!ll&&!rl&&r
10110
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 21 my @attr = ($attr);
303 21 ▶ if (defined $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 21 0 21
304 21 push @attr, $value;
305 }
306 21 $self->_process_callback(\@attr, 'attr_callback');
307  
308 # Process attribute.
309 21 push @{$self->{'tmp_code'}}, $SPACE, $attr[0];
310 21 ▶ if (defined $attr[1]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $attr[1]) 21 0 21
311 21 push @{$self->{'tmp_code'}}, q{=}, $self->{'attr_delimeter'}.
312 21 $attr[1].$self->{'attr_delimeter'};
313 }
314  
315 # Reset comment flag.
316 21 $self->{'comment_flag'} = 0;
317  
318 21 return;
319 }
320  
321 # Begin of tag.
322 sub _put_begin_of_tag {
323 72 ▶ my ($self, $tag) = @_;
Subroutine _put_begin_of_tag: called CC=2 SCAR=6.9
324  
325 # Flush tmp code.
326 72 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 14 58 72
327 14 $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 72 push @{$self->{'tmp_code'}}, "<$tag";
337  
338 # Added tag to printed tags.
339 72 unshift @{$self->{'printed_tags'}}, $tag;
340  
341 72 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 27 ▶ my ($self, @data) = @_;
Subroutine _put_data: called CC=5 SCAR=16.1
413  
414 # Flush tmp code.
415 27 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 24 3 27
416 24 $self->_print_tag('>');
417 }
418  
419 # Process data callback.
420 27 ▶ 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"};})) 26 1 27
defined $self->{"printed_tags"}[0] and $_ eq $self->{"printed_tags"}[0] 51 1 52
421 27 @{$self->{'no_data_callback'}}) {
422  
423 26 $self->_process_callback(\@data, 'data_callback');
424 }
425  
426 27 $self->_newline;
427 27 $self->{'preserve_obj'}->save_previous;
428 27 my $pre = $self->{'preserve_obj'}->get;
429 my $indent_data = $self->{'indent_word'}->indent(
430 (join $EMPTY_STR, @data),
431 27 ▶ $pre ? $EMPTY_STR : $self->{'indent'}->get,
Branch: 2 branches
BranchTrueFalseTotal
$pre ? : 4 23 27
$pre ? : 4 23 27
432 $pre ? 1 : 0
433 );
434  
435 27 $self->_flush_code($indent_data);
436 27 return;
437 }
438  
439 # End of tag.
440 sub _put_end_of_tag {
441 66 ▶ my ($self, $tag) = @_;
Subroutine _put_end_of_tag: called CC=16 SCAR=29.4
442 66 my $printed = shift @{$self->{'printed_tags'}};
443 66 ▶ if ($self->{'xml'} && $printed ne $tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"xml"} and $printed ne $tag) 0 66 66
Condition66%2/3
$self->{"xml"} and $printed ne $tag
!ll&&!rl&&r
43230
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 66 ▶ 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 43 66
Condition50%3/6
$self->{"xml"} and !scalar(@{$self->{"no_simple"};}) || &none(sub { $_ eq $tag; } , @{$$self{"no_simple"};})
!ll&&!rl&&r
43023
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, $pre_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 3 $self->_print_end_tag($tag);
458 } else {
459 9 $self->_print_tag('/>');
460 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
461 9 $self->{'indent'}->remove;
462 }
463 }
464 } else {
465 11 $self->_print_end_tag($tag);
466 }
467  
468 # If we just ended a preserved element ($pre_pre == 1), reset the previous flag
469 # so that the next element will start on a new line
470 23 ▶ if ($pre == 0 && $pre_pre == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre == 0 and $pre_pre == 1) 0 23 23
Condition33%1/3
$pre == 0 and $pre_pre == 1
!ll&&!rl&&r
0230
MC/DC0%0/2
$pre == 0 and $pre_pre == 1
$pre == 0 $pre_pre == 1
Truth table33%1/3
A and B
A= $pre == 0B= $pre_pre == 1
ABresult
0X0
100
111
471 0 $self->{'preserve_obj'}->save_previous;
472 }
473  
474 # Tag cannot be simple.
475 } else {
476 43 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 8 35 43
477 8 unshift @{$self->{'printed_tags'}}, $tag;
478 8 $self->_print_tag('>');
479 8 shift @{$self->{'printed_tags'}};
480 }
481 43 my ($pre, $pre_pre) = $self->{'preserve_obj'}->end($tag);
482 43 $self->_print_end_tag($tag);
483  
484 # If we just ended a preserved element ($pre_pre == 1), reset the previous flag
485 # so that the next element will start on a new line
486 43 ▶ if ($pre == 0 && $pre_pre == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pre == 0 and $pre_pre == 1) 4 39 43
Condition66%2/3
$pre == 0 and $pre_pre == 1
!ll&&!rl&&r
0394
MC/DC50%1/2
$pre == 0 and $pre_pre == 1
$pre == 0 $pre_pre == 1
Truth table66%2/3
A and B
A= $pre == 0B= $pre_pre == 1
ABresult
0X0
100
111
487 4 $self->{'preserve_obj'}->save_previous;
488 }
489 }
490 66 return;
491 }
492  
493 # Instruction.
494 sub _put_instruction {
495 1 ▶ my ($self, $target, $code) = @_;
Subroutine _put_instruction: called CC=3 SCAR=11.5
496  
497 # Flush tmp code.
498 1 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 0 1 1
499 0 $self->_print_tag('>');
500 }
501  
502 # Process instruction code.
503 1 ▶ if (ref $self->{'instruction'} eq 'CODE') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->{'instruction'} eq 'CODE') { } 0 1 1
504 0 $self->{'instruction'}->($self, $target, $code);
505  
506 # Print instruction.
507 } else {
508 1 $self->_newline;
509 1 $self->{'preserve_obj'}->save_previous;
510 my $indent_instr = $self->{'indent_block'}->indent(
511 ['<?'.$target, $SPACE, $code, '?>',
512 1 $self->{'indent'}->get],
513 );
514 1 $self->_flush_code($indent_instr);
515 }
516  
517 1 return;
518 }
519  
520 # Raw data.
521 sub _put_raw {
522 11 ▶ my ($self, @raw_data) = @_;
Subroutine _put_raw: called CC=2 SCAR=6.9
523  
524 # Flush tmp code.
525 11 ▶ if (scalar @{$self->{'tmp_code'}}) {
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @{$self->{"tmp_code"};}) 6 5 11
526 6 $self->_print_tag('>');
527 }
528  
529 # Process data callback.
530 11 $self->_process_callback(\@raw_data, 'raw_callback');
531  
532 # Added raw data to flush code.
533 11 $self->_flush_code(join $EMPTY_STR, @raw_data);
534  
535 # Set raw flag.
536 11 $self->{'raw_tag'} = 1;
537  
538 11 return;
539 }
540  
541 # Reset flush code.
542 sub _reset_flush {
543 68 ▶ my $self = shift;
Subroutine _reset_flush: called CC=1 SCAR=0.0
544 68 $self->{'flush_code'} = $EMPTY_STR;
545 68 return;
546 }
547  
548 20 1;
549  
550 __END__
↑ Summary