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 68     68   68162 use strict;
  68         129  
  68         2073  
5 68     68   338 use warnings;
  68         141  
  68         1681  
6 68     68   50179 use Pod::Simple::BlackBox;
  68         219  
  68         5258  
7             our $VERSION = '3.45';
8              
9             use overload( # So it'll stringify nice
10 68         476 '""' => \&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 68     68   58723 );
  68         47566  
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 2021 goto &Pod::Simple::BlackBox::stringify_lol;
27             }
28              
29             sub new {
30 530     530 0 1039 my $class = shift;
31 530   33     1466 $class = ref($class) || $class;
32 530         680 my $new;
33 530 50       1050 if(@_ == 1) {
34 530 100 50     1690 if (!ref($_[0] || '')) { # most common case: one bare string
    50 50        
35 166         721 return bless ['', {}, $_[0] ], $class;
36             } elsif( ref($_[0] || '') eq 'ARRAY') {
37 364         475 $new = [ @{ $_[0] } ];
  364         894  
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 364         684 foreach my $x (@$new) {
47 1294 100 100     4176 if(ref($x || '') eq 'ARRAY') {
    100 100        
48 126         270 $x = $class->new($x); # recurse
49             } elsif(ref($x || '') eq 'HASH') {
50 364         897 $x = { %$x };
51             }
52             # otherwise leave it.
53             }
54              
55 364         978 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__