blib/lib/Text/Format.pm

filter: Statementstmt 58.2% 166 / 285 Branchbran 39.0% 110 / 282 Conditioncond 42.3% 47 / 111 MC/DCmcdc 15.8% 10 / 63 Subroutinesub 41.3% 12 / 29 Podpod 100% 23 / 23 totaltotal 46.4% 368 / 793 CC 186 SCAR 40.4
CC
186
Cov
48%
__do_break
210.0
format
119.8
config
54.8
CRAP 56.8
↑ Summary
1 package Text::Format;
2 3 $Text::Format::VERSION = '0.63';
3 3 require 5.006;
4  
5  
6 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 # local abbreviations, you can add your own with abbrevs()
12 3 my %abbrev = (
13 Mr => 1,
14 Mrs => 1,
15 Ms => 1,
16 Jr => 1,
17 Sr => 1,
18 );
19  
20 # formats text into a nice paragraph format. can set a variety of
21 # attributes such as first line indent, body indent, left and right
22 # margin, right align, right fill with spaces, non-breaking spaces,
23 # justification to both margins
24 sub format($@)
25 13 ▶{
Subroutine format: called CC=38 SCAR=47.9
Pod documented
26 13 my $this = shift;
27 13 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 13 13
28 unless ref $this;
29 13 ▶ my @wrap = @_
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 0 13 0 13
30 if @_ > 0;
31  
32 0 ▶ @wrap = @{ $_[0] }
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "ARRAY" 0 13 13
33 if ref $_[0] eq 'ARRAY';
34 0 ▶ @wrap = @{ $this->{'_text'} }
Branch: 1 branch
BranchTrueFalseTotal
if @wrap < 1 0 13 13
35 if @wrap < 1;
36  
37 13 my $findent = ' ' x $this->{'_findent'};
38 13 my $bindent = ' ' x $this->{'_bindent'};
39  
40 13 my @words = split /\s+/, join ' ', @wrap;
41 shift @words
42 13 ▶ unless defined( $words[0] ) && $words[0] ne '';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $words[0] and $words[0] ne "" 0 13 13
Condition33%1/3
defined $words[0] and $words[0] ne ""
!ll&&!rl&&r
0013
MC/DC0%0/2
defined $words[0] and $words[0] ne ""
defined $words[0] $words[0] ne ""
Truth table33%1/3
A and B
A= defined $words[0]B= $words[0] ne ""
ABresult
0X0
100
111
43  
44 #if $words[0] eq '';
45  
46 13 @wrap = ();
47 13 my ( $line, $width, $abbrev );
48 13 $abbrev = 0;
49 $width =
50 $this->{'_cols'} -
51 $this->{'_findent'} -
52 $this->{'_lmargin'} -
53 13 $this->{'_rmargin'};
54 13 $line = shift @words;
55 13 ▶ $abbrev = $this->__is_abbrev($line)
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 13 0 13
56 if defined $line;
57 13 my $nextword;
58  
59 13 ▶ while ( defined( $nextword = shift @words ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined($nextword = shift @words)) 46 5 51
60 {
61  
62 46 ▶ if ( length($nextword) + length($line) < $width - 1
Branch: 1 branch
BranchTrueFalseTotal
if (length($nextword) + length($line) < $width - 1 or !($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width) { } 38 8 46
Condition44%4/9
length($nextword) + length($line) < $width - 1 or !($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width
l!l&&r!l&&!r
3808
!($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width
!ll&&!rl&&r
080
not $line =~ /[.?!]['"]?$/ or $abbrev
l!l&&r!l&&!r
800
MC/DC25%1/4
length($nextword) + length($line) < $width - 1 or !($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width
length($nextword) + length($line) < $width - 1 not $line =~ /[.?!]['"]?$/ $abbrev length($nextword) + length($line) < $width
Truth table33%2/6
A or not(B) or C and D
A= length($nextword) + length($line) < $width - 1B= not $line =~ /[.?!]['"]?$/C= $abbrevD= length($nextword) + length($line) < $width
ABCDresult
1XXX1
01X11
00111
000X0
01X00
00100
63 || ( $line !~ /[.?!]['"]?$/ || $abbrev )
64 && length($nextword) + length($line) < $width )
65 {
66 38 ▶ $line .= ' '
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /[.?!]['"]?$/ and not $abbrev 0 38 38
Condition33%1/3
$line =~ /[.?!]['"]?$/ and not $abbrev
!ll&&!rl&&r
3800
MC/DC0%0/2
$line =~ /[.?!]['"]?$/ and not $abbrev
$line =~ /[.?!]['"]?$/ not $abbrev
Truth table33%1/3
A and not(B)
A= $line =~ /[.?!]['"]?$/B= not $abbrev
ABresult
0X0
100
111
67 if $line =~ /[.?!]['"]?$/ && !$abbrev;
68 38 $line .= ' ' . $nextword;
69 }
70 else
71 {
72 8 last;
73 }
74 38 $abbrev = $this->__is_abbrev($nextword);
75 }
76 ( $line, $nextword ) = $this->__do_break( $line, $nextword )
77 13 ▶ if $this->{'_nobreak'} && defined $line;
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"_nobreak"} and defined $line 0 13 13
Condition33%1/3
$this->{"_nobreak"} and defined $line
!ll&&!rl&&r
1300
MC/DC0%0/2
$this->{"_nobreak"} and defined $line
$this->{"_nobreak"} defined $line
Truth table33%1/3
A and B
A= $this->{"_nobreak"}B= defined $line
ABresult
0X0
100
111
78 13 ▶ push @wrap,
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 13 0 13
79 $this->__make_line( $line, $findent, $width, defined($nextword) )
80 if defined $line;
81 13 $line = $nextword;
82 $width =
83 $this->{'_cols'} -
84 $this->{'_bindent'} -
85 $this->{'_lmargin'} -
86 13 $this->{'_rmargin'};
87 13 $abbrev = 0;
88 13 ▶ $abbrev = $this->__is_abbrev($line)
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 8 5 13
89 if defined $line;
90 13 ▶ while ( defined( $nextword = shift @words ) )
Branch: 1 branch
BranchTrueFalseTotal
if (defined($nextword = shift @words)) 256 13 269
91 {
92  
93 256 ▶ if ( length($nextword) + length($line) < $width - 1
Branch: 1 branch
BranchTrueFalseTotal
if (length($nextword) + length($line) < $width - 1 or !($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width) { } 208 48 256
Condition66%6/9
length($nextword) + length($line) < $width - 1 or !($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width
l!l&&r!l&&!r
202648
!($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width
!ll&&!rl&&r
0486
not $line =~ /[.?!]['"]?$/ or $abbrev
l!l&&r!l&&!r
5400
MC/DC50%2/4
length($nextword) + length($line) < $width - 1 or !($line =~ /[.?!]['"]?$/) || $abbrev and length($nextword) + length($line) < $width
length($nextword) + length($line) < $width - 1 not $line =~ /[.?!]['"]?$/ $abbrev length($nextword) + length($line) < $width
Truth table50%3/6
A or not(B) or C and D
A= length($nextword) + length($line) < $width - 1B= not $line =~ /[.?!]['"]?$/C= $abbrevD= length($nextword) + length($line) < $width
ABCDresult
1XXX1
01X11
00111
000X0
01X00
00100
94 || ( $line !~ /[.?!]['"]?$/ || $abbrev )
95 && length($nextword) + length($line) < $width )
96 {
97 208 ▶ $line .= ' '
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /[.?!]['"]?$/ and not $abbrev 6 202 208
Condition100%3/3
$line =~ /[.?!]['"]?$/ and not $abbrev
!ll&&!rl&&r
19666
MC/DC100%2/2
$line =~ /[.?!]['"]?$/ and not $abbrev
$line =~ /[.?!]['"]?$/ not $abbrev
Truth table100%3/3
A and not(B)
A= $line =~ /[.?!]['"]?$/B= not $abbrev
ABresult
0X0
100
111
98 if $line =~ /[.?!]['"]?$/ && !$abbrev;
99 208 $line .= ' ' . $nextword;
100 }
101 else
102 {
103 ( $line, $nextword ) = $this->__do_break( $line, $nextword )
104 48 ▶ if $this->{'_nobreak'};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"_nobreak"} 0 48 48
105 48 ▶ push @wrap,
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 48 0 48
106 $this->__make_line( $line, $bindent, $width, defined $nextword )
107 if defined $line;
108 48 $line = $nextword;
109 }
110 256 ▶ $abbrev = $this->__is_abbrev($nextword)
Branch: 1 branch
BranchTrueFalseTotal
if defined $nextword 256 0 256
111 if defined $nextword;
112 }
113 13 ▶ push @wrap, $this->__make_line( $line, $bindent, $width, 0 )
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 8 5 13
114 if defined $line;
115  
116 13 ▶ if ( $this->{'_hindent'} && @wrap > 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"_hindent"} and @wrap > 0) 0 13 13
Condition33%1/3
$this->{"_hindent"} and @wrap > 0
!ll&&!rl&&r
1300
MC/DC0%0/2
$this->{"_hindent"} and @wrap > 0
$this->{"_hindent"} @wrap > 0
Truth table33%1/3
A and B
A= $this->{"_hindent"}B= @wrap > 0
ABresult
0X0
100
111
117 {
118 0 my $caller = ( caller 1 )[3];
119 0 ▶ $caller = ''
Branch: 1 branch
BranchTrueFalseTotal
unless defined $caller 0 0 0
120 unless defined $caller;
121 $this->{'_hindcurr'} = $this->{'_hindtext'}->[0]
122 if defined $this->{'_hindtext'}->[0]
123 0 ▶ && length( $this->{'_hindcurr'} ) < 1
Branch: 1 branch
BranchTrueFalseTotal
if defined $this->{"_hindtext"}[0] and length $this->{"_hindcurr"} < 1 and $caller ne "Text::Format::paragraphs" 0 0 0
Condition0%0/6
defined $this->{"_hindtext"}[0] and length $this->{"_hindcurr"} < 1 and $caller ne "Text::Format::paragraphs"
!ll&&!rl&&r
000
defined $this->{"_hindtext"}[0] and length $this->{"_hindcurr"} < 1
!ll&&!rl&&r
000
MC/DC0%0/3
defined $this->{"_hindtext"}[0] and length $this->{"_hindcurr"} < 1 and $caller ne "Text::Format::paragraphs"
defined $this->{"_hindtext"}[0] length $this->{"_hindcurr"} < 1 $caller ne "Text::Format::paragraphs"
Truth table0%0/4
A and B and C
A= defined $this->{"_hindtext"}[0]B= length $this->{"_hindcurr"} < 1C= $caller ne "Text::Format::paragraphs"
ABCresult
0XX0
10X0
1100
1111
124 && $caller ne 'Text::Format::paragraphs';
125 0 my ($fchar) = $wrap[0] =~ /(\S)/;
126 0 my $white = index $wrap[0], $fchar;
127 0 ▶ if ( $white - $this->{'_lmargin'} - 1 > length( $this->{'_hindcurr'} ) )
Branch: 1 branch
BranchTrueFalseTotal
if ($white - $this->{'_lmargin'} - 1 > length $this->{'_hindcurr'}) { } 0 0 0
128 {
129 0 $white = length( $this->{'_hindcurr'} ) + $this->{'_lmargin'};
130 0 $wrap[0] =~
131 0 s/^ {$white}/' ' x $this->{'_lmargin'} . $this->{'_hindcurr'}/e;
132 }
133 else
134 {
135 unshift @wrap,
136 0 ' ' x $this->{'_lmargin'} . $this->{'_hindcurr'} . "\n";
137 }
138 }
139  
140 wantarray
141 ? @wrap
142 13 ▶ : join '', @wrap;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 2 11 13
143 }
144  
145 # format lines in text into paragraphs with each element of @wrap a
146 # paragraph; uses Text::Format->format for the formatting
147 sub paragraphs($@)
148 1 ▶{
Subroutine paragraphs: called CC=15 SCAR=33.4
Pod documented
149 1 my $this = shift;
150 1 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 1 1
151 unless ref $this;
152 1 ▶ my @wrap = @_
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 0 1 0 1
153 if @_ > 0;
154  
155 0 ▶ @wrap = @{ $_[0] }
Branch: 1 branch
BranchTrueFalseTotal
if ref $_[0] eq "ARRAY" 0 1 1
156 if ref $_[0] eq 'ARRAY';
157 0 ▶ @wrap = @{ $this->{'_text'} }
Branch: 1 branch
BranchTrueFalseTotal
if @wrap < 1 0 1 1
158 if @wrap < 1;
159  
160 1 my ( @ret, $end, $cnt, $line );
161  
162 # if indents are same, use newline between paragraphs
163 1 ▶ if ( $this->{'_findent'} == $this->{'_bindent'}
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{'_findent'} == $this->{'_bindent'} or $this->{'_hindent'}) { } 0 1 1
Condition33%1/3
$this->{"_findent"} == $this->{"_bindent"} or $this->{"_hindent"}
l!l&&r!l&&!r
001
MC/DC0%0/2
$this->{"_findent"} == $this->{"_bindent"} or $this->{"_hindent"}
$this->{"_findent"} == $this->{"_bindent"} $this->{"_hindent"}
Truth table33%1/3
A or B
A= $this->{"_findent"} == $this->{"_bindent"}B= $this->{"_hindent"}
ABresult
1X1
011
000
164 || $this->{'_hindent'} )
165 {
166 0 $end = "\n";
167 }
168 else
169 {
170 1 $end = '';
171 }
172  
173 1 $cnt = 0;
174 1 for my $nextword (@wrap)
175 {
176 $this->{'_hindcurr'} = $this->{'_hindtext'}->[$cnt]
177 2 ▶ if $this->{'_hindent'};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"_hindent"} 0 2 2
178 $this->{'_hindcurr'} = ''
179 2 ▶ unless defined $this->{'_hindcurr'};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $this->{"_hindcurr"} 0 2 2
180 2 $line = $this->format($nextword);
181 2 ▶ push @ret, $line . $end
Branch: 1 branch
BranchTrueFalseTotal
if defined $line and length $line > 0 2 0 2
Condition33%1/3
defined $line and length $line > 0
!ll&&!rl&&r
002
MC/DC0%0/2
defined $line and length $line > 0
defined $line length $line > 0
Truth table33%1/3
A and B
A= defined $lineB= length $line > 0
ABresult
0X0
100
111
182 if defined $line && length $line > 0;
183 2 ++$cnt;
184 }
185 1 ▶ chop $ret[$#ret]
Branch: 1 branch
BranchTrueFalseTotal
if defined $ret[$#ret] and $ret[$#ret] =~ /\n\n$/ 0 1 1
Condition33%1/3
defined $ret[$#ret] and $ret[$#ret] =~ /\n\n$/
!ll&&!rl&&r
010
MC/DC0%0/2
defined $ret[$#ret] and $ret[$#ret] =~ /\n\n$/
defined $ret[$#ret] $ret[$#ret] =~ /\n\n$/
Truth table33%1/3
A and B
A= defined $ret[$#ret]B= $ret[$#ret] =~ /\n\n$/
ABresult
0X0
100
111
186 if defined( $ret[$#ret] ) && $ret[$#ret] =~ /\n\n$/;
187  
188 #if $ret[$#ret] =~ /\n\n$/;
189  
190 wantarray
191 ? @ret
192 1 ▶ : join '', @ret;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
193 }
194  
195 # center text using spaces on left side to pad it out
196 # empty lines are preserved
197 sub center($@)
198 1 ▶{
Subroutine center: called CC=8 SCAR=22.2
Pod documented
199 1 my $this = shift;
200 1 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 1 1
201 unless ref $this;
202 1 ▶ my @center = @_
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 0 1 0 1
203 if @_ > 0;
204 0 ▶ @center = @{ $this->{'_text'} }
Branch: 1 branch
BranchTrueFalseTotal
if @center < 1 0 1 1
205 if @center < 1;
206 1 my ($tabs);
207 1 my $width = $this->{'_cols'} - $this->{'_lmargin'} - $this->{'_rmargin'};
208  
209 1 for my $nextword (@center)
210 {
211 2 $nextword =~ s/(?:^\s+|\s+$)|\n//g;
212 2 $tabs = ( $nextword =~ tr/\t// ); # count tabs
213 substr( $nextword, 0, 0 ) =
214 ' ' x
215 int(
216 2 ▶ ( $width - length($nextword) - $tabs * $this->{'_tabs'} + $tabs ) /
Branch: 1 branch
BranchTrueFalseTotal
if length $nextword > 0 2 0 2
217 2 )
218 if length($nextword) > 0;
219 2 ▶ substr( $nextword, 0, 0 ) = ' ' x $this->{'_lmargin'}
Branch: 1 branch
BranchTrueFalseTotal
if length $nextword > 0 2 0 2
220 if length($nextword) > 0;
221 2 substr( $nextword, length($nextword) ) = "\n";
222 }
223  
224 return wantarray
225 ? @center
226 1 ▶ : join '', @center;
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 1 0 1
227 }
228  
229 # expand tabs to spaces
230 # should be similar to Text::Tabs::expand
231 sub expand($@)
232 0 ▶{
Subroutine expand: not called CC=6 SCAR=37.4
Pod documented
233 0 my $this = shift;
234 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
235 unless ref $this;
236 0 ▶ my @lines = @_
Branch: 1 branch
BranchTrueFalseTotal
if @_ > 0 0 0 0
237 if @_ > 0;
238 0 ▶ @lines = @{ $this->{'_text'} }
Branch: 1 branch
BranchTrueFalseTotal
if @lines < 1 0 0 0
239 if @lines < 1;
240  
241 0 for (@lines)
242 {
243 0 s/\t/' ' x $this->{'_tabs'}/eg;
244 }
245  
246 wantarray
247 ? @lines
248 0 ▶ : $lines[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
249 }
250  
251 # turn tabstop number of spaces into tabs
252 # should be similar to Text::Tabs::unexpand
253 sub unexpand($@)
254 0 ▶{
Subroutine unexpand: not called CC=4 SCAR=30.0
Pod documented
255 0 my $this = shift;
256 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
257 unless ref $this;
258 0 my @lines = $this->expand(@_);
259  
260 0 for (@lines)
261 {
262 0 s/ {$this->{'_tabs'}}/\t/g;
263 }
264  
265 wantarray
266 ? @lines
267 0 ▶ : $lines[0];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
268 }
269  
270 # return a reference to the object, call as $text = Text::Format->new()
271 # can be used to clone the current reference $ntext = $text->new()
272 sub new($@)
273 3 ▶{
Subroutine new: called CC=26 SCAR=39.7
Pod documented
274 3 my $this = shift;
275 3 my $ref;
276 3 ▶ if ( ref $_[0] eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 1 2 3
elsif (scalar(@_) % 2 == 0) { } 2 0 2
277 {
278 1 $ref = shift;
279 }
280 elsif ( scalar(@_) % 2 == 0 )
281 {
282 2 my %ref = @_;
283 2 $ref = \%ref;
284 }
285 else
286 {
287 0 $ref = '';
288 }
289 0 ▶ my %clone = %{$this}
Branch: 1 branch
BranchTrueFalseTotal
if ref $this 0 3 3
290 if ref $this;
291  
292 3 my $conf = {
293 _cols => 72,
294 _tabs => 8,
295 _findent => 4,
296 _bindent => 0,
297 _fill => 0,
298 _align => 0,
299 _justify => 0,
300 _lmargin => 0,
301 _rmargin => 0,
302 _space => 0,
303 _abbrs => {},
304 _text => [],
305 _hindent => 0,
306 _hindtext => [],
307 _hindcurr => '',
308 _nobreak => 0,
309 _nobreakregex => {},
310 };
311  
312 3 ▶ if ( ref $ref eq 'HASH' )
Branch: 1 branch
BranchTrueFalseTotal
if (ref $ref eq "HASH") 3 0 3
313 {
314 $conf->{'_cols'} = abs int $ref->{'columns'}
315 3 ▶ if defined $ref->{'columns'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"columns"} 1 2 3
316 $conf->{'_tabs'} = abs int $ref->{'tabstop'}
317 3 ▶ if defined $ref->{'tabstop'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"tabstop"} 0 3 3
318 $conf->{'_findent'} = abs int $ref->{'firstIndent'}
319 3 ▶ if defined $ref->{'firstIndent'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"firstIndent"} 1 2 3
320 $conf->{'_bindent'} = abs int $ref->{'bodyIndent'}
321 3 ▶ if defined $ref->{'bodyIndent'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"bodyIndent"} 0 3 3
322 $conf->{'_fill'} = abs int $ref->{'rightFill'}
323 3 ▶ if defined $ref->{'rightFill'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"rightFill"} 0 3 3
324 $conf->{'_align'} = abs int $ref->{'rightAlign'}
325 3 ▶ if defined $ref->{'rightAlign'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"rightAlign"} 0 3 3
326 $conf->{'_justify'} = abs int $ref->{'justify'}
327 3 ▶ if defined $ref->{'justify'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"justify"} 0 3 3
328 $conf->{'_lmargin'} = abs int $ref->{'leftMargin'}
329 3 ▶ if defined $ref->{'leftMargin'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"leftMargin"} 0 3 3
330 $conf->{'_rmargin'} = abs int $ref->{'rightMargin'}
331 3 ▶ if defined $ref->{'rightMargin'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"rightMargin"} 0 3 3
332 $conf->{'_space'} = abs int $ref->{'extraSpace'}
333 3 ▶ if defined $ref->{'extraSpace'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"extraSpace"} 0 3 3
334 $conf->{'_abbrs'} = $ref->{'abbrevs'}
335 if defined $ref->{'abbrevs'}
336 3 ▶ && ref $ref->{'abbrevs'} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"abbrevs"} and ref $ref->{"abbrevs"} eq "HASH" 0 3 3
Condition33%1/3
defined $ref->{"abbrevs"} and ref $ref->{"abbrevs"} eq "HASH"
!ll&&!rl&&r
300
MC/DC0%0/2
defined $ref->{"abbrevs"} and ref $ref->{"abbrevs"} eq "HASH"
defined $ref->{"abbrevs"} ref $ref->{"abbrevs"} eq "HASH"
Truth table33%1/3
A and B
A= defined $ref->{"abbrevs"}B= ref $ref->{"abbrevs"} eq "HASH"
ABresult
0X0
100
111
337 $conf->{'_text'} = $ref->{'text'}
338 if defined $ref->{'text'}
339 3 ▶ && ref $ref->{'text'} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"text"} and ref $ref->{"text"} eq "ARRAY" 0 3 3
Condition33%1/3
defined $ref->{"text"} and ref $ref->{"text"} eq "ARRAY"
!ll&&!rl&&r
300
MC/DC0%0/2
defined $ref->{"text"} and ref $ref->{"text"} eq "ARRAY"
defined $ref->{"text"} ref $ref->{"text"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $ref->{"text"}B= ref $ref->{"text"} eq "ARRAY"
ABresult
0X0
100
111
340 $conf->{'_hindent'} = abs int $ref->{'hangingIndent'}
341 3 ▶ if defined $ref->{'hangingIndent'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"hangingIndent"} 0 3 3
342 $conf->{'_hindtext'} = $ref->{'hangingText'}
343 if defined $ref->{'hangingText'}
344 3 ▶ && ref $ref->{'hangingText'} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"hangingText"} and ref $ref->{"hangingText"} eq "ARRAY" 0 3 3
Condition33%1/3
defined $ref->{"hangingText"} and ref $ref->{"hangingText"} eq "ARRAY"
!ll&&!rl&&r
300
MC/DC0%0/2
defined $ref->{"hangingText"} and ref $ref->{"hangingText"} eq "ARRAY"
defined $ref->{"hangingText"} ref $ref->{"hangingText"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $ref->{"hangingText"}B= ref $ref->{"hangingText"} eq "ARRAY"
ABresult
0X0
100
111
345 $conf->{'_nobreak'} = abs int $ref->{'noBreak'}
346 3 ▶ if defined $ref->{'noBreak'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"noBreak"} 0 3 3
347 $conf->{'_nobreakregex'} = $ref->{'noBreakRegex'}
348 if defined $ref->{'noBreakRegex'}
349 3 ▶ && ref $ref->{'noBreakRegex'} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $ref->{"noBreakRegex"} and ref $ref->{"noBreakRegex"} eq "HASH" 0 3 3
Condition33%1/3
defined $ref->{"noBreakRegex"} and ref $ref->{"noBreakRegex"} eq "HASH"
!ll&&!rl&&r
300
MC/DC0%0/2
defined $ref->{"noBreakRegex"} and ref $ref->{"noBreakRegex"} eq "HASH"
defined $ref->{"noBreakRegex"} ref $ref->{"noBreakRegex"} eq "HASH"
Truth table33%1/3
A and B
A= defined $ref->{"noBreakRegex"}B= ref $ref->{"noBreakRegex"} eq "HASH"
ABresult
0X0
100
111
350 }
351  
352 3 ▶ ref $this
Branch: 1 branch
BranchTrueFalseTotal
ref $this ? : 0 3 3
353 ? bless \%clone, ref $this
354 : bless $conf, $this;
355 }
356  
357 # configure all the attributes of the object
358 # returns the old object prior to configuration
359 sub config($@)
360 7 ▶{
Subroutine config: called CC=24 SCAR=40.0
Pod documented
361 7 my $this = shift;
362 7 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 7 7
363 unless ref $this;
364 7 my $conf;
365 7 ▶ if ( ref $_[0] eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 7 0 7
elsif (scalar(@_) % 2 == 0) { } 0 0 0
366 {
367 7 $conf = shift;
368 }
369 elsif ( scalar(@_) % 2 == 0 )
370 {
371 0 my %conf = @_;
372 0 $conf = \%conf;
373 }
374 else
375 {
376 0 croak "Bad hash ref";
377 }
378 7 my %clone = %{$this};
379  
380 $this->{'_cols'} = abs int $conf->{'columns'}
381 7 ▶ if defined $conf->{'columns'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"columns"} 3 4 7
382 $this->{'_tabs'} = abs int $conf->{'tabstop'}
383 7 ▶ if defined $conf->{'tabstop'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"tabstop"} 0 7 7
384 $this->{'_findent'} = abs int $conf->{'firstIndent'}
385 7 ▶ if defined $conf->{'firstIndent'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"firstIndent"} 0 7 7
386 $this->{'_bindent'} = abs int $conf->{'bodyIndent'}
387 7 ▶ if defined $conf->{'bodyIndent'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"bodyIndent"} 0 7 7
388 $this->{'_fill'} = abs int $conf->{'rightFill'}
389 7 ▶ if defined $conf->{'rightFill'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"rightFill"} 7 0 7
390 $this->{'_align'} = abs int $conf->{'rightAlign'}
391 7 ▶ if defined $conf->{'rightAlign'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"rightAlign"} 0 7 7
392 $this->{'_justify'} = abs int $conf->{'justify'}
393 7 ▶ if defined $conf->{'justify'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"justify"} 7 0 7
394 $this->{'_lmargin'} = abs int $conf->{'leftMargin'}
395 7 ▶ if defined $conf->{'leftMargin'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"leftMargin"} 0 7 7
396 $this->{'_rmargin'} = abs int $conf->{'rightMargin'}
397 7 ▶ if defined $conf->{'rightMargin'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"rightMargin"} 0 7 7
398 $this->{'_space'} = abs int $conf->{'extraSpace'}
399 7 ▶ if defined $conf->{'extraSpace'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"extraSpace"} 4 3 7
400 $this->{'_abbrs'} = $conf->{'abbrevs'}
401 if defined $conf->{'abbrevs'}
402 7 ▶ && ref $conf->{'abbrevs'} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"abbrevs"} and ref $conf->{"abbrevs"} eq "HASH" 0 7 7
Condition33%1/3
defined $conf->{"abbrevs"} and ref $conf->{"abbrevs"} eq "HASH"
!ll&&!rl&&r
700
MC/DC0%0/2
defined $conf->{"abbrevs"} and ref $conf->{"abbrevs"} eq "HASH"
defined $conf->{"abbrevs"} ref $conf->{"abbrevs"} eq "HASH"
Truth table33%1/3
A and B
A= defined $conf->{"abbrevs"}B= ref $conf->{"abbrevs"} eq "HASH"
ABresult
0X0
100
111
403 $this->{'_text'} = $conf->{'text'}
404 if defined $conf->{'text'}
405 7 ▶ && ref $conf->{'text'} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"text"} and ref $conf->{"text"} eq "ARRAY" 0 7 7
Condition33%1/3
defined $conf->{"text"} and ref $conf->{"text"} eq "ARRAY"
!ll&&!rl&&r
700
MC/DC0%0/2
defined $conf->{"text"} and ref $conf->{"text"} eq "ARRAY"
defined $conf->{"text"} ref $conf->{"text"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $conf->{"text"}B= ref $conf->{"text"} eq "ARRAY"
ABresult
0X0
100
111
406 $this->{'_hindent'} = abs int $conf->{'hangingIndent'}
407 7 ▶ if defined $conf->{'hangingIndent'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"hangingIndent"} 0 7 7
408 $this->{'_hindtext'} = $conf->{'hangingText'}
409 if defined $conf->{'hangingText'}
410 7 ▶ && ref $conf->{'hangingText'} eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"hangingText"} and ref $conf->{"hangingText"} eq "ARRAY" 0 7 7
Condition33%1/3
defined $conf->{"hangingText"} and ref $conf->{"hangingText"} eq "ARRAY"
!ll&&!rl&&r
700
MC/DC0%0/2
defined $conf->{"hangingText"} and ref $conf->{"hangingText"} eq "ARRAY"
defined $conf->{"hangingText"} ref $conf->{"hangingText"} eq "ARRAY"
Truth table33%1/3
A and B
A= defined $conf->{"hangingText"}B= ref $conf->{"hangingText"} eq "ARRAY"
ABresult
0X0
100
111
411 $this->{'_nobreak'} = abs int $conf->{'noBreak'}
412 7 ▶ if defined $conf->{'noBreak'};
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"noBreak"} 0 7 7
413 $this->{'_nobreakregex'} = $conf->{'noBreakRegex'}
414 if defined $conf->{'noBreakRegex'}
415 7 ▶ && ref $conf->{'noBreakRegex'} eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if defined $conf->{"noBreakRegex"} and ref $conf->{"noBreakRegex"} eq "HASH" 0 7 7
Condition33%1/3
defined $conf->{"noBreakRegex"} and ref $conf->{"noBreakRegex"} eq "HASH"
!ll&&!rl&&r
700
MC/DC0%0/2
defined $conf->{"noBreakRegex"} and ref $conf->{"noBreakRegex"} eq "HASH"
defined $conf->{"noBreakRegex"} ref $conf->{"noBreakRegex"} eq "HASH"
Truth table33%1/3
A and B
A= defined $conf->{"noBreakRegex"}B= ref $conf->{"noBreakRegex"} eq "HASH"
ABresult
0X0
100
111
416  
417 7 bless \%clone, ref $this;
418 }
419  
420 sub columns($;$)
421 1 ▶{
Subroutine columns: called CC=3 SCAR=11.7
Pod documented
422 1 my $this = shift;
423 1 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 1 1
424 unless ref $this;
425  
426 @_
427 ? $this->{'_cols'} = abs int shift
428 1 ▶ : $this->{'_cols'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 0 1
429 }
430  
431 sub tabstop($;$)
432 0 ▶{
Subroutine tabstop: not called CC=3 SCAR=24.8
Pod documented
433 0 my $this = shift;
434 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
435 unless ref $this;
436  
437 @_
438 ? $this->{'_tabs'} = abs int shift
439 0 ▶ : $this->{'_tabs'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
440 }
441  
442 sub firstIndent($;$)
443 0 ▶{
Subroutine firstIndent: not called CC=3 SCAR=24.8
Pod documented
444 0 my $this = shift;
445 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
446 unless ref $this;
447  
448 @_
449 ? $this->{'_findent'} = abs int shift
450 0 ▶ : $this->{'_findent'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
451 }
452  
453 sub bodyIndent($;$)
454 1 ▶{
Subroutine bodyIndent: called CC=3 SCAR=11.7
Pod documented
455 1 my $this = shift;
456 1 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 1 1
457 unless ref $this;
458  
459 @_
460 ? $this->{'_bindent'} = abs int shift
461 1 ▶ : $this->{'_bindent'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 1 0 1
462 }
463  
464 sub rightFill($;$)
465 0 ▶{
Subroutine rightFill: not called CC=3 SCAR=24.8
Pod documented
466 0 my $this = shift;
467 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
468 unless ref $this;
469  
470 @_
471 ? $this->{'_fill'} = abs int shift
472 0 ▶ : $this->{'_fill'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
473 }
474  
475 sub rightAlign($;$)
476 0 ▶{
Subroutine rightAlign: not called CC=3 SCAR=24.8
Pod documented
477 0 my $this = shift;
478 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
479 unless ref $this;
480  
481 @_
482 ? $this->{'_align'} = abs int shift
483 0 ▶ : $this->{'_align'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
484 }
485  
486 sub justify($;$)
487 0 ▶{
Subroutine justify: not called CC=3 SCAR=24.8
Pod documented
488 0 my $this = shift;
489 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
490 unless ref $this;
491  
492 @_
493 ? $this->{'_justify'} = abs int shift
494 0 ▶ : $this->{'_justify'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
495 }
496  
497 sub leftMargin($;$)
498 0 ▶{
Subroutine leftMargin: not called CC=3 SCAR=24.8
Pod documented
499 0 my $this = shift;
500 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
501 unless ref $this;
502  
503 @_
504 ? $this->{'_lmargin'} = abs int shift
505 0 ▶ : $this->{'_lmargin'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
506 }
507  
508 sub rightMargin($;$)
509 0 ▶{
Subroutine rightMargin: not called CC=3 SCAR=24.8
Pod documented
510 0 my $this = shift;
511 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
512 unless ref $this;
513  
514 @_
515 ? $this->{'_rmargin'} = abs int shift
516 0 ▶ : $this->{'_rmargin'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
517 }
518  
519 sub extraSpace($;$)
520 0 ▶{
Subroutine extraSpace: not called CC=3 SCAR=24.8
Pod documented
521 0 my $this = shift;
522 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
523 unless ref $this;
524  
525 @_
526 ? $this->{'_space'} = abs int shift
527 0 ▶ : $this->{'_space'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
528 }
529  
530 # takes a reference to your hash or takes a list of abbreviations,
531 # returns the INTERNAL abbreviations
532 sub abbrevs($@)
533 0 ▶{
Subroutine abbrevs: not called CC=5 SCAR=34.0
Pod documented
534 0 my $this = shift;
535 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
536 unless ref $this;
537  
538 0 ▶ if ( ref $_[0] eq 'HASH' )
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'HASH') { } 0 0 0
elsif (@_ > 0) { } 0 0 0
539 {
540 0 $this->{'_abbrs'} = shift;
541 }
542 elsif ( @_ > 0 )
543 {
544 0 my %tmp;
545 0 @tmp{@_} = @_;
546 0 $this->{'_abbrs'} = \%tmp;
547 }
548  
549 wantarray
550 0 ▶ ? sort keys %abbrev
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
551 : join ' ', sort keys %abbrev;
552 }
553  
554 sub text($;$)
555 0 ▶{
Subroutine text: not called CC=4 SCAR=30.0
Pod documented
556 0 my $this = shift;
557 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
558 unless ref $this;
559 0 my $text = shift;
560  
561 0 ▶ $this->{'_text'} = $text
Branch: 1 branch
BranchTrueFalseTotal
if ref $text eq "ARRAY" 0 0 0
562 if ref $text eq 'ARRAY';
563  
564 wantarray
565 0 ? @{ $this->{'_text'} }
566 0 ▶ : join ' ', @{ $this->{'_text'} };
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
567 }
568  
569 sub hangingIndent($;$)
570 0 ▶{
Subroutine hangingIndent: not called CC=3 SCAR=24.8
Pod documented
571 0 my $this = shift;
572 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
573 unless ref $this;
574  
575 @_
576 ? $this->{'_hindent'} = abs int shift
577 0 ▶ : $this->{'_hindent'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
578 }
579  
580 sub hangingText($;$)
581 0 ▶{
Subroutine hangingText: not called CC=4 SCAR=30.0
Pod documented
582 0 my $this = shift;
583 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
584 unless ref $this;
585 0 my $text = shift;
586  
587 0 ▶ $this->{'_hindtext'} = $text
Branch: 1 branch
BranchTrueFalseTotal
if ref $text eq "ARRAY" 0 0 0
588 if ref $text eq 'ARRAY';
589  
590 wantarray
591 0 ? @{ $this->{'_hindtext'} }
592 0 ▶ : join ' ', @{ $this->{'_hindtext'} };
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
593 }
594  
595 sub noBreak($;$)
596 0 ▶{
Subroutine noBreak: not called CC=3 SCAR=24.8
Pod documented
597 0 my $this = shift;
598 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
599 unless ref $this;
600  
601 @_
602 ? $this->{'_nobreak'} = abs int shift
603 0 ▶ : $this->{'_nobreak'};
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 0 0 0
604 }
605  
606 sub noBreakRegex($;$)
607 0 ▶{
Subroutine noBreakRegex: not called CC=3 SCAR=24.8
Pod documented
608 0 my $this = shift;
609 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
610 unless ref $this;
611 0 my $nobreak = shift;
612  
613 0 ▶ $this->{'_nobreakregex'} = $nobreak
Branch: 1 branch
BranchTrueFalseTotal
if ref $nobreak eq "HASH" 0 0 0
614 if ref $nobreak eq 'HASH';
615  
616 0 %{ $this->{'_nobreakregex'} };
617 }
618  
619 # internal routine, should not be called by an external routine
620 sub __make_line($$$$$)
621 69 ▶{
Subroutine __make_line: called CC=18 SCAR=30.2
622 69 my $this = shift;
623 69 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 69 69
624 unless ref $this;
625 69 my ( $line, $lead_white, $width, $not_last ) = @_;
626 69 my $fill = '';
627 69 my $lmargin = ' ' x $this->{'_lmargin'};
628  
629 $fill = ' ' x ( $width - length($line) )
630 69 ▶ if $this->{'_fill'} && !$this->{'_align'};
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"_fill"} and not $this->{"_align"} 32 37 69
Condition66%2/3
$this->{"_fill"} and not $this->{"_align"}
!ll&&!rl&&r
37032
MC/DC50%1/2
$this->{"_fill"} and not $this->{"_align"}
$this->{"_fill"} not $this->{"_align"}
Truth table66%2/3
A and not(B)
A= $this->{"_fill"}B= not $this->{"_align"}
ABresult
0X0
100
111
631 69 ▶ if ( $this->{'_justify'}
Branch: 1 branch
BranchTrueFalseTotal
if ($this->{"_justify"} and not $this->{"_fill"} || $this->{"_align"} and defined $line and $line =~ /\S+\s+\S+/ and $not_last) 26 43 69
Condition73%11/15
$this->{"_justify"} and not $this->{"_fill"} || $this->{"_align"} and defined $line and $line =~ /\S+\s+\S+/ and $not_last
!ll&&!rl&&r
41226
$this->{"_justify"} and not $this->{"_fill"} || $this->{"_align"} and defined $line and $line =~ /\S+\s+\S+/
!ll&&!rl&&r
40128
$this->{"_justify"} and not $this->{"_fill"} || $this->{"_align"} and defined $line
!ll&&!rl&&r
40029
$this->{"_justify"} and not $this->{"_fill"} || $this->{"_align"}
!ll&&!rl&&r
40029
$this->{'_fill'} || $this->{'_align'}
l!l&&r!l&&!r
0029
MC/DC50%3/6
$this->{"_justify"} and not $this->{"_fill"} || $this->{"_align"} and defined $line and $line =~ /\S+\s+\S+/ and $not_last
$this->{"_justify"} $this->{'_fill'} $this->{'_align'} defined $line $line =~ /\S+\s+\S+/ $not_last
Truth table57%4/7
A and not(B || C) and D and E and F
A= $this->{"_justify"}B= $this->{'_fill'}C= $this->{'_align'}D= defined $lineE= $line =~ /\S+\s+\S+/F= $not_last
ABCDEFresult
0XXXXX0
11XXXX0
101XXX0
1000XX0
10010X0
1001100
1001111
632 && !( $this->{'_fill'} || $this->{'_align'} )
633 && defined $line
634 && $line =~ /\S+\s+\S+/
635 && $not_last )
636 {
637 26 my $spaces = $width - length($line);
638 26 my @words = split /(\s+)/, $line;
639 26 my $ws = int( $spaces / int( @words / 2 ) ); # for filling all gaps
640 26 ▶ $spaces %= int( @words / 2 )
Branch: 1 branch
BranchTrueFalseTotal
if $ws > 0 9 17 26
641 if $ws > 0; # if we must fill between every single word
642 WORDS_LOOP:
643 26 for my $nextword ( reverse @words )
644 {
645 next WORDS_LOOP
646 248 ▶ if $nextword =~ /^\S/;
Branch: 1 branch
BranchTrueFalseTotal
if $nextword =~ /^\S/ 137 111 248
647 111 substr( $nextword, 0, 0 ) = ' ' x $ws;
648 111 ▶ $spaces || next WORDS_LOOP;
Branch: 1 branch
BranchTrueFalseTotal
$spaces or next WORDS_LOOP 33 78 111
649 33 substr( $nextword, 0, 0 ) = ' ';
650 33 --$spaces;
651 }
652 26 $line = join '', @words;
653 }
654 69 ▶ $line = $lmargin . $lead_white . $line . $fill . "\n"
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 69 0 69
655 if defined $line;
656 substr( $line, 0, 0 ) =
657 ' ' x ( $this->{'_cols'} - $this->{'_rmargin'} - ( length($line) - 1 ) )
658 69 ▶ if $this->{'_align'} && !$this->{'_fill'} && defined $line;
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"_align"} and not $this->{"_fill"} and defined $line 0 69 69
Condition33%2/6
$this->{"_align"} and not $this->{"_fill"} and defined $line
!ll&&!rl&&r
6900
$this->{"_align"} and not $this->{"_fill"}
!ll&&!rl&&r
6900
MC/DC0%0/3
$this->{"_align"} and not $this->{"_fill"} and defined $line
$this->{"_align"} not $this->{"_fill"} defined $line
Truth table25%1/4
A and not(B) and C
A= $this->{"_align"}B= not $this->{"_fill"}C= defined $line
ABCresult
0XX0
10X0
1100
1111
659  
660 69 $line;
661 }
662  
663 # internal routine, should not be called by an external routine
664 sub __is_abbrev($$)
665 315 ▶{
Subroutine __is_abbrev: called CC=6 SCAR=18.5
666 315 my $this = shift;
667 315 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 315 315
668 unless ref $this;
669 315 my $word = shift;
670  
671 315 ▶ $word =~ s/\.$//
Branch: 1 branch
BranchTrueFalseTotal
if defined $word 315 0 315
672 if defined $word; # remove period if there is one
673 # if we have an abbreviation OR no extra space is wanted after
674 # sentence endings
675 return 1
676 if !$this->{'_space'}
677 || exists( $abbrev{$word} )
678 315 ▶ || exists( ${ $this->{'_abbrs'} }{$word} );
Branch: 1 branch
BranchTrueFalseTotal
if not $this->{"_space"} or exists $abbrev{$word} or exists do { $$this{"_abbrs"} }->{$word} 179 136 315
Condition66%4/6
not $this->{"_space"} or exists $abbrev{$word} or exists do { $$this{"_abbrs"} }->{$word}
l!l&&r!l&&!r
1790136
not $this->{"_space"} or exists $abbrev{$word}
l!l&&r!l&&!r
1790136
MC/DC33%1/3
not $this->{"_space"} or exists $abbrev{$word} or exists do { $$this{"_abbrs"} }->{$word}
not $this->{"_space"} exists $abbrev{$word} exists do { $$this{"_abbrs"} }->{$word}
Truth table50%2/4
not(A) or B or C
A= not $this->{"_space"}B= exists $abbrev{$word}C= exists do { $$this{"_abbrs"} }->{$word}
ABCresult
1XX1
01X1
0011
0000
679  
680 136 0;
681 }
682  
683 # internal routine, should not be called by an external routine
684 sub __do_break($$$)
685 0 ▶{
Subroutine __do_break: not called CC=14 SCAR=53.5
686 0 my $this = shift;
687 0 ▶ croak "Bad method call"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $this 0 0 0
688 unless ref $this;
689 0 my ( $line, $next_line ) = @_;
690 0 my $no_break = 0;
691 0 ▶ my @words = split /\s+/, $line
Branch: 1 branch
BranchTrueFalseTotal
if defined $line 0 0 0
692 if defined $line;
693 0 my $last_word = $words[$#words];
694 0 local $_;
695  
696 0 for ( keys %{ $this->{'_nobreakregex'} } )
697 {
698 0 ▶ $no_break = 1
Branch: 1 branch
BranchTrueFalseTotal
if $last_word =~ /$_/ and $next_line =~ /do { $$this{"_nobreakregex"} }->{$_}/ 0 0 0
Condition0%0/3
$last_word =~ /$_/ and $next_line =~ /do { $$this{"_nobreakregex"} }->{$_}/
!ll&&!rl&&r
000
MC/DC0%0/2
$last_word =~ /$_/ and $next_line =~ /do { $$this{"_nobreakregex"} }->{$_}/
$last_word =~ /$_/ $next_line =~ /do { $$this{"_nobreakregex"} }->{$_}/
Truth table0%0/3
A and B
A= $last_word =~ /$_/B= $next_line =~ /do { $$this{"_nobreakregex"} }->{$_}/
ABresult
0X0
100
111
699 if $last_word =~ m$_
700 0 && $next_line =~ m${$this->{'_nobreakregex'}}{$_};
701 }
702  
703 0 ▶ if ( $no_break && @words > 1 )
Branch: 1 branch
BranchTrueFalseTotal
if ($no_break and @words > 1) 0 0 0
Condition0%0/3
$no_break and @words > 1
!ll&&!rl&&r
000
MC/DC0%0/2
$no_break and @words > 1
$no_break @words > 1
Truth table0%0/3
A and B
A= $no_breakB= @words > 1
ABresult
0X0
100
111
704 {
705 0 my $i;
706 0 ▶ for ( $i = $#words ; $i > 0 ; --$i )
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) 0 0 0
707 {
708 0 $no_break = 0;
709 0 for ( keys %{ $this->{'_nobreakregex'} } )
710 {
711 0 ▶ $no_break = 1
Branch: 1 branch
BranchTrueFalseTotal
if $words[$i - 1] =~ /$_/ and $words[$i] =~ /do { $$this{"_nobreakregex"} }->{$_}/ 0 0 0
Condition0%0/3
$words[$i - 1] =~ /$_/ and $words[$i] =~ /do { $$this{"_nobreakregex"} }->{$_}/
!ll&&!rl&&r
000
MC/DC0%0/2
$words[$i - 1] =~ /$_/ and $words[$i] =~ /do { $$this{"_nobreakregex"} }->{$_}/
$words[$i - 1] =~ /$_/ $words[$i] =~ /do { $$this{"_nobreakregex"} }->{$_}/
Truth table0%0/3
A and B
A= $words[$i - 1] =~ /$_/B= $words[$i] =~ /do { $$this{"_nobreakregex"} }->{$_}/
ABresult
0X0
100
111
712 if $words[ $i - 1 ] =~ m$_
713 0 && $words[$i] =~ m${$this->{'_nobreakregex'}}{$_};
714 }
715 last
716 0 ▶ if !$no_break;
Branch: 1 branch
BranchTrueFalseTotal
unless $no_break 0 0 0
717 }
718 0 ▶ if ( $i > 0 )
Branch: 1 branch
BranchTrueFalseTotal
if ($i > 0) 0 0 0
719 { # found break point
720 0 $line =~ s/((?:\S+\s+){$i})(.+)/$1/;
721 0 $next_line = $2 . ' ' . $next_line;
722 0 $line =~ s/\s+$//;
723 }
724  
725 # else, no breakpoint found and must break here anyways :<
726 }
727 0 ( $line, $next_line );
728 }
729  
730 3 1;
731  
732 __END__
↑ Summary