Simple/LinkSection.pm

filter: Statementstmt 84.8% 28 / 33 Branchbran 80.0% 8 / 10 Conditioncond 63.6% 7 / 11 MC/DCmcdc 33.3% 2 / 6 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 4 totaltotal 70.8% 51 / 72 CC 12 SCAR 22.0
CC
12
Cov
80%
new
13.6
tack_on
2.0
as_string
2.0
CRAP 9.1
« Simple/HTMLBatch.pm ↑ Summary Simple/XHTML.pm »
1 package Pod::Simple::LinkSection;
2 # Based somewhat dimly on Array::Autojoin
3  
4 70 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 70 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 70 ▶use Pod::Simple::BlackBox;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 70 our $VERSION = '3.48';
8  
9 70 ▶use overload( # So it'll stringify nice
Subroutine BEGIN: called CC=1 SCAR=0.0
10 70 '""' => \&Pod::Simple::BlackBox::stringify_lol,
11 'bool' => \&Pod::Simple::BlackBox::stringify_lol,
12 # '.=' => \&tack_on, # grudgingly support
13  
14 'fallback' => 1, # turn on cleverness
15 70 );
16  
17 0 ▶sub tack_on {
Subroutine tack_on: not called CC=1 SCAR=6.9
Pod undocumented
18 0 $_[0] = ['', {}, "$_[0]" ];
19 0 return $_[0][2] .= $_[1];
20 }
21  
22 0 ▶sub as_string {
Subroutine as_string: not called CC=1 SCAR=6.9
Pod undocumented
23 0 goto &Pod::Simple::BlackBox::stringify_lol;
24 }
25 2 ▶sub stringify {
Subroutine stringify: called CC=1 SCAR=0.0
Pod undocumented
26 2 goto &Pod::Simple::BlackBox::stringify_lol;
27 }
28  
29 538 ▶sub new {
Subroutine new: called CC=12 SCAR=26.1
Pod undocumented
30 538 my $class = shift;
31 538 ▶ $class = ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
05380
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
32 538 my $new;
33 538 ▶ if(@_ == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1) { } 538 0 538
34 538 ▶ if (!ref($_[0] || '')) { # most common case: one bare string
Branch: 2 branches
BranchTrueFalseTotal
if (not ref($_[0] || '')) { } 166 372 538
elsif (ref($_[0] || '') eq 'ARRAY') { } 372 0 372
Condition50%1/2
$_[0] || ''
l!l
5380
MC/DC0%0/1
$_[0] || ''
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
35 166 return bless ['', {}, $_[0] ], $class;
36 ▶ } elsif( ref($_[0] || '') eq 'ARRAY') {
Condition50%1/2
$_[0] || ''
l!l
3720
MC/DC0%0/1
$_[0] || ''
$_[0]
Truth table50%1/2
A
A= $_[0]
Aresult
11
00
37 372 $new = [ @{ $_[0] } ];
38 } else {
39 0 Carp::croak( "$class new() doesn't know to clone $new" );
40 }
41 } else { # misc stuff
42 0 $new = [ '', {}, @_ ];
43 }
44  
45 # By now it's a treelet: [ 'foo', {}, ... ]
46 372 foreach my $x (@$new) {
47 1321 ▶ if(ref($x || '') eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref($x || '') eq 'ARRAY') { } 127 1194 1321
elsif (ref($x || '') eq 'HASH') { } 372 822 1194
Condition100%2/2
$x || ''
l!l
1056265
MC/DC100%1/1
$x || ''
$x
Truth table100%2/2
A
A= $x
Aresult
11
00
48 127 $x = $class->new($x); # recurse
49 ▶ } elsif(ref($x || '') eq 'HASH') {
Condition100%2/2
$x || ''
l!l
929265
MC/DC100%1/1
$x || ''
$x
Truth table100%2/2
A
A= $x
Aresult
11
00
50 372 $x = { %$x };
51 }
52 # otherwise leave it.
53 }
54  
55 372 return bless $new, $class;
56 }
57  
58 # Not much in this class is likely to be link-section specific --
59 # but it just so happens that link-sections are about the only treelets
60 # that are exposed to the user.
61  
62 70 1;
63  
64 __END__
« Simple/HTMLBatch.pm ↑ Summary Simple/XHTML.pm »