Stream.pm

filter: Statementstmt 77.7% 21 / 27 Branchbran 33.3% 4 / 12 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 80.0% 4 / 5 Podpod 33.3% 1 / 3 totaltotal 66.0% 33 / 50 CC 8 SCAR 21.6
CC
8
Cov
66%
new
12.3
xlsx
2.0
BEGIN
1.0
CRAP 8.6
« Stream/XLSX.pm ↑ Summary Stream/XLS.pm »
1 package Spreadsheet::ParseExcel::Stream;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 8 our $VERSION = '0.11';
7  
8 8 ▶sub new {
Subroutine new: called CC=8 SCAR=25.1
Pod documented
9  
10 8 my ($class, $file, $opts) = @_;
11 8 ▶ $opts ||= {};
Condition100%2/2
$opts ||= {}
l!l
26
MC/DC100%1/1
$opts ||= {}
$opts
Truth table100%2/2
A
A= $opts
Aresult
11
00
12 8 my $type = $opts->{Type};
13  
14 8 ▶ if ($type) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type) 0 8 8
15 0 ▶ return $class->xls($file, $opts) if $type =~ /^xls$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /^xls$/i 0 0 0
16 0 ▶ return $class->xlsx($file, $opts) if $type =~ /^xlsx$/i;
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /^xlsx$/i 0 0 0
17 0 die "Can not parse file $file of type $type";
18 }
19  
20 8 ▶ open(my $fh, "<", $file) or die "Failed to open $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Failed to open ${file}: $!" 8 0 8
21 8 my $cnt = read($fh, my $pk, 4);
22 8 close $fh;
23 8 ▶ die "Unable to read header from $file" unless $cnt == 4;
Branch: 1 branch
BranchTrueFalseTotal
unless $cnt == 4 0 8 8
24  
25 8 ▶ return $class->xlsx($file, $opts) if $pk eq "PK\003\004";
Branch: 1 branch
BranchTrueFalseTotal
if $pk eq "PK\3\4" 0 8 8
26 8 return $class->xls($file, $opts);
27 }
28  
29 8 ▶sub xls {
Subroutine xls: called CC=1 SCAR=0.0
Pod undocumented
30 8 my ($class, $file, $opts) = @_;
31 8 require Spreadsheet::ParseExcel::Stream::XLS;
32 8 return Spreadsheet::ParseExcel::Stream::XLS->new($file, $opts);
33 }
34  
35 0 ▶sub xlsx {
Subroutine xlsx: not called CC=1 SCAR=6.9
Pod undocumented
36 0 my ($class, $file, $opts) = @_;
37 0 require Spreadsheet::ParseExcel::Stream::XLSX;
38 0 return Spreadsheet::ParseExcel::Stream::XLSX->new($file, $opts);
39 }
40  
41 8 1;
42  
43 __END__
« Stream/XLSX.pm ↑ Summary Stream/XLS.pm »