blib/lib/HTML/Subtext.pm

filter: Statementstmt 91.3% 42 / 46 Branchbran 81.2% 13 / 16 Conditioncond 66.6% 4 / 6 MC/DCmcdc 50.0% 2 / 4 Subroutinesub 100% 8 / 8 Podpod 80.0% 4 / 5 totaltotal 85.8% 73 / 85 CC 11 SCAR 11.1
CC
11
Cov
87%
start
4.4
output
4.2
end
3.0
CRAP 3.0
↑ Summary
1 package HTML::Subtext;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use URI::Escape;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use vars qw($VERSION @ISA);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 require HTML::Filter;
8 1 @ISA=qw(HTML::Filter);
9  
10 1 $VERSION = '1.03';
11  
12 2 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
13 2 my $class = shift;
14 2 my $self = $class->SUPER::new();
15 2 ▶ while (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 2 6
16 4 my $key = shift;
17 4 my $val = shift;
18 4 $self->{$key} = $val;
19 }
20 2 return $self;
21 }
22  
23 28 ▶sub output {
Subroutine output: called CC=4 SCAR=14.5
Pod undocumented
24 28 my $self = shift;
25 28 my $output = $self->{'OUTPUT'};
26 28 ▶ if ($output) {
Branch: 1 branch
BranchTrueFalseTotal
if ($output) { } 28 0 28
27 28 my $type = ref($output);
28 28 ▶ if ($type eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if ($type eq 'ARRAY') { } 14 14 28
elsif ($type eq 'SCALAR') { } 14 0 14
29 14 push(@{$output}, $_[0]);
30 }
31 elsif ($type eq 'SCALAR') {
32 14 $$output .= $_[0];
33 }
34 else {
35 0 print $output $_[0];
36 }
37 }
38 else {
39 0 $self->SUPER::output(@_);
40 }
41 }
42  
43 12 ▶sub start {
Subroutine start: called CC=4 SCAR=14.8
Pod documented
44 12 my $self = shift;
45 12 my $tag = $_[0];
46 12 ▶ if ($tag eq 'a' && $_[1]{'href'} =~ /^subtext:(.*)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag eq 'a' and $_[1]{'href'} =~ /^subtext:(.*)/) { } 4 8 12
Condition66%2/3
$tag eq "a" and $_[1]{"href"} =~ /^subtext:(.*)/
!ll&&!rl&&r
804
MC/DC50%1/2
$tag eq "a" and $_[1]{"href"} =~ /^subtext:(.*)/
$tag eq "a" $_[1]{"href"} =~ /^subtext:(.*)/
Truth table66%2/3
A and B
A= $tag eq "a"B= $_[1]{"href"} =~ /^subtext:(.*)/
ABresult
0X0
100
111
47 ($self->{subtext} = $self->{'CONTEXT'}{uri_unescape($1)})
48 0 ▶ || do { warn "WARNING: HTML::Subtext -- no context for " . $_[3] . "\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"subtext"} = $self->{"CONTEXT"}{uri_unescape($1)} or do { warn 'WARNING: HTML::Subtext -- no context for ' . $_[3] . "\n"; $self->SUPER::start(@_) } 4 0 4
49 0 $self->SUPER::start(@_); }
50 }
51 else {
52 8 $self->SUPER::start(@_);
53 }
54 }
55  
56 12 ▶sub text {
Subroutine text: called CC=2 SCAR=6.9
Pod documented
57 12 my $self = shift;
58 12 ▶ if ($self->{subtext}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'subtext'}) { } 4 8 12
59 4 $self->output($self->{subtext});
60 }
61 else {
62 8 $self->SUPER::text(@_);
63 }
64 }
65  
66 12 ▶sub end {
Subroutine end: called CC=3 SCAR=11.0
Pod documented
67 12 my $self = shift;
68 12 my $tag = $_[0];
69 12 ▶ if ($self->{subtext} && $tag eq 'a') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'subtext'} and $tag eq 'a') { } 4 8 12
Condition66%2/3
$self->{"subtext"} and $tag eq "a"
!ll&&!rl&&r
804
MC/DC50%1/2
$self->{"subtext"} and $tag eq "a"
$self->{"subtext"} $tag eq "a"
Truth table66%2/3
A and B
A= $self->{"subtext"}B= $tag eq "a"
ABresult
0X0
100
111
70 4 $self->{subtext} = 0;
71 }
72 else {
73 8 $self->SUPER::end(@_);
74 }
75 }
76  
77 1 1;
78 __END__
↑ Summary