| 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
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||
| 32 | 538 | my $new; | |||||||||||||||||||||||
| 33 | 538 | ▶ | if(@_ == 1) { | ||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||
| 34 | 538 | ▶ | if (!ref($_[0] || '')) { # most common case: one bare string | ||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$_[0] || ''
MC/DC0%0/1
$_[0] || ''
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||
| 35 | 166 | return bless ['', {}, $_[0] ], $class; | |||||||||||||||||||||||
| 36 | ▶ | } elsif( ref($_[0] || '') eq 'ARRAY') { | |||||||||||||||||||||||
|
Condition50%1/2
$_[0] || ''
MC/DC0%0/1
$_[0] || ''
$_[0]
Truth table50%1/2
A
A= $_[0]
| |||||||||||||||||||||||||
| 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
Condition100%2/2
$x || ''
MC/DC100%1/1
$x || ''
$x
Truth table100%2/2
A
A= $x
| |||||||||||||||||||||||||
| 48 | 127 | $x = $class->new($x); # recurse | |||||||||||||||||||||||
| 49 | ▶ | } elsif(ref($x || '') eq 'HASH') { | |||||||||||||||||||||||
|
Condition100%2/2
$x || ''
MC/DC100%1/1
$x || ''
$x
Truth table100%2/2
A
A= $x
| |||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||