Structured/OL.pm

filter: Statementstmt 98.1% 53 / 54 Branchbran 80.0% 16 / 20 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 4 totaltotal 86.8% 79 / 91 CC 12 SCAR 14.6
CC
12
Cov
92%
is_ok
6.1
process_li
6.0
new
2.0
CRAP 4.3
« Structured.pm ↑ Summary Structured/UL.pm »
1 package MKDoc::Text::Structured::OL;
2 20 ▶use base qw /MKDoc::Text::Structured::Base/;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 ▶use MKDoc::Text::Structured::LI;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 sub new
9 267 ▶{
Subroutine new: called CC=2 SCAR=6.9
Pod undocumented
10 267 my $class = shift;
11 267 my $line = shift;
12  
13 267 my ($marker) = $line =~ /^(\d+\.\s+)/;
14 267 ▶ return unless ($marker);
Branch: 1 branch
BranchTrueFalseTotal
unless $marker 261 6 267
15  
16 6 my $self = $class->SUPER::new();
17 6 $self->{indent_re} = " " x length ($marker);
18 6 return $self;
19 }
20  
21  
22 sub is_ok
23 29 ▶{
Subroutine is_ok: called CC=6 SCAR=18.1
Pod undocumented
24 29 my $self = shift;
25 29 ▶ $self->{lines} || return 1;
Branch: 1 branch
BranchTrueFalseTotal
$self->{"lines"} or return 1 23 6 29
26  
27 23 my $line = shift;
28 23 my $re = $self->{indent_re};
29 23 ▶ $line eq '' and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$line eq "" and return 1 9 14 23
30 14 ▶ $line =~ /^\s+$/ and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^\s+$/ and return 1 0 14 14
31 14 ▶ $line =~ /^$re/ and return 1;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ /^$re/ and return 1 11 3 14
32  
33 3 my ($marker) = $line =~ /^(\d+\.\s+)/;
34 3 ▶ $marker and do {
Branch: 1 branch
BranchTrueFalseTotal
$marker and do { $self->{"indent_re"} = " " x length($marker); return 1 } 3 0 3
35 3 $self->{indent_re} = " " x length ($marker);
36 3 return 1;
37 };
38 0 return;
39 }
40  
41  
42 sub process
43 6 ▶{
Subroutine process: called CC=1 SCAR=0.0
Pod undocumented
44 6 my $self = shift;
45 6 my @lines = @{$self->{lines}};
46 6 my $text = join "\n", @lines;
47 6 $text = $self->process_li ($text);
48 6 return "<ol>$text</ol>";
49 }
50  
51  
52 sub process_li
53 6 ▶{
Subroutine process_li: called CC=6 SCAR=18.0
Pod undocumented
54 6 my $self = shift;
55 6 my $text = shift;
56 6 my @lines = split /\n/, $text;
57 6 my @result = ();
58 6 my $current = undef;
59  
60 6 ▶ while (scalar @lines)
Branch: 1 branch
BranchTrueFalseTotal
if (scalar @lines) 32 6 38
61 {
62 32 my $line = shift (@lines);
63 32 ▶ $current ||= new MKDoc::Text::Structured::LI ($line);
Condition66%2/3
$current ||= "MKDoc::Text::Structured::LI"->new($line)
l!l&&r!l&&!r
2390
MC/DC0%0/2
$current ||= "MKDoc::Text::Structured::LI"->new($line)
$current "MKDoc::Text::Structured::LI"->new($line)
Truth table66%2/3
A ||= B
A= $currentB= "MKDoc::Text::Structured::LI"->new($line)
ABresult
1X1
011
000
64 32 ▶ $current || next;
Branch: 1 branch
BranchTrueFalseTotal
$current or next 32 0 32
65  
66 32 ▶ if ($current->is_ok ($line))
Branch: 1 branch
BranchTrueFalseTotal
if ($current->is_ok($line)) { } 29 3 32
67 {
68 29 $current->add_line ($line);
69 }
70 else
71 {
72 3 push @result, $current->process();
73 3 unshift (@lines, $line);
74 3 $current = undef;
75 }
76 }
77  
78 6 ▶ push @result, $current->process() if ($current);
Branch: 1 branch
BranchTrueFalseTotal
if $current 6 0 6
79 6 return join "\n", @result;
80 }
81  
82  
83 20 1;
84  
85  
86 __END__
« Structured.pm ↑ Summary Structured/UL.pm »