blib/lib/HTML/EP/Parser.pm

filter: Statementstmt 98.2% 56 / 57 Branchbran 75.0% 18 / 24 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 13 / 13 Podpod 100% 6 / 6 totaltotal 89.5% 94 / 105 CC 14 SCAR 11.9
CC
14
Cov
89%
new
7.8
Clone
3.1
start
2.0
CRAP 3.3
« blib/lib/HTML/EP/Session/DBI.pm ↑ Summary blib/lib/HTML/EP/Session/DBIq.pm »
1 # -*- perl -*-
2 #
3 # HTML::EP - A Perl based HTML extension.
4 #
5 #
6 # Copyright (C) 1998 Jochen Wiedmann
7 # Am Eisteich 9
8 # 72555 Metzingen
9 # Germany
10 #
11 # Email: joe@ispsoft.de
12 #
13 #
14 # Portions Copyright (C) 1999 OnTV Pittsburgh, L.P.
15 # 123 University St.
16 # Pittsburgh, PA 15213
17 # USA
18 #
19 # Phone: 1 412 681 5230
20 # Developer: Jason McMullan <jmcc@ontv.com>
21 # Developer: Erin Glendenning <erg@ontv.com>
22 #
23 #
24 # All rights reserved.
25 #
26 # You may distribute this module under the terms of either
27 # the GNU General Public License or the Artistic License, as
28 # specified in the Perl README file.
29 #
30 ############################################################################
31  
32 10 ▶use HTML::Parser ();
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34  
35 package HTML::EP::Parser;
36  
37 10 $HTML::EP::Parser::VERSION = '0.01';
38 10 @HTML::EP::Parser::ISA = qw(HTML::Parser);
39  
40  
41 89 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
42 89 my $self = shift->SUPER::new(@_);
43 89 $self->{'_ep_tokens'} = [];
44 89 $self->{'_ep_text'} = undef;
45 89 $self;
46 }
47  
48 1 ▶sub declaration {
Subroutine declaration: called CC=1 SCAR=0.0
Pod documented
49 1 my($self, $decl) = @_;
50 1 $self->text("<!$decl>");
51 }
52  
53 274 ▶sub start {
Subroutine start: called CC=2 SCAR=6.9
Pod documented
54 274 my($self, $tag, $attr, $attrseq, $origtext) = @_;
55 274 ▶ return $self->text($origtext) unless $tag =~ /^ep-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $tag =~ /^ep-/ 42 232 274
56 232 push(@{$self->{'_ep_tokens'}},
57 {'type' => 'S',
58 'tag' => $tag,
59 'attr' => $attr,
60 'attrseq' => $attrseq,
61 'origtext' => $origtext});
62 232 $self->{'_ep_text'} = undef;
63 }
64  
65 132 ▶sub end {
Subroutine end: called CC=2 SCAR=6.9
Pod documented
66 132 my($self, $tag, $origtext) = @_;
67 132 ▶ return $self->text($origtext) unless $tag =~ /^ep-/;
Branch: 1 branch
BranchTrueFalseTotal
unless $tag =~ /^ep-/ 41 91 132
68 91 push(@{$self->{'_ep_tokens'}},
69 {'type' => 'E', 'tag' => $tag, 'origtext' => $origtext});
70 91 $self->{'_ep_text'} = undef;
71 }
72  
73 438 ▶sub text {
Subroutine text: called CC=2 SCAR=6.9
Pod documented
74 438 my($self, $text) = @_;
75 438 ▶ if (my $t = $self->{'_ep_text'}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $t = $self->{'_ep_text'}) { } 165 273 438
76 165 $t->{'text'} .= $text;
77 } else {
78 273 push(@{$self->{'_ep_tokens'}},
79 273 ($self->{'_ep_text'} = {'type' => 'T', 'text' => $text}));
80 }
81 }
82  
83 2 ▶sub comment {
Subroutine comment: called CC=1 SCAR=0.0
Pod documented
84 2 my($self, $comment) = @_;
85 2 $self->text("<!--$comment-->");
86 }
87  
88  
89 package HTML::EP::Tokens;
90  
91 89 ▶sub new {
Subroutine new: called CC=6 SCAR=20.5
92 89 my $proto = shift;
93 0 ▶ my $self = { (@_ == 1) ? %{shift()} : @_ };
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 0 89 89
94 89 ▶ die "Missing token array" unless exists $self->{'tokens'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"tokens"} 0 89 89
95 89 ▶ $self->{'first'} = 0 unless exists $self->{'first'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"first"} 89 0 89
96 89 ▶ $self->{'last'} = @{$self->{'tokens'}} unless exists $self->{'last'};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"last"} 89 0 89
97 89 ▶ bless($self, (ref($proto) || $proto));
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
0890
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
98 }
99  
100 91 ▶sub Clone {
Subroutine Clone: called CC=3 SCAR=11.3
101 91 my($proto, $first, $last) = @_;
102 91 my $self = {%$proto};
103 91 ▶ $self->{'first'} = $first if defined $first;
Branch: 1 branch
BranchTrueFalseTotal
if defined $first 91 0 91
104 91 ▶ $self->{'last'} = $last if defined $first;
Branch: 1 branch
BranchTrueFalseTotal
if defined $first 91 0 91
105 91 bless($self, ref($proto));
106 }
107  
108 335 ▶sub First {
Subroutine First: called CC=2 SCAR=6.9
109 335 my $self = shift;
110 335 ▶ if (@_) { $self->{'first'} = shift() } else { $self->{'first'} }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 75 260 335
111 }
112 150 ▶sub Last {
Subroutine Last: called CC=2 SCAR=6.9
113 150 my $self = shift;
114 150 ▶ if (@_) { $self->{'last'} = shift() } else { $self->{'last'} }
Branch: 1 branch
BranchTrueFalseTotal
if (@_) { } 75 75 150
115 }
116 1047 ▶sub Token {
Subroutine Token: called CC=2 SCAR=6.9
117 1047 my $self = shift();
118 1047 my $first = $self->{'first'};
119 1047 ▶ return undef if $first >= $self->{'last'};
Branch: 1 branch
BranchTrueFalseTotal
if $first >= $self->{"last"} 224 823 1047
120 823 $self->{'first'} = $first+1;
121 823 $self->{'tokens'}->[$first];
122 }
123 3 ▶sub Replace {
Subroutine Replace: called CC=1 SCAR=0.0
124 3 my($self, $index, $token) = @_;
125 3 $self->{'tokens'}->[$index] = $token;
126 }
127  
128 10 1;
« blib/lib/HTML/EP/Session/DBI.pm ↑ Summary blib/lib/HTML/EP/Session/DBIq.pm »