blib/lib/Module/Reader.pm

filter: Statementstmt 81.1% 177 / 218 Branchbran 65.6% 84 / 128 Conditioncond 50.0% 35 / 70 MC/DCmcdc 26.3% 10 / 38 Subroutinesub 77.5% 38 / 49 Podpod 90.9% 10 / 11 totaltotal 68.8% 354 / 514 CC 93 SCAR 25.8
CC
93
Cov
71%
content
31.0
handle
30.0
_find
25.5
CRAP 13.2
↑ Summary
1 package Module::Reader;
2 3 ▶BEGIN { require 5.006 }
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 our $VERSION = '0.003003';
7 3 $VERSION = eval $VERSION;
8  
9 3 ▶use Exporter (); BEGIN { *import = \&Exporter::import }
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 our @EXPORT_OK = qw(module_content module_handle);
11 3 our %EXPORT_TAGS = (all => [@EXPORT_OK]);
12  
13 3 ▶use File::Spec ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Scalar::Util qw(reftype refaddr openhandle);
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use Config ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use Errno qw(EACCES);
Subroutine BEGIN: called CC=1 SCAR=0.0
18 3 ▶use constant _OPEN_LAYERS => "$]" >= 5.008_000 ? ':' : '';
Subroutine BEGIN: called CC=2 SCAR=7.1
Branch: 1 branch
BranchTrueFalseTotal
"$]" >= 5.008 ? : 3 0 3
19 3 ▶use constant _ABORT_ON_EACCES => "$]" >= 5.017_001;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 3 ▶use constant _ALLOW_PREFIX => "$]" >= 5.008009;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 3 ▶use constant _VMS => $^O eq 'VMS' && !!require VMS::Filespec;
Subroutine BEGIN: called CC=2 SCAR=7.6
Condition33%1/3
$^O eq 'VMS' && !!(require VMS::Filespec)
!ll&&!rl&&r
300
MC/DC0%0/2
$^O eq 'VMS' && !!(require VMS::Filespec)
$^O eq 'VMS' !!(require VMS::Filespec)
Truth table33%1/3
A && B
A= $^O eq 'VMS'B= !!(require VMS::Filespec)
ABresult
0X0
100
111
22 3 ▶use constant _WIN32 => $^O eq 'MSWin32';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 3 ▶use constant _PMC_ENABLED => !(
Subroutine BEGIN: called CC=2 SCAR=7.0
24 exists &Config::non_bincompat_options
25 30 ? grep { $_ eq 'PERL_DISABLE_PMC' } Config::non_bincompat_options()
26 3 ▶ : $Config::Config{ccflags} =~ /(?:^|\s)-DPERL_DISABLE_PMC\b/
Branch: 1 branch
BranchTrueFalseTotal
exists &Config::non_bincompat_options ? : 3 0 3
27 3 );
28 3 ▶use constant _FAKE_FILE_FORMAT => do {
Subroutine BEGIN: called CC=3 SCAR=11.2
29 3 ▶ my $uvx = $Config::Config{uvxformat} || '';
Condition50%1/2
$Config::Config{'uvxformat'} || ''
l!l
30
MC/DC0%0/1
$Config::Config{'uvxformat'} || ''
$Config::Config{'uvxformat'}
Truth table50%1/2
A
A= $Config::Config{'uvxformat'}
Aresult
11
00
30 3 $uvx =~ tr/"\0//d;
31 3 ▶ $uvx ||= 'lx';
Condition50%1/2
$uvx ||= "lx"
l!l
30
MC/DC0%0/1
$uvx ||= "lx"
$uvx
Truth table50%1/2
A
A= $uvx
Aresult
11
00
32 3 "/loader/0x%$uvx/%s"
33 3 };
34  
35 44 ▶sub _mod_to_file {
Subroutine _mod_to_file: called CC=1 SCAR=0.0
36 44 my $module = shift;
37 44 (my $file = "$module.pm") =~ s{::}{/}g;
38 44 $file;
39 }
40  
41 18 ▶sub module_content {
Subroutine module_content: called CC=4 SCAR=14.1
Pod documented
42 18 ▶ my $opts = ref $_[-1] eq 'HASH' && pop @_ || {};
Condition80%4/5
ref $_[-1] eq 'HASH' && pop @_ || {}
l!l
153
ref $_[-1] eq "HASH" and pop @_
!ll&&!rl&&r
3015
MC/DC50%1/2
ref $_[-1] eq 'HASH' && pop @_ || {}
ref $_[-1] eq "HASH" pop @_
Truth table66%2/3
A and B
A= ref $_[-1] eq "HASH"B= pop @_
ABresult
111
0X0
100
43 18 my $module = shift;
44 18 ▶ $opts->{inc} = [@_]
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 18 18
45 if @_;
46 18 __PACKAGE__->new($opts)->module($module)->content;
47 }
48  
49 0 ▶sub module_handle {
Subroutine module_handle: not called CC=4 SCAR=30.0
Pod documented
50 0 ▶ my $opts = ref $_[-1] eq 'HASH' && pop @_ || {};
Condition0%0/5
ref $_[-1] eq 'HASH' && pop @_ || {}
l!l
00
ref $_[-1] eq "HASH" and pop @_
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[-1] eq 'HASH' && pop @_ || {}
ref $_[-1] eq "HASH" pop @_
Truth table0%0/3
A and B
A= ref $_[-1] eq "HASH"B= pop @_
ABresult
111
0X0
100
51 0 my $module = shift;
52 0 ▶ $opts->{inc} = [@_]
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
53 if @_;
54 0 __PACKAGE__->new($opts)->module($module)->handle;
55 }
56  
57 119 ▶sub new {
Subroutine new: called CC=11 SCAR=24.8
Pod undocumented
58 119 my $class = shift;
59 119 my %options;
60 119 ▶ if (@_ == 1 && ref $_[-1]) {
Branch: 2 branches
BranchTrueFalseTotal
if (@_ == 1 and ref $_[-1]) { } 18 101 119
elsif (@_ % 2 == 0) { } 101 0 101
Condition66%2/3
@_ == 1 and ref $_[-1]
!ll&&!rl&&r
101018
MC/DC50%1/2
@_ == 1 and ref $_[-1]
@_ == 1 ref $_[-1]
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[-1]
ABresult
0X0
100
111
61 18 %options = %{(pop)};
62 }
63 elsif (@_ % 2 == 0) {
64 101 %options = @_;
65 }
66 else {
67 0 croak "Expected hash ref, or key value pairs. Got ".@_." arguments.";
68 }
69  
70 119 ▶ $options{inc} ||= \@INC;
Condition100%2/2
$options{"inc"} ||= \@INC
l!l
1145
MC/DC100%1/1
$options{"inc"} ||= \@INC
$options{"inc"}
Truth table100%2/2
A
A= $options{"inc"}
Aresult
11
00
71 $options{found} = \%INC
72 119 ▶ if exists $options{found} && $options{found} eq 1;
Branch: 1 branch
BranchTrueFalseTotal
if exists $options{"found"} and $options{"found"} eq 1 0 119 119
Condition66%2/3
exists $options{"found"} and $options{"found"} eq 1
!ll&&!rl&&r
93260
MC/DC0%0/2
exists $options{"found"} and $options{"found"} eq 1
exists $options{"found"} $options{"found"} eq 1
Truth table66%2/3
A and B
A= exists $options{"found"}B= $options{"found"} eq 1
ABresult
0X0
100
111
73 $options{pmc} = _PMC_ENABLED
74 119 ▶ if !exists $options{pmc};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"pmc"} 19 100 119
75 $options{open} = 1
76 119 ▶ if !exists $options{open};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"open"} 119 0 119
77 $options{abort_on_eacces} = _ABORT_ON_EACCES
78 119 ▶ if !exists $options{abort_on_eacces};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"abort_on_eacces"} 19 100 119
79 $options{check_hooks_for_nonsearchable} = 1
80 119 ▶ if !exists $options{check_hooks_for_nonsearchable};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $options{"check_hooks_for_nonsearchable"} 119 0 119
81 119 bless \%options, $class;
82 }
83  
84 44 ▶sub module {
Subroutine module: called CC=1 SCAR=0.0
Pod documented
85 44 my ($self, $module) = @_;
86 44 $self->file(_mod_to_file($module));
87 }
88  
89 0 ▶sub modules {
Subroutine modules: not called CC=1 SCAR=6.9
Pod documented
90 0 my ($self, $module) = @_;
91 0 $self->files(_mod_to_file($module));
92 }
93  
94 119 ▶sub file {
Subroutine file: called CC=1 SCAR=0.0
Pod documented
95 119 my ($self, $file) = @_;
96 119 $self->_find($file);
97 }
98  
99 0 ▶sub files {
Subroutine files: not called CC=1 SCAR=6.9
Pod documented
100 0 my ($self, $file) = @_;
101 0 $self->_find($file, 1);
102 }
103  
104 99 ▶sub _searchable {
Subroutine _searchable: called CC=3 SCAR=11.1
105 99 my $file = shift;
106 99 ▶ File::Spec->file_name_is_absolute($file) ? 0
Branch: 2 branches
BranchTrueFalseTotal
'File::Spec'->file_name_is_absolute($file) ? : 0 99 99
$file =~ m[^\.\.?/] ? : 25 74 99
107 : _WIN32 && $file =~ m{^\.\.?[/\\]} ? 0
108 : $file =~ m{^\.\.?/} ? 0
109 : 1
110 }
111  
112 119 ▶sub _find {
Subroutine _find: called CC=21 SCAR=32.4
113 119 my ($self, $file, $all) = @_;
114  
115 119 my @found;
116 119 eval {
117 119 ▶ if (my $found = $self->{found}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $found = $self->{"found"}) 26 93 119
118 26 ▶ if (defined( my $full = $found->{$file} )) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $full = $found->{$file})) 26 0 26
119 26 ▶ my $open = length ref $full ? $self->_open_ref($full, $file)
Branch: 1 branch
BranchTrueFalseTotal
length ref $full ? : 1 25 26
120 : $self->_open_file($full, $file);
121 23 ▶ push @found, $open
Branch: 1 branch
BranchTrueFalseTotal
if $open 17 6 23
122 if $open;
123 }
124 }
125 };
126 119 ▶ if (!$all) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($all) 119 0 119
127 119 ▶ return $found[0]
Branch: 1 branch
BranchTrueFalseTotal
if @found 17 102 119
128 if @found;
129 102 ▶ die $@
Branch: 1 branch
BranchTrueFalseTotal
if $@ 3 99 102
130 if $@;
131 }
132  
133 99 my $searchable = _searchable($file);
134 99 ▶ if (!$searchable) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($searchable) 25 74 99
135 25 my $open = $self->_open_file($file);
136 22 ▶ if ($all) {
Branch: 2 branches
BranchTrueFalseTotal
if ($all) { } 0 22 22
elsif ($open) { } 16 6 22
137 0 push @found, $open;
138 }
139 elsif ($open) {
140 16 return $open;
141 }
142 else {
143 6 croak "Can't locate $file";
144 }
145 }
146  
147 74 my $search = $self->{inc};
148 74 for my $inc (@$search) {
149 99 my $open;
150 99 ▶ if (!$searchable) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($searchable) 0 99 99
151 last
152 0 ▶ if !$self->{check_hooks_for_nonsearchable};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"check_hooks_for_nonsearchable"} 0 0 0
153 next
154 0 ▶ if !length ref $inc;
Branch: 1 branch
BranchTrueFalseTotal
unless length ref $inc 0 0 0
155 }
156 99 eval {
157 99 ▶ if (!length ref $inc) {
Branch: 1 branch
BranchTrueFalseTotal
if (not length ref $inc) { } 61 38 99
158 61 my $full = _VMS ? VMS::Filespec::unixpath($inc) : $inc;
159 61 $full =~ s{/?$}{/};
160 61 $full .= $file;
161 61 $open = $self->_open_file($full, $file, $inc);
162 }
163 else {
164 38 $open = $self->_open_ref($inc, $file);
165 }
166 77 ▶ push @found, $open
Branch: 1 branch
BranchTrueFalseTotal
if $open 52 25 77
167 if $open;
168 };
169 99 ▶ if (!$all) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($all) 99 0 99
170 99 ▶ return $found[0]
Branch: 1 branch
BranchTrueFalseTotal
if @found 52 47 99
171 if @found;
172 47 ▶ die $@
Branch: 1 branch
BranchTrueFalseTotal
if $@ 22 25 47
173 if $@;
174 }
175 }
176 0 ▶ croak "Can't locate $file"
Branch: 1 branch
BranchTrueFalseTotal
unless $all 0 0 0
177 if !$all;
178 0 return @found;
179 }
180  
181 111 ▶sub _open_file {
Subroutine _open_file: called CC=14 SCAR=26.6
182 111 my ($self, $full, $file, $inc) = @_;
183 111 ▶ $file = $full
Branch: 1 branch
BranchTrueFalseTotal
unless defined $file 25 86 111
184 if !defined $file;
185 111 ▶ for my $try (
Branch: 1 branch
BranchTrueFalseTotal
$self->{'pmc'} && $file =~ /\.pm\z/ ? : 76 35 111
Condition66%2/3
$self->{"pmc"} and $file =~ /\.pm\z/
!ll&&!rl&&r
35076
MC/DC50%1/2
$self->{"pmc"} and $file =~ /\.pm\z/
$self->{"pmc"} $file =~ /\.pm\z/
Truth table66%2/3
A and B
A= $self->{"pmc"}B= $file =~ /\.pm\z/
ABresult
0X0
100
111
186 ($self->{pmc} && $file =~ /\.pm\z/ ? $full.'c' : ()),
187 $full,
188 ) {
189 157 my $pmc = $full ne $try;
190 157 ▶ if (-e $try) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $try) 125 32 157
191 next
192 125 ▶ if -d _ || -b _;
Branch: 1 branch
BranchTrueFalseTotal
if -d _ or -b _ 31 94 125
Condition66%2/3
-d _ or -b _
l!l&&r!l&&!r
31094
MC/DC50%1/2
-d _ or -b _
-d _ -b _
Truth table66%2/3
A or B
A= -d _B= -b _
ABresult
1X1
011
000
193 94 ▶ if (open my $fh, '<'._OPEN_LAYERS, $try) {
Branch: 1 branch
BranchTrueFalseTotal
if (CORE::open my $fh, "<:", $try) 63 31 94
194 return Module::Reader::File->new(
195 filename => $file,
196 63 ▶ ($self->{open} ? (raw_filehandle => $fh) : ()),
Branch: 2 branches
BranchTrueFalseTotal
$self->{'open'} ? : 63 0 63
defined $inc ? : 31 32 63
197 found_file => $full,
198 disk_file => $try,
199 is_pmc => $pmc,
200 (defined $inc ? (inc_entry => $inc) : ()),
201 );
202 }
203 }
204  
205 croak "Can't locate $file: $full: $!"
206 63 ▶ if $self->{abort_on_eacces} && $! == EACCES && !$pmc;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"abort_on_eacces"} and $! == 13 and not $pmc 16 47 63
Condition83%5/6
$self->{"abort_on_eacces"} and $! == 13 and not $pmc
!ll&&!rl&&r
321516
$self->{"abort_on_eacces"} and $! == 13
!ll&&!rl&&r
03231
MC/DC66%2/3
$self->{"abort_on_eacces"} and $! == 13 and not $pmc
$self->{"abort_on_eacces"} $! == 13 not $pmc
Truth table75%3/4
A and B and not(C)
A= $self->{"abort_on_eacces"}B= $! == 13C= not $pmc
ABCresult
0XX0
10X0
1100
1111
207 }
208 32 return;
209 }
210  
211 39 ▶sub _open_ref {
Subroutine _open_ref: called CC=17 SCAR=28.8
212 39 my ($self, $inc, $file) = @_;
213  
214 39 my @cb;
215 {
216 # strings in arrayrefs are taken as sub names relative to main
217 39 package
218 main;
219 3 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
220 3 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
221 39 ▶ @cb = defined Scalar::Util::blessed $inc ? $inc->INC($file)
Branch: 2 branches
BranchTrueFalseTotal
defined builtin::blessed($inc) ? : 4 35 39
ref $inc eq 'ARRAY' ? : 6 29 35
222 : ref $inc eq 'ARRAY' ? $inc->[0]->($inc, $file)
223 : $inc->($inc, $file);
224 }
225  
226 return
227 27 ▶ unless length ref $cb[0];
Branch: 1 branch
BranchTrueFalseTotal
unless length ref $cb[0] 3 24 27
228  
229 24 my $fake_file = sprintf _FAKE_FILE_FORMAT, refaddr($inc), $file;
230  
231 24 my $fh;
232 my $prefix;
233 24 my $cb;
234 24 my $cb_options;
235  
236 24 ▶ if (_ALLOW_PREFIX && reftype $cb[0] eq 'SCALAR') {
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::reftype($cb[0]) eq "SCALAR") 0 24 24
237 0 $prefix = shift @cb;
238 }
239  
240 24 ▶ if ((reftype $cb[0]||'') eq 'GLOB' && openhandle $cb[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if ((builtin::reftype($cb[0]) || "") eq "GLOB" and &openhandle($cb[0])) 6 18 24
Condition60%3/5
(builtin::reftype($cb[0]) || "") eq "GLOB" and &openhandle($cb[0])
!ll&&!rl&&r
1806
builtin::reftype($cb[0]) || ''
l!l
240
MC/DC0%0/2
(builtin::reftype($cb[0]) || "") eq "GLOB" and &openhandle($cb[0])
builtin::reftype($cb[0]) &openhandle($cb[0])
Truth table33%1/3
A and B
A= builtin::reftype($cb[0])B= &openhandle($cb[0])
ABresult
0X0
100
111
241 6 $fh = shift @cb;
242 }
243  
244 24 ▶ if ((reftype $cb[0]||'') eq 'CODE') {
Branch: 2 branches
BranchTrueFalseTotal
if ((builtin::reftype($cb[0]) || '') eq 'CODE') { } 16 8 24
elsif (not defined $fh || defined $prefix) { } 2 6 8
Condition100%2/2
builtin::reftype($cb[0]) || ''
l!l
186
MC/DC100%1/1
builtin::reftype($cb[0]) || ''
builtin::reftype($cb[0])
Truth table100%2/2
A
A= builtin::reftype($cb[0])
Aresult
11
00
245 16 $cb = $cb[0];
246 # only one or zero callback options will be passed
247 16 ▶ $cb_options = @cb > 1 ? [ $cb[1] ] : undef;
Branch: 1 branch
BranchTrueFalseTotal
@cb > 1 ? : 0 16 16
248 }
249 ▶ elsif (!defined $fh && !defined $prefix) {
Condition66%2/3
defined $fh || defined $prefix
l!l&&r!l&&!r
602
MC/DC50%1/2
defined $fh || defined $prefix
defined $fh defined $prefix
Truth table66%2/3
A || B
A= defined $fhB= defined $prefix
ABresult
1X1
011
000
250 2 return;
251 }
252 22 ▶ return Module::Reader::File->new(
Branch: 4 branches
BranchTrueFalseTotal
defined $prefix ? : 0 22 22
defined $fh ? : 6 16 22
defined $cb ? : 16 6 22
defined $cb_options ? : 0 22 22
253 filename => $file,
254 found_file => $fake_file,
255 inc_entry => $inc,
256 (defined $prefix ? (prefix => $prefix) : ()),
257 (defined $fh ? (raw_filehandle => $fh) : ()),
258 (defined $cb ? (read_callback => $cb) : ()),
259 (defined $cb_options ? (read_callback_options => $cb_options) : ()),
260 );
261 }
262  
263 0 ▶sub inc { $_[0]->{inc} }
Subroutine inc: not called CC=1 SCAR=6.9
Pod documented
264 0 ▶sub found { $_[0]->{found} }
Subroutine found: not called CC=1 SCAR=6.9
Pod documented
265 0 ▶sub pmc { $_[0]->{pmc} }
Subroutine pmc: not called CC=1 SCAR=6.9
Pod documented
266 0 ▶sub open { $_[0]->{open} }
Subroutine open: not called CC=1 SCAR=6.9
Pod documented
267  
268 {
269 package Module::Reader::File;
270 3 ▶ use constant _OPEN_STRING => "$]" >= 5.008 || !require IO::String;
Subroutine BEGIN: called CC=2 SCAR=7.6
Condition33%1/3
"$]" >= 5.008 || !(require IO::String)
l!l&&r!l&&!r
300
MC/DC0%0/2
"$]" >= 5.008 || !(require IO::String)
"$]" >= 5.008 !(require IO::String)
Truth table33%1/3
A || not(B)
A= "$]" >= 5.008B= !(require IO::String)
ABresult
1X1
011
000
271 3 ▶ use Carp 'croak';
Subroutine BEGIN: called CC=1 SCAR=0.0
272  
273 85 ▶ sub new {
Subroutine new: called CC=4 SCAR=14.2
274 85 my ($class, %opts) = @_;
275 85 my $filename = $opts{filename};
276 85 ▶ if (!exists $opts{module} && $opts{filename}
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $opts{"module"} and $opts{"filename"} and $opts{"filename"} =~ m[\A(\w+(?:/\w+)?)\.pm\z]) 69 16 85
Condition50%3/6
not exists $opts{"module"} and $opts{"filename"} and $opts{"filename"} =~ m[\A(\w+(?:/\w+)?)\.pm\z]
!ll&&!rl&&r
01669
not exists $opts{"module"} and $opts{"filename"}
!ll&&!rl&&r
0085
MC/DC33%1/3
not exists $opts{"module"} and $opts{"filename"} and $opts{"filename"} =~ m[\A(\w+(?:/\w+)?)\.pm\z]
not exists $opts{"module"} $opts{"filename"} $opts{"filename"} =~ m[\A(\w+(?:/\w+)?)\.pm\z]
Truth table50%2/4
not(A) and B and C
A= not exists $opts{"module"}B= $opts{"filename"}C= $opts{"filename"} =~ m[\A(\w+(?:/\w+)?)\.pm\z]
ABCresult
0XX0
10X0
1100
1111
277 && $opts{filename} =~ m{\A(\w+(?:/\w+)?)\.pm\z}) {
278 69 my $module = $1;
279 69 $module =~ s{/}{::}g;
280 69 $opts{module} = $module;
281 }
282 85 bless \%opts, $class;
283 }
284  
285 0 ▶ sub filename { $_[0]->{filename} }
Subroutine filename: not called CC=1 SCAR=6.9
286 0 ▶ sub module { $_[0]->{module} }
Subroutine module: not called CC=1 SCAR=6.9
287 1 ▶ sub found_file { $_[0]->{found_file} }
Subroutine found_file: called CC=1 SCAR=0.0
288 14 ▶ sub disk_file { $_[0]->{disk_file} }
Subroutine disk_file: called CC=1 SCAR=0.0
289 48 ▶ sub is_pmc { $_[0]->{is_pmc} }
Subroutine is_pmc: called CC=1 SCAR=0.0
290 78 ▶ sub inc_entry { $_[0]->{inc_entry} }
Subroutine inc_entry: called CC=1 SCAR=0.0
291 6 ▶ sub read_callback { $_[0]->{read_callback} }
Subroutine read_callback: called CC=1 SCAR=0.0
292 0 ▶ sub read_callback_options { $_[0]->{read_callback_options} }
Subroutine read_callback_options: not called CC=1 SCAR=6.9
293 6 ▶ sub raw_filehandle {
Subroutine raw_filehandle: called CC=4 SCAR=25.0
294 6 ▶ $_[0]->{raw_filehandle} ||= !$_[0]->{disk_file} ? undef : do {
Branch: 1 branch
BranchTrueFalseTotal
!$_[0]{'disk_file'} ? : 0 0 0
Condition33%1/3
$_[0]{"raw_filehandle"} ||= !$_[0]{"disk_file"} ? undef : do { open my $fh, "<:", $_[0]{"disk_file"} or croak(qq[Can't locate $_[0]{"disk_file"}]); $fh }
l!l&&r!l&&!r
600
MC/DC0%0/2
$_[0]{"raw_filehandle"} ||= !$_[0]{"disk_file"} ? undef : do { open my $fh, "<:", $_[0]{"disk_file"} or croak(qq[Can't locate $_[0]{"disk_file"}]); $fh }
$_[0]{"raw_filehandle"} !$_[0]{"disk_file"} ? undef : do { open my $fh, "<:", $_[0]{"disk_file"} or croak(qq[Can't locate $_[0]{"disk_file"}]); $fh }
Truth table33%1/3
A ||= not(B)
A= $_[0]{"raw_filehandle"}B= !$_[0]{"disk_file"} ? undef : do { open my $fh, "<:", $_[0]{"disk_file"} or croak(qq[Can't locate $_[0]{"disk_file"}]); $fh }
ABresult
1X1
011
000
295 open my $fh, '<'.Module::Reader::_OPEN_LAYERS, $_[0]->{disk_file}
296 0 ▶ or croak "Can't locate $_[0]->{disk_file}";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<:", $_[0]{"disk_file"} or croak(qq[Can't locate $_[0]{"disk_file"}]) 0 0 0
297 0 $fh;
298 };
299 }
300  
301 6 ▶ sub content {
Subroutine content: called CC=10 SCAR=34.3
302 6 my $self = shift;
303 return $self->{content}
304 6 ▶ if exists $self->{content};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"content"} 0 6 6
305 6 my $fh = $self->raw_filehandle;
306 6 my $cb = $self->read_callback;
307 0 ▶ my $content = defined $self->{prefix} ? ${$self->{prefix}} : '';
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'prefix'} ? : 0 6 6
308 6 ▶ if ($fh && !$cb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh and not $cb) 6 0 6
Condition33%1/3
$fh and not $cb
!ll&&!rl&&r
006
MC/DC0%0/2
$fh and not $cb
$fh not $cb
Truth table33%1/3
A and not(B)
A= $fhB= not $cb
ABresult
0X0
100
111
309 6 local $/;
310 6 $content .= <$fh>;
311 }
312 6 ▶ if ($cb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($cb) 0 6 6
313 0 ▶ my @params = @{$self->read_callback_options||[]};
Condition0%0/2
$self->read_callback_options || []
l!l
00
MC/DC0%0/1
$self->read_callback_options || []
$self->read_callback_options
Truth table0%0/2
A
A= $self->read_callback_options
Aresult
11
00
314 0 while (1) {
315 0 ▶ local $_ = $fh ? <$fh> : '';
Branch: 1 branch
BranchTrueFalseTotal
$fh ? : 0 0 0
316 0 ▶ $_ = ''
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_ 0 0 0
317 if !defined;
318 # perlfunc/require says that the first parameter will be a reference the
319 # sub itself. this is wrong. 0 will be passed.
320 0 ▶ last if !$cb->(0, @params);
Branch: 1 branch
BranchTrueFalseTotal
unless &$cb(0, @params) 0 0 0
321 0 $content .= $_;
322 }
323 }
324 6 return $self->{content} = $content;
325 }
326  
327 0 ▶ sub handle {
Subroutine handle: not called CC=5 SCAR=34.0
328 0 my $self = shift;
329 0 my $fh = $self->raw_filehandle;
330 0 ▶ if ($fh && !$self->read_callback && -f $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if ($fh and not $self->read_callback and -f $fh) 0 0 0
Condition0%0/6
$fh and not $self->read_callback and -f $fh
!ll&&!rl&&r
000
$fh and not $self->read_callback
!ll&&!rl&&r
000
MC/DC0%0/3
$fh and not $self->read_callback and -f $fh
$fh not $self->read_callback -f $fh
Truth table0%0/4
A and not(B) and C
A= $fhB= not $self->read_callbackC= -f $fh
ABCresult
0XX0
10X0
1100
1111
331 0 ▶ open my $dup, '<&', $fh
Branch: 1 branch
BranchTrueFalseTotal
open my $dup, "<&", $fh or croak("can't dup file handle: $!") 0 0 0
332 or croak "can't dup file handle: $!";
333 0 return $dup;
334 }
335 0 my $content = $self->content;
336 0 if (_OPEN_STRING) {
337 0 open my $fh, '<', \$content;
338 0 return $fh;
339 }
340 else {
341 return IO::String->new($content);
342 }
343 }
344 }
345  
346 3 1;
347  
348 __END__
↑ Summary