File Coverage

blib/lib/Pod/Simple/SimpleTree.pm
Criterion Covered Total %
statement 35 39 89.7
branch 3 4 75.0
condition n/a
subroutine 8 9 88.8
pod n/a
total 46 52 88.4


line stmt bran cond sub pod time code
1             package Pod::Simple::SimpleTree;
2 2     2   70601 use strict;
  2         13  
  2         81  
3 2     2   11 use warnings;
  2         12  
  2         56  
4 2     2   8 use Carp ();
  2         4  
  2         37  
5 2     2   649 use Pod::Simple ();
  2         5  
  2         146  
6             our $VERSION = '3.45';
7             BEGIN {
8 2     2   43 our @ISA = ('Pod::Simple');
9 2 50       939 *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG;
10             }
11              
12             __PACKAGE__->_accessorize(
13             'root', # root of the tree
14             );
15              
16             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17              
18             sub _handle_element_start { # self, tagname, attrhash
19 7     7   13 DEBUG > 2 and print STDERR "Handling $_[1] start-event\n";
20 7         14 my $x = [$_[1], $_[2]];
21 7 100       18 if($_[0]{'_currpos'}) {
22 1         3 push @{ $_[0]{'_currpos'}[0] }, $x; # insert in parent's child-list
  1         6  
23 1         2 unshift @{ $_[0]{'_currpos'} }, $x; # prefix to stack
  1         3  
24             } else {
25 6         8 DEBUG and print STDERR " And oo, it gets to be root!\n";
26 6         15 $_[0]{'_currpos'} = [ $_[0]{'root'} = $x ];
27             # first event! set to stack, and set as root.
28             }
29             DEBUG > 3 and print STDERR "Stack is now: ",
30 7         12 join(">", map $_->[0], @{$_[0]{'_currpos'}}), "\n";
31 7         15 return;
32             }
33              
34             sub _handle_element_end { # self, tagname
35 7     7   9 DEBUG > 2 and print STDERR "Handling $_[1] end-event\n";
36 7         10 shift @{$_[0]{'_currpos'}};
  7         22  
37             DEBUG > 3 and print STDERR "Stack is now: ",
38 7         9 join(">", map $_->[0], @{$_[0]{'_currpos'}}), "\n";
39 7         16 return;
40             }
41              
42             sub _handle_text { # self, text
43 0     0   0 DEBUG > 2 and print STDERR "Handling $_[1] text-event\n";
44 0         0 push @{ $_[0]{'_currpos'}[0] }, $_[1];
  0         0  
45 0         0 return;
46             }
47              
48              
49             # A bit of evil from the black box... please avert your eyes, kind souls.
50             sub _traverse_treelet_bit {
51 6     6   10 DEBUG > 2 and print STDERR "Handling $_[1] paragraph event\n";
52 6         10 my $self = shift;
53 6         7 push @{ $self->{'_currpos'}[0] }, [@_];
  6         33  
54 6         39 return;
55             }
56             #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57             1;
58             __END__