blib/lib/Data/Stag/ITextWriter.pm

filter: Statementstmt 84.3% 43 / 51 Branchbran 50.0% 5 / 10 Conditioncond 50.0% 2 / 4 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 76.9% 10 / 13 Podpod 33.3% 3 / 9 totaltotal 70.7% 63 / 89 CC 8 SCAR 7.4
CC
8
Cov
77%
start_event
3.1
end_event
3.0
itextesc
2.1
CRAP 2.1
« blib/lib/Data/Stag.pm ↑ Summary blib/lib/Data/Stag/DTDWriter.pm »
1 package Data::Stag::ITextWriter;
2  
3 =head1 NAME
4  
5 Data::Stag::ITextWriter - writes stag events into stag IText format
6  
7 =head1 SYNOPSIS
8  
9  
10 =cut
11  
12 =head1 DESCRIPTION
13  
14 =head1 PUBLIC METHODS -
15  
16 =cut
17  
18 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶use base qw(Data::Stag::Writer);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 $VERSION="0.14";
23  
24 0 ▶sub fmtstr {
Subroutine fmtstr: not called CC=1 SCAR=6.9
Pod undocumented
25 0 return 'itext';
26 }
27  
28  
29 31 ▶sub stack {
Subroutine stack: called CC=2 SCAR=7.1
Pod undocumented
30 31 my $self = shift;
31 31 ▶ $self->{_stack} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 31 31
32 31 return $self->{_stack};
33 }
34  
35 10 ▶sub indent_txt {
Subroutine indent_txt: called CC=1 SCAR=0.0
Pod undocumented
36 10 my $self = shift;
37 10 my $stack = $self->stack;
38 10 return " " x scalar(@$stack);
39 }
40  
41 0 ▶sub o {
Subroutine o: not called CC=1 SCAR=6.9
Pod undocumented
42 0 my $self = shift;
43 0 my @o = @_;
44 0 $self->addtext($self->indent_txt() . "@o");
45 }
46  
47 10 ▶sub start_event {
Subroutine start_event: called CC=3 SCAR=11.4
Pod documented
48 10 my $self = shift;
49 10 ▶ my $ev = shift || '';
Condition50%1/2
shift() || ''
l!l
100
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
50 10 my $stack = $self->stack;
51 10 my $tag = "$ev: ";
52 10 ▶ if ($self->use_color) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->use_color) 0 10 10
53 0 $tag = color('red').$ev.color('reset').':';
54 }
55 10 $self->addtext("\n" . $self->indent_txt() . $tag);
56 10 push(@$stack, $ev);
57 }
58 10 ▶sub end_event {
Subroutine end_event: called CC=3 SCAR=11.1
Pod documented
59 10 my $self = shift;
60 10 ▶ my $ev = shift || '';
Condition50%1/2
shift() || ''
l!l
100
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
61 10 my $stack = $self->stack;
62 10 my $top = pop @$stack;
63 1 ▶ use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
64 10 ▶ $top eq $ev or confess("$top ne $ev");
Branch: 1 branch
BranchTrueFalseTotal
$top eq $ev or confess("$top ne $ev") 10 0 10
65 10 return $ev;
66 }
67 7 ▶sub evbody {
Subroutine evbody: called CC=2 SCAR=7.1
Pod documented
68 7 my $self = shift;
69 7 my $body = shift;
70 7 my $str = itextesc($body);
71 7 ▶ if ($self->use_color) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->use_color) 0 7 7
72 0 $str = color('white').$str;
73 }
74 7 $self->addtext($str);
75 7 return;
76 }
77  
78 7 ▶sub itextesc {
Subroutine itextesc: called CC=2 SCAR=7.4
Pod undocumented
79 7 my $w = shift;
80 7 ▶ if (!defined($w)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $w) 0 7 7
81 0 $w='';
82 }
83 7 $w =~ s/:/\\:/g;
84 7 return $w;
85 }
86  
87 # this should already be require'd in Writer.pm
88 0 ▶sub color {
Subroutine color: not called CC=1 SCAR=6.9
Pod undocumented
89 0 Term::ANSIColor::color(@_);
90 }
91  
92  
93 1 1;
« blib/lib/Data/Stag.pm ↑ Summary blib/lib/Data/Stag/DTDWriter.pm »