| 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
| |||||||||||||
| 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() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 50 | 10 | my $stack = $self->stack; | |||||||||||
| 51 | 10 | my $tag = "$ev: "; | |||||||||||
| 52 | 10 | ▶ | if ($self->use_color) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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() || ''
MC/DC0%0/1
shift() || ''
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 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; | |||||||||||