TableReader/Decoder.pm

filter: Statementstmt 88.4% 23 / 26 Branchbran 90.0% 9 / 10 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 3 / 3 Podpod 0.0% 0 / 1 totaltotal 78.0% 39 / 50 CC 9 SCAR 17.7
CC
9
Cov
83%
_first_sufficient_module
7.8
BUILD
3.0
BEGIN
1.0
CRAP 5.9
« TableReader/Decoder/Spreadsheet.pm ↑ Summary TableReader/Decoder/Mock.pm »
1 package Data::TableReader::Decoder;
2 12 ▶use Moo 2;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 # ABSTRACT: Base class for table decoders
5 12 our $VERSION = '0.023'; # VERSION
6  
7  
8 12 has file_handle => ( is => 'ro', required => 1 );
9 12 has real_file_name => ( is => 'rw' );
10 12 has client_file_name => ( is => 'rw' );
11 12 *file_name= *real_file_name; # back-compat
12  
13 12 has _log => ( is => 'ro', required => 1 );
14 12 *log= *_log; # back-compat, but deprecated since it doesn't match ->log on TableReader
15  
16 58 ▶sub BUILD {
Subroutine BUILD: called CC=3 SCAR=11.1
Pod undocumented
17 58 my ($self, $args)= @_;
18 # Previous attribute name was 'file_name'
19 $self->real_file_name($args->{file_name})
20 58 ▶ if defined $args->{file_name} && !defined $self->real_file_name;
Branch: 1 branch
BranchTrueFalseTotal
if defined $args->{"file_name"} and not defined $self->real_file_name 15 43 58
Condition66%2/3
defined $args->{"file_name"} and not defined $self->real_file_name
!ll&&!rl&&r
43015
MC/DC50%1/2
defined $args->{"file_name"} and not defined $self->real_file_name
defined $args->{"file_name"} not defined $self->real_file_name
Truth table66%2/3
A and not(B)
A= defined $args->{"file_name"}B= not defined $self->real_file_name
ABresult
0X0
100
111
21 }
22  
23 5 ▶sub _first_sufficient_module {
Subroutine _first_sufficient_module: called CC=7 SCAR=20.5
24 5 my ($name, $modules, $req_versions)= @_;
25 5 require Module::Runtime;
26 5 for my $mod (@$modules) {
27 6 ▶ my ($pkg, $ver)= ref $mod eq 'ARRAY'? @$mod : ( $mod, 0 );
Branch: 1 branch
BranchTrueFalseTotal
ref $mod eq 'ARRAY' ? : 5 1 6
28 6 ▶ next unless eval { Module::Runtime::use_module($pkg, $ver) };
Branch: 1 branch
BranchTrueFalseTotal
unless eval { do { Module::Runtime::use_module($pkg, $ver) } } 2 4 6
29 # Special case for Excel modules that use Archive::Zip and don't declare proper
30 # version requirements for it:
31 # https://github.com/MichaelDaum/spreadsheet-parsexlsx/pull/12
32 0 ▶ if ($pkg =~ /XLSX/ && !eval { Module::Runtime::use_module('Archive::Zip', 1.34) }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg =~ /XLSX/ and not eval { do { Module::Runtime::use_module("Archive::Zip", "1.34") } }) 0 4 4
Condition33%1/3
$pkg =~ /XLSX/ and not eval { do { Module::Runtime::use_module("Archive::Zip", "1.34") } }
!ll&&!rl&&r
400
MC/DC0%0/2
$pkg =~ /XLSX/ and not eval { do { Module::Runtime::use_module("Archive::Zip", "1.34") } }
$pkg =~ /XLSX/ not eval { do { Module::Runtime::use_module("Archive::Zip", "1.34") } }
Truth table33%1/3
A and not(B)
A= $pkg =~ /XLSX/B= not eval { do { Module::Runtime::use_module("Archive::Zip", "1.34") } }
ABresult
0X0
100
111
33 0 Carp::carp("Your version of Archive::Zip is not new enough to make use of $pkg");
34 0 next;
35 }
36 4 return $pkg
37 }
38 1 require Carp;
39 1 ▶ Carp::croak "No $name available (or of sufficient version); install one of: "
Branch: 1 branch
BranchTrueFalseTotal
ref $_ eq 'ARRAY' ? : 1 1 2
40 .join(', ', map +(ref $_ eq 'ARRAY'? "$_->[0] >= $_->[1]" : $_), @$modules);
41 }
42  
43 12 1;
44  
45 __END__
« TableReader/Decoder/Spreadsheet.pm ↑ Summary TableReader/Decoder/Mock.pm »