| 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
| |||||||||||||
| 16 | 0 | ▶ | die "No 'file' or 'fh' parameter given" unless $self->{file}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | 0 | ▶ | open($self->{fh}, '<', $self->{file}) or die "Couldn't open $self->{file}: $!"; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 28 | 1608 | ▶ | next unless /^ =encoding \s+ (\S+)/ix; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 29 | 1 | binmode $fh, ":encoding($1)"; | |||||||||||
| 30 | 1 | last; | |||||||||||
| 31 | } | ||||||||||||
| 32 | 73 | seek $fh, 0, 0; | |||||||||||
| 33 | |||||||||||||
| 34 | 73 | ▶ | while (<$fh>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 35 | 1008 | ▶ | next unless /^=(?!cut)/ .. /^=cut/; # in POD | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 38 | } | ||||||||||||
| 39 | |||||||||||||
| 40 | 73 | my @author; | |||||||||||
| 41 | 73 | ▶ | while (<$fh>) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 42 | 612 | ▶ | next unless /^=head1\s+AUTHORS?/i ... /^=/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 43 | 345 | ▶ | next if /^=/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 44 | 211 | ▶ | push @author, $_ if /\@/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 45 | } | ||||||||||||
| 46 | 73 | ▶ | return unless @author; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 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
| |||||||||||||
| 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
| |||||||||||||
| 66 | |||||||||||||
| 67 | 32 | $self->parse_from_filehandle($self->{fh}); | |||||||||||
| 68 | |||||||||||||
| 69 | 32 | ▶ | return $self->{author} || []; | ||||||||||
|
Condition100%2/2
$self->{'author'} || []
MC/DC100%1/1
$self->{'author'} || []
$self->{'author'}
Truth table100%2/2
A
A= $self->{'author'}
| |||||||||||||
| 70 | } | ||||||||||||