lib/Module/Build/PodParser.pm

filter: Statementstmt 95.2% 40 / 42 Branchbran 80.0% 24 / 30 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 4 totaltotal 85.8% 73 / 85 CC 18 SCAR 20.9
CC
18
Cov
89%
parse_from_filehandle
12.0
new
6.5
get_author
3.0
CRAP 8.0
« blib/lib/Module/Build/Platform/os2.pm ↑ Summary lib/Module/Build/Notes.pm »
1 package Module::Build::PodParser;
2  
3 19 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 19 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 19 our $VERSION = '0.4234';
6 19 $VERSION = eval $VERSION;
7  
8 73 ▶sub new {
Subroutine new: called CC=4 SCAR=18.7
Pod undocumented
9 # Perl is so fun.
10 73 my $package = shift;
11  
12 73 my $self;
13 73 $self = bless {have_pod_parser => 0, @_}, $package;
14  
15 73 ▶ unless ($self->{fh}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"fh"}) 0 73 73
16 0 ▶ die "No 'file' or 'fh' parameter given" unless $self->{file};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"file"} 0 0 0
17 0 ▶ open($self->{fh}, '<', $self->{file}) or die "Couldn't open $self->{file}: $!";
Branch: 1 branch
BranchTrueFalseTotal
open $self->{"fh"}, "<", $self->{"file"} or die qq[Couldn't open $self->{"file"}: $!] 0 0 0
18 }
19  
20 73 return $self;
21 }
22  
23 73 ▶sub parse_from_filehandle {
Subroutine parse_from_filehandle: called CC=12 SCAR=24.8
Pod undocumented
24 73 my ($self, $fh) = @_;
25  
26 73 local $_;
27 73 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 1608 72 1680
28 1608 ▶ next unless /^ =encoding \s+ (\S+)/ix;
Branch: 1 branch
BranchTrueFalseTotal
unless /^ =encoding \s+ (\S+)/xi 1607 1 1608
29 1 binmode $fh, ":encoding($1)";
30 1 last;
31 }
32 73 seek $fh, 0, 0;
33  
34 73 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 1008 5 1013
35 1008 ▶ next unless /^=(?!cut)/ .. /^=cut/; # in POD
Branch: 1 branch
BranchTrueFalseTotal
unless /^=(?!cut)/ .. /^=cut/ 317 691 1008
36 # Accept Name - abstract or C<Name> - abstract
37 691 ▶ last if ($self->{abstract}) = /^ (?: [a-z_0-9:]+ | [BCIF] < [a-z_0-9:]+ > ) \s+ - \s+ (.*\S) /ix;
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"abstract"}) = /^ (?: [a-z_0-9:]+ | [BCIF] < [a-z_0-9:]+ > ) \s+ - \s+ (.*\S) /xi 68 623 691
38 }
39  
40 73 my @author;
41 73 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 612 73 685
42 612 ▶ next unless /^=head1\s+AUTHORS?/i ... /^=/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^=head1\s+AUTHORS?/i ... /^=/ 267 345 612
43 345 ▶ next if /^=/;
Branch: 1 branch
BranchTrueFalseTotal
if /^=/ 134 211 345
44 211 ▶ push @author, $_ if /\@/;
Branch: 1 branch
BranchTrueFalseTotal
if /\@/ 67 144 211
45 }
46 73 ▶ return unless @author;
Branch: 1 branch
BranchTrueFalseTotal
unless @author 6 67 73
47 67 s/^\s+|\s+$//g foreach @author;
48  
49 67 $self->{author} = \@author;
50  
51 67 return;
52 }
53  
54 45 ▶sub get_abstract {
Subroutine get_abstract: called CC=2 SCAR=6.9
Pod undocumented
55 45 my $self = shift;
56 45 ▶ return $self->{abstract} if defined $self->{abstract};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"abstract"} 4 41 45
57  
58 41 $self->parse_from_filehandle($self->{fh});
59  
60 41 return $self->{abstract};
61 }
62  
63 32 ▶sub get_author {
Subroutine get_author: called CC=3 SCAR=11.0
Pod undocumented
64 32 my $self = shift;
65 32 ▶ return $self->{author} if defined $self->{author};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"author"} 0 32 32
66  
67 32 $self->parse_from_filehandle($self->{fh});
68  
69 32 ▶ return $self->{author} || [];
Condition100%2/2
$self->{'author'} || []
l!l
311
MC/DC100%1/1
$self->{'author'} || []
$self->{'author'}
Truth table100%2/2
A
A= $self->{'author'}
Aresult
11
00
70 }
« blib/lib/Module/Build/Platform/os2.pm ↑ Summary lib/Module/Build/Notes.pm »