Structured/PRE.pm

filter: Statementstmt 100% 38 / 38 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 94.4% 51 / 54 CC 5 SCAR 7.4
CC
5
Cov
100%
new
3.0
process
3.0
BEGIN
1.0
CRAP 2.1
« Structured/Factory.pm ↑ Summary Structured/BQ.pm »
1 package MKDoc::Text::Structured::PRE;
2 20 ▶use base qw /MKDoc::Text::Structured::Base/;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 20 ▶use MKDoc::Text::Structured::Inline;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 20 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 20 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7  
8 sub new
9 258 ▶{
Subroutine new: called CC=3 SCAR=11.0
Pod undocumented
10 258 my $class = shift;
11 258 my $line = shift;
12  
13 258 ▶ $line =~ s/^\s*$// and return;
Branch: 1 branch
BranchTrueFalseTotal
$line =~ s/^\s*$// and return 42 216 258
14  
15 216 my ($indent) = $line =~ /^(\s+)/;
16 216 ▶ return unless ($indent);
Branch: 1 branch
BranchTrueFalseTotal
unless $indent 205 11 216
17  
18 11 my $self = $class->SUPER::new();
19 11 $self->{indent} = $indent;
20 11 return $self;
21 }
22  
23  
24 sub is_ok
25 22 ▶{
Subroutine is_ok: called CC=1 SCAR=0.0
Pod undocumented
26 22 my $self = shift;
27 22 my $line = shift;
28 22 return $line =~ /^\s/;
29 }
30  
31  
32 sub process
33 9 ▶{
Subroutine process: called CC=3 SCAR=11.0
Pod undocumented
34 9 my $self = shift;
35 9 my @lines = @{$self->{lines}};
36 9 my $indent = $self->{indent};
37 9 for (@lines)
38 {
39 15 my ($_indent) = $_ =~ /^(\s+)/;
40 15 ▶ $indent = $_indent if (length ($_indent) lt length ($indent));
Branch: 1 branch
BranchTrueFalseTotal
if length $_indent lt length $indent 2 13 15
41 }
42 9 my $text = join "\n", map { s/^$indent//; $_ } @lines;
43  
44 # minimal encoding since we don't want all
45 # the inline fluff
46 9 $text =~ s/&/&/g;
47 9 $text =~ s/</&lt;/g;
48 9 $text =~ s/>/&gt;/g;
49  
50 9 return "<pre>$text</pre>";
51 }
52  
53  
54 20 1;
55  
56  
57 __END__
« Structured/Factory.pm ↑ Summary Structured/BQ.pm »