MinimumVersion/Parser.pm

filter: Statementstmt 97.8% 46 / 47 Branchbran 87.5% 7 / 8 Conditioncond 77.7% 7 / 9 MC/DCmcdc 60.0% 3 / 5 Subroutinesub 90.9% 10 / 11 Podpod 0.0% 0 / 7 totaltotal 83.9% 73 / 87 CC 10 SCAR 12.7
CC
10
Cov
94%
command
6.0
interior_sequence
5.0
verbatim
2.0
CRAP 3.6
« MinimumVersion.pm ↑ Summary MinimumVersion/Report.pm »
1 # Copyright 2009, 2010, 2011 Kevin Ryde
2  
3 # This file is part of Pod-MinimumVersion.
4  
5 # Pod-MinimumVersion is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 3, or (at your option) any later
8 # version.
9 #
10 # Pod-MinimumVersion is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 # for more details.
14 #
15 # You should have received a copy of the GNU General Public License along
16 # with Pod-MinimumVersion. If not, see <http://www.gnu.org/licenses/>.
17  
18  
19 package Pod::MinimumVersion::Parser;
20 3 ▶use 5.004;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 3 ▶use vars '$VERSION', '@ISA';
Subroutine BEGIN: called CC=1 SCAR=0.0
23  
24 3 ▶use Pod::Parser;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 3 @ISA = ('Pod::Parser');
26  
27 3 $VERSION = 50;
28  
29 # uncomment this to run the ### lines
30 #use Smart::Comments;
31  
32 49 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
33 49 my $class = shift;
34 49 my $self = $class->SUPER::new(@_);
35 49 $self->errorsub ('error_handler'); # method name
36 49 return $self;
37 }
38 1 ▶sub error_handler {
Subroutine error_handler: called CC=1 SCAR=0.0
Pod undocumented
39 1 my ($self, $errmsg) = @_;
40 ### PMV error_handler()
41 1 return 1; # error handled
42 }
43  
44 # sub begin_input {
45 # print "begin_input\n";
46 # }
47 # sub end_input {
48 # print "end_input\n";
49 # }
50  
51 48 ▶sub parse_from_string {
Subroutine parse_from_string: called CC=1 SCAR=0.0
Pod undocumented
52 48 my ($self, $str) = @_;
53 ### PMV parse_from_string()
54  
55 48 require IO::String;
56 48 my $fh = IO::String->new ($str);
57 48 $self->{_INFILE} = "(string)";
58 48 return $self->parse_from_filehandle ($fh);
59 }
60  
61 3 my %command_does_not_interpolate = (for => 1, # free form text
62 begin => 1, # formatname not text
63 end => 1,
64 pod => 1, # text ignored
65 cut => 1, # text ignored
66 encoding => 1, # encoding name not text
67 );
68 47 ▶sub command {
Subroutine command: called CC=6 SCAR=17.9
Pod undocumented
69 47 my ($self, $command, $text, $linenum, $paraobj) = @_;
70 ### PMV command()
71 ### $command
72 ### $text
73 ### $linenum
74  
75 # If =foo command at EOF with no more chars, including no trailing
76 # newline, then $text is undef (circa Pod::Parser 1.37 at least).
77 #
78 47 ▶ if (defined $text) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $text) 47 0 47
79 47 ▶ if ($command eq 'for'
Branch: 1 branch
BranchTrueFalseTotal
if ($command eq "for" and $text =~ /^Pod::MinimumVersion\s+use\s+(v?[0-9._]+)/) 2 45 47
Condition100%3/3
$command eq "for" and $text =~ /^Pod::MinimumVersion\s+use\s+(v?[0-9._]+)/
!ll&&!rl&&r
4142
MC/DC100%2/2
$command eq "for" and $text =~ /^Pod::MinimumVersion\s+use\s+(v?[0-9._]+)/
$command eq "for" $text =~ /^Pod::MinimumVersion\s+use\s+(v?[0-9._]+)/
Truth table100%3/3
A and B
A= $command eq "for"B= $text =~ /^Pod::MinimumVersion\s+use\s+(v?[0-9._]+)/
ABresult
0X0
100
111
80 && $text =~ /^Pod::MinimumVersion\s+use\s+(v?[0-9._]+)/) {
81 2 $self->{'pmv'}->{'for_version'} = version->new($1);
82 }
83  
84 47 foreach my $func (@{$self->{'checks'}->{'command'}}) {
85 116 $func->($self->{'pmv'}, $command, $text, $paraobj);
86 }
87  
88 47 ▶ unless ($command_does_not_interpolate{$command}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($command_does_not_interpolate{$command}) 14 33 47
89 14 $self->interpolate ($text, $linenum);
90 }
91 }
92 47 return '';
93 }
94  
95 0 ▶sub verbatim {
Subroutine verbatim: not called CC=1 SCAR=6.9
Pod undocumented
96 ### PMV verbatim()
97 0 return '';
98 }
99  
100 27 ▶sub textblock {
Subroutine textblock: called CC=1 SCAR=0.0
Pod undocumented
101 27 my ($self, $text, $linenum, $paraobj) = @_;
102 ### PMV textblock()
103 ### $text
104 27 return $self->interpolate ($text, $linenum);
105 }
106  
107 35 ▶sub interior_sequence {
Subroutine interior_sequence: called CC=5 SCAR=16.2
Pod undocumented
108 35 my ($self, $command, $arg, $seq_obj) = @_;
109 ### interior
110 ### $command
111 ### $arg
112 ### $seq_obj
113 ### raw_text: $seq_obj->raw_text
114 ### left: $seq_obj->left_delimiter
115 ### nested: do { my $outer = $seq_obj->nested; $outer && $outer->cmd_name }
116  
117 # J<> from Pod::MultiLang -- doubled C<<>> or L<|display> are allowed
118 # ENHANCE-ME: might prefer to make parse_tree() not descend into J<> at
119 # all, but it doesn't seem setup for that
120 35 my $outer;
121 35 ▶ if ($command eq 'J'
Branch: 1 branch
BranchTrueFalseTotal
if ($command eq "J" or $outer = $seq_obj->nested and $outer->cmd_name eq "J") 1 34 35
Condition66%4/6
$command eq "J" or $outer = $seq_obj->nested and $outer->cmd_name eq "J"
l!l&&r!l&&!r
1034
$outer = $seq_obj->nested and $outer->cmd_name eq "J"
!ll&&!rl&&r
2770
MC/DC33%1/3
$command eq "J" or $outer = $seq_obj->nested and $outer->cmd_name eq "J"
$command eq "J" $outer = $seq_obj->nested $outer->cmd_name eq "J"
Truth table75%3/4
A or B and C
A= $command eq "J"B= $outer = $seq_obj->nestedC= $outer->cmd_name eq "J"
ABCresult
1XX1
0111
00X0
0100
122 || (($outer = $seq_obj->nested) && $outer->cmd_name eq 'J')) {
123 1 return '';
124 }
125  
126 34 foreach my $func (@{$self->{'checks'}->{'interior_sequence'}}) {
127 147 $func->($self->{'pmv'}, $command, $arg, $seq_obj);
128 }
129 34 return '';
130 }
131  
132 3 1;
133 __END__
« MinimumVersion.pm ↑ Summary MinimumVersion/Report.pm »