File Coverage

blib/lib/Pod/Simple/LinkSection.pm
Criterion Covered Total %
statement 26 31 83.8
branch 8 10 80.0
condition 7 11 63.6
subroutine 6 8 75.0
pod 0 4 0.0
total 47 64 73.4


line stmt bran cond sub pod time code
1             package Pod::Simple::LinkSection;
2             # Based somewhat dimly on Array::Autojoin
3              
4 70     70   113129 use strict;
  70         208  
  70         2980  
5 70     70   433 use warnings;
  70         163  
  70         3768  
6 70     70   57053 use Pod::Simple::BlackBox;
  70         454  
  70         6516  
7             our $VERSION = '3.47';
8              
9             use overload( # So it'll stringify nice
10 70         601 '""' => \&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     70   43019 );
  70         113013  
16              
17             sub tack_on {
18 0     0 0 0 $_[0] = ['', {}, "$_[0]" ];
19 0         0 return $_[0][2] .= $_[1];
20             }
21              
22             sub as_string {
23 0     0 0 0 goto &Pod::Simple::BlackBox::stringify_lol;
24             }
25             sub stringify {
26 2     2 0 2482 goto &Pod::Simple::BlackBox::stringify_lol;
27             }
28              
29             sub new {
30 535     535 0 243973 my $class = shift;
31 535   33     1784 $class = ref($class) || $class;
32 535         797 my $new;
33 535 50       1270 if(@_ == 1) {
34 535 100 50     1942 if (!ref($_[0] || '')) { # most common case: one bare string
    50 50        
35 166         955 return bless ['', {}, $_[0] ], $class;
36             } elsif( ref($_[0] || '') eq 'ARRAY') {
37 369         551 $new = [ @{ $_[0] } ];
  369         1771  
38             } else {
39 0         0 Carp::croak( "$class new() doesn't know to clone $new" );
40             }
41             } else { # misc stuff
42 0         0 $new = [ '', {}, @_ ];
43             }
44              
45             # By now it's a treelet: [ 'foo', {}, ... ]
46 369         813 foreach my $x (@$new) {
47 1312 100 100     5115 if(ref($x || '') eq 'ARRAY') {
    100 100        
48 127         350 $x = $class->new($x); # recurse
49             } elsif(ref($x || '') eq 'HASH') {
50 369         1051 $x = { %$x };
51             }
52             # otherwise leave it.
53             }
54              
55 369         1345 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             1;
63              
64             __END__