File Coverage

blib/lib/Data/TableReader/Decoder.pm
Criterion Covered Total %
statement 13 16 81.2
branch 7 8 87.5
condition 1 3 33.3
subroutine 2 2 100.0
pod n/a
total 23 29 79.3


line stmt bran cond sub pod time code
1             package Data::TableReader::Decoder;
2 11     11   6140 use Moo 2;
  11         196  
  11         77  
3              
4             # ABSTRACT: Base class for table decoders
5             our $VERSION = '0.021'; # VERSION
6              
7              
8             has file_name => ( is => 'ro', required => 1 );
9             has file_handle => ( is => 'ro', required => 1 );
10             has _log => ( is => 'ro', required => 1 );
11             *log= *_log; # back-compat, but deprecated since it doesn't match ->log on TableReader
12              
13             sub _first_sufficient_module {
14 5     5   21 my ($name, $modules, $req_versions)= @_;
15 5         2127 require Module::Runtime;
16 5         6933 for my $mod (@$modules) {
17 6 100       98849 my ($pkg, $ver)= ref $mod eq 'ARRAY'? @$mod : ( $mod, 0 );
18 6 100       16 next unless eval { Module::Runtime::use_module($pkg, $ver) };
  6         28  
19             # Special case for Excel modules that use Archive::Zip and don't declare proper
20             # version requirements for it:
21             # https://github.com/MichaelDaum/spreadsheet-parsexlsx/pull/12
22 4 50 33     112751 if ($pkg =~ /XLSX/ && !eval { Module::Runtime::use_module('Archive::Zip', 1.34) }) {
  0         0  
23 0         0 Carp::carp("Your version of Archive::Zip is not new enough to make use of $pkg");
24 0         0 next;
25             }
26 4         54 return $pkg
27             }
28 1         173 require Carp;
29 1 100       350 Carp::croak "No $name available (or of sufficient version); install one of: "
30             .join(', ', map +(ref $_ eq 'ARRAY'? "$_->[0] >= $_->[1]" : $_), @$modules);
31             }
32              
33             1;
34              
35             __END__