Index/Extract.pm

filter: Statementstmt 98.2% 57 / 58 Branchbran 84.3% 27 / 32 Conditioncond 100% 9 / 9 MC/DCmcdc 100% 6 / 6 Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 6 totaltotal 90.0% 109 / 121 CC 20 SCAR 20.9
CC
20
Cov
94%
command
14.2
textblock
4.0
ppi_done
3.0
CRAP 8.1
« Index/Builder.pm ↑ Summary Index/Search.pm »
1 package Pod::Index::Extract;
2  
3 4 ▶use 5.008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 $VERSION = '0.14';
5  
6 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 4 ▶use base qw(Pod::Parser);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 6 ▶sub begin_input {
Subroutine begin_input: called CC=1 SCAR=0.0
Pod undocumented
12 6 my ($self) = @_;
13 6 $self->cutting(0); # force parser to notice that it's in POD mode
14 }
15  
16 4 ▶sub verbatim {
Subroutine verbatim: called CC=2 SCAR=7.0
Pod undocumented
17 4 my ($self, $text, $line_num, $pod_para) = @_;
18  
19 # verbatim should't have the X<> attached
20 4 ▶ return $self->ppi_done unless $self->{ppi_anchor_type};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ppi_anchor_type"} 0 4 4
21  
22 4 my $out_fh = $self->output_handle;
23 4 print $out_fh $text;
24 4 $self->{ppi_textblock_count}++;
25 }
26  
27 9 ▶sub textblock {
Subroutine textblock: called CC=4 SCAR=13.9
Pod undocumented
28 9 my ($self, $text, $line_num, $pod_para) = @_;
29  
30 # should sanity check that the X<> is really here...
31 #print "<<<$text>>>\n";
32  
33 9 my $out_fh = $self->output_handle;
34  
35 9 ▶ unless ($self->{ppi_anchor_type}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ppi_anchor_type"}) 2 7 9
36 2 $self->{ppi_anchor_type} = 'textblock';
37 2 $self->ppi_start;
38 }
39  
40 # only print the first paragraph if in textblock mode
41 return $self->ppi_done if $self->{ppi_anchor_type} eq 'textblock'
42 9 ▶ and $self->{ppi_textblock_count};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"ppi_anchor_type"} eq "textblock" and $self->{"ppi_textblock_count"} 1 8 9
Condition100%3/3
$self->{"ppi_anchor_type"} eq "textblock" and $self->{"ppi_textblock_count"}
!ll&&!rl&&r
621
MC/DC100%2/2
$self->{"ppi_anchor_type"} eq "textblock" and $self->{"ppi_textblock_count"}
$self->{"ppi_anchor_type"} eq "textblock" $self->{"ppi_textblock_count"}
Truth table100%3/3
A and B
A= $self->{"ppi_anchor_type"} eq "textblock"B= $self->{"ppi_textblock_count"}
ABresult
0X0
100
111
43  
44 8 print $out_fh $text;
45 8 $self->{ppi_textblock_count}++;
46 }
47  
48 15 ▶sub command {
Subroutine command: called CC=14 SCAR=26.5
Pod undocumented
49 15 my ($self, $cmd, $text, $line_num, $pod_para) = @_;
50  
51 # should sanity check that the X<> is really here...
52  
53 15 my $out_fh = $self->output_handle;
54  
55 15 ▶ unless ($self->{ppi_anchor_type}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"ppi_anchor_type"}) 4 11 15
56 4 $self->{ppi_anchor_type} = 'command';
57 4 $self->{ppi_command} = $cmd;
58 4 $self->ppi_start;
59 4 ▶ if ($cmd eq 'item') {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd eq "item") 2 2 4
60 2 print $out_fh "=over\n\n";
61 }
62 }
63  
64 15 ▶ return $self->ppi_done unless $self->{ppi_anchor_type} eq 'command';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"ppi_anchor_type"} eq "command" 1 14 15
65  
66 14 my $ppi_cmd = $self->{ppi_command};
67 14 ▶ return $self->ppi_done unless $ppi_cmd =~ /^(?:head|item)/; # XXX
Branch: 1 branch
BranchTrueFalseTotal
unless $ppi_cmd =~ /^(?:head|item)/ 0 14 14
68
69 # check if we are out of scope
70 14 ▶ if ($self->{ppi_textblock_count}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ppi_textblock_count"}) 8 6 14
71 8 ▶ if ($ppi_cmd =~ /^head(\d)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ppi_cmd =~ /^head(\d)/) { } 2 6 8
elsif ($ppi_cmd =~ /^item/) { } 6 0 6
72 2 my $initial_level = $1;
73 2 ▶ if ($cmd =~ /^head(\d)/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cmd =~ /^head(\d)/) 2 0 2
74 2 my $current_level = $1;
75 2 ▶ return $self->ppi_done if $current_level <= $initial_level;
Branch: 1 branch
BranchTrueFalseTotal
if $current_level <= $initial_level 2 0 2
76 }
77 } elsif ($ppi_cmd =~ /^item/) {
78 6 ▶ if ($cmd =~ /item|back/ and !$self->{ppi_depth}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($cmd =~ /item|back/ and not $self->{'ppi_depth'}) { } 2 4 6
elsif ($cmd eq 'over') { } 1 3 4
elsif ($cmd eq 'back') { } 1 2 3
Condition100%3/3
$cmd =~ /item|back/ and not $self->{"ppi_depth"}
!ll&&!rl&&r
132
MC/DC100%2/2
$cmd =~ /item|back/ and not $self->{"ppi_depth"}
$cmd =~ /item|back/ not $self->{"ppi_depth"}
Truth table100%3/3
A and not(B)
A= $cmd =~ /item|back/B= not $self->{"ppi_depth"}
ABresult
0X0
100
111
79 2 return $self->ppi_done;
80 } elsif ($cmd eq 'over') {
81 1 $self->{ppi_depth}++;
82 } elsif ($cmd eq 'back') {
83 1 $self->{ppi_depth}--;
84 }
85 } else {
86 0 die "shouldn't be here ";
87 }
88 }
89  
90 10 print $out_fh $pod_para->raw_text;
91 }
92  
93 6 ▶sub ppi_start {
Subroutine ppi_start: called CC=1 SCAR=0.0
Pod undocumented
94 6 my ($self) = @_;
95 }
96  
97 6 ▶sub ppi_done {
Subroutine ppi_done: called CC=3 SCAR=11.0
Pod undocumented
98 6 my ($self) = @_;
99 6 my $out_fh = $self->output_handle;
100 6 ▶ if ($self->{ppi_command} and $self->{ppi_command} eq 'item') {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"ppi_command"} and $self->{"ppi_command"} eq "item") 2 4 6
Condition100%3/3
$self->{"ppi_command"} and $self->{"ppi_command"} eq "item"
!ll&&!rl&&r
222
MC/DC100%2/2
$self->{"ppi_command"} and $self->{"ppi_command"} eq "item"
$self->{"ppi_command"} $self->{"ppi_command"} eq "item"
Truth table100%3/3
A and B
A= $self->{"ppi_command"}B= $self->{"ppi_command"} eq "item"
ABresult
0X0
100
111
101 2 print $out_fh "=back\n\n";
102 }
103  
104  
105 6 my $fh = $self->input_handle;
106 6 seek $fh, 0, 2; # EOF
107 }
108  
109 4 1;
110  
111 __END__
« Index/Builder.pm ↑ Summary Index/Search.pm »