blib/lib/Tags/Output/PYX.pm

filter: Statementstmt 100% 62 / 62 Branchbran 100% 4 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod n/a totaltotal 100% 80 / 80 CC 3 SCAR 2.2
CC
3
Cov
100%
_put_end_of_tag
2.0
_put_instruction
2.0
BEGIN
1.0
CRAP 1.2
↑ Summary
1 package Tags::Output::PYX;
2  
3 13 ▶use base qw(Tags::Output);
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 13 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 13 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use Tags::Utils qw(encode_newline);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # Constants.
12 13 Readonly::Scalar my $EMPTY_STR => q{};
13 13 Readonly::Scalar my $SPACE => q{ };
14  
15 13 our $VERSION = 0.05;
16  
17 # Attributes.
18 9 ▶sub _put_attribute {
Subroutine _put_attribute: called CC=1 SCAR=0.0
19 9 my ($self, $attr, $value) = @_;
20 9 push @{$self->{'flush_code'}}, "A$attr $value";
21 9 return;
22 }
23  
24 # Begin of tag.
25 22 ▶sub _put_begin_of_tag {
Subroutine _put_begin_of_tag: called CC=1 SCAR=0.0
26 22 my ($self, $tag) = @_;
27 22 push @{$self->{'flush_code'}}, "($tag";
28 22 unshift @{$self->{'printed_tags'}}, $tag;
29 22 return;
30 }
31  
32 # CData.
33 1 ▶sub _put_cdata {
Subroutine _put_cdata: called CC=1 SCAR=0.0
34 1 my ($self, @cdata) = @_;
35 1 $self->_put_data(@cdata);
36 1 return;
37 }
38  
39 # Comment.
40 2 ▶sub _put_comment {
Subroutine _put_comment: called CC=1 SCAR=0.0
41 2 my ($self, @comments) = @_;
42 $self->_put_data(
43 2 map { '<!--'.$_.'-->' } @comments,
44 );
45 2 return;
46 }
47  
48 # Data.
49 12 ▶sub _put_data {
Subroutine _put_data: called CC=1 SCAR=0.0
50 12 my ($self, @data) = @_;
51 12 my $data = join($EMPTY_STR, @data);
52 12 push @{$self->{'flush_code'}}, '-'.encode_newline($data);
53 12 return;
54 }
55  
56 # End of tag.
57 22 ▶sub _put_end_of_tag {
Subroutine _put_end_of_tag: called CC=2 SCAR=6.9
58 22 my ($self, $tag) = @_;
59 22 my $printed = shift @{$self->{'printed_tags'}};
60 22 ▶ if ($printed ne $tag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($printed ne $tag) 1 21 22
61 1 err "Ending bad tag: '$tag' in block of tag '$printed'.";
62 }
63 21 push @{$self->{'flush_code'}}, ")$tag";
64 21 return;
65 }
66  
67 # Instruction.
68 2 ▶sub _put_instruction {
Subroutine _put_instruction: called CC=2 SCAR=6.9
69 2 my ($self, $target, $code) = @_;
70  
71 # Construct instruction line.
72 2 my $instruction = '?'.$target;
73 2 ▶ if ($code) {
Branch: 1 branch
BranchTrueFalseTotal
if ($code) 1 1 2
74 1 $instruction .= $SPACE.$code;
75 }
76  
77 # To flush code.
78 2 push @{$self->{'flush_code'}}, encode_newline($instruction);
79  
80 2 return;
81 }
82  
83 # Raw data.
84 1 ▶sub _put_raw {
Subroutine _put_raw: called CC=1 SCAR=0.0
85 1 my ($self, @raw_data) = @_;
86 1 $self->_put_data(@raw_data);
87 1 return;
88 }
89  
90 13 1;
91  
92 __END__
↑ Summary