Simple/SimpleTree.pm

filter: Statementstmt 90.4% 38 / 42 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod n/a totaltotal 89.0% 49 / 55 CC 3 SCAR 3.8
CC
3
Cov
89%
BEGIN
2.1
_handle_element_start
2.0
_handle_text
2.0
CRAP 1.5
« Simple/TextContent.pm ↑ Summary
1 package Pod::Simple::SimpleTree;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use Pod::Simple ();
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 our $VERSION = '3.48';
7 2 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=7.2
8 2 our @ISA = ('Pod::Simple');
9 2 ▶ *DEBUG = \&Pod::Simple::DEBUG unless defined &DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
unless defined &Pod::Simple::SimpleTree::DEBUG 2 0 2
10 }
11  
12 2 __PACKAGE__->_accessorize(
13 'root', # root of the tree
14 );
15  
16 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
17  
18 7 ▶sub _handle_element_start { # self, tagname, attrhash
Subroutine _handle_element_start: called CC=2 SCAR=6.9
19 7 DEBUG > 2 and print STDERR "Handling $_[1] start-event\n";
20 7 my $x = [$_[1], $_[2]];
21 7 ▶ if($_[0]{'_currpos'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[0]{'_currpos'}) { } 1 6 7
22 1 push @{ $_[0]{'_currpos'}[0] }, $x; # insert in parent's child-list
23 1 unshift @{ $_[0]{'_currpos'} }, $x; # prefix to stack
24 } else {
25 6 DEBUG and print STDERR " And oo, it gets to be root!\n";
26 6 $_[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 join(">", map $_->[0], @{$_[0]{'_currpos'}}), "\n";
31 7 return;
32 }
33  
34 7 ▶sub _handle_element_end { # self, tagname
Subroutine _handle_element_end: called CC=1 SCAR=0.0
35 7 DEBUG > 2 and print STDERR "Handling $_[1] end-event\n";
36 7 shift @{$_[0]{'_currpos'}};
37 DEBUG > 3 and print STDERR "Stack is now: ",
38 7 join(">", map $_->[0], @{$_[0]{'_currpos'}}), "\n";
39 7 return;
40 }
41  
42 0 ▶sub _handle_text { # self, text
Subroutine _handle_text: not called CC=1 SCAR=6.9
43 0 DEBUG > 2 and print STDERR "Handling $_[1] text-event\n";
44 0 push @{ $_[0]{'_currpos'}[0] }, $_[1];
45 0 return;
46 }
47  
48  
49 # A bit of evil from the black box... please avert your eyes, kind souls.
50 6 ▶sub _traverse_treelet_bit {
Subroutine _traverse_treelet_bit: called CC=1 SCAR=0.0
51 6 DEBUG > 2 and print STDERR "Handling $_[1] paragraph event\n";
52 6 my $self = shift;
53 6 push @{ $self->{'_currpos'}[0] }, [@_];
54 6 return;
55 }
56 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57 2 1;
58 __END__
« Simple/TextContent.pm ↑ Summary