blib/lib/Text/Trac/Ol.pm

filter: Statementstmt 93.8% 46 / 49 Branchbran 65.0% 13 / 20 Conditioncond 100% 7 / 7 MC/DCmcdc 100% 4 / 4 Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 86.2% 75 / 87 SCAR 28.7
CC
17
Cov
87%
parse
18.2
BEGIN
1.0
BEGIN
1.0
CRAP 17.7
« blib/lib/Text/Trac/Blockquote.pm ↑ Summary blib/lib/Text/Trac/BlockNode.pm »
1 package Text::Trac::Ol;
2  
3 48 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 48 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 48 ▶use base qw(Text::Trac::BlockNode);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 48 our $VERSION = '0.23';
8  
9 sub init {
10 160 ▶ my $self = shift;
Subroutine init: called CC=1 SCAR=0.0
Pod undocumented
11 160 $self->pattern(qr/(\s+) ([\daiAI])\. \s+ (.*)$/xms);
12 160 return $self;
13 }
14  
15 sub parse {
16 133 ▶ my ( $self, $l ) = @_;
Subroutine parse: called CC=17 SCAR=29.0
Pod undocumented
17 133 my $c = $self->{context};
18 133 my $pattern = $self->pattern;
19 133 ▶ $l =~ $pattern or return $l;
Branch: 1 branch
BranchTrueFalseTotal
$l =~ /$pattern/msx or return $l 57 76 133
20 76 my $type = $2;
21  
22 76 my $space = length($1);
23 76 ▶ my $level = $c->ol->{level} || 0;
Condition100%2/2
$c->ol->{'level'} || 0
l!l
5719
MC/DC100%1/1
$c->ol->{'level'} || 0
$c->ol->{'level'}
Truth table100%2/2
A
A= $c->ol->{'level'}
Aresult
11
00
24 76 ▶ $c->ol->{space} ||= 0;
Condition100%2/2
$c->ol->{"space"} ||= 0
l!l
5719
MC/DC100%1/1
$c->ol->{"space"} ||= 0
$c->ol->{"space"}
Truth table100%2/2
A
A= $c->ol->{"space"}
Aresult
11
00
25  
26 76 my $start_tag;
27 76 ▶ if ( $type =~ /(\d)/ ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($type =~ /(\d)/) { } 41 35 76
elsif ($type eq 'a') { } 35 0 35
elsif ($type eq 'A') { } 0 0 0
elsif ($type eq 'i') { } 0 0 0
elsif ($type eq 'I') { } 0 0 0
28 41 ▶ $start_tag = $type == 1 ? '<ol>' : qq{<ol start="$1">};
Branch: 1 branch
BranchTrueFalseTotal
$type == 1 ? : 29 12 41
29 }
30 elsif ( $type eq 'a' ) {
31 35 $start_tag = q{<ol class="loweralpha">};
32 }
33 elsif ( $type eq 'A' ) {
34 0 $start_tag = q{<ol class="upperalpha">};
35 }
36 elsif ( $type eq 'i' ) {
37 0 $start_tag = q{<ol class="lowerroman">};
38 }
39 elsif ( $type eq 'I' ) {
40 0 $start_tag = q{<ol class="upperroman">};
41 }
42  
43 76 ▶ if ( $space > $c->ol->{space} ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($space > $c->ol->{'space'}) { } 29 47 76
elsif ($space < $c->ol->{'space'}) { } 5 42 47
44 29 for ( 1 .. ( $space + 1 ) / 2 - $level ) {
45 31 $l = $start_tag . $l;
46 31 $level++;
47 }
48 }
49 elsif ( $space < $c->ol->{space} ) {
50 5 for ( 1 .. ( $c->ol->{space} - $space ) / 2 ) {
51 7 $l = '</li></ol>' . $l;
52 7 $level--;
53 }
54 5 $l =~ s!(?<=</(?:ol|li)>)(?= )!</li>!;
55 }
56 else {
57 42 $l = "</li>$l";
58 }
59  
60 76 $c->ol( { level => $level, space => $space } );
61  
62 # parse inline nodes
63 76 $l =~ s{ $pattern }{'<li>' . $self->replace($3)}xmsge;
64  
65 76 ▶ if ( $c->hasnext and $c->nextline =~ $pattern ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($c->hasnext and $c->nextline =~ /$pattern/msx) { } 57 19 76
Condition100%3/3
$c->hasnext and $c->nextline =~ /$pattern/msx
!ll&&!rl&&r
81157
MC/DC100%2/2
$c->hasnext and $c->nextline =~ /$pattern/msx
$c->hasnext $c->nextline =~ /$pattern/msx
Truth table100%3/3
A and B
A= $c->hasnextB= $c->nextline =~ /$pattern/msx
ABresult
0X0
100
111
66 57 $self->parse($l);
67 }
68 else {
69 19 for ( 1 .. $c->ol->{level} ) {
70 24 $l .= '</li></ol>';
71 }
72 19 $c->ol->{level} = 0;
73 19 $c->ol->{space} = 0;
74 }
75  
76 76 $c->htmllines($l);
77  
78 76 return;
79 }
80  
81 48 1;
« blib/lib/Text/Trac/Blockquote.pm ↑ Summary blib/lib/Text/Trac/BlockNode.pm »