Expander/Plugin/ApplicationZip.pm

filter: Statementstmt 100% 34 / 34 Branchbran 68.7% 11 / 16 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 87.1% 54 / 62 CC 10 SCAR 19.9
CC
10
Cov
89%
expand
10.5
BEGIN
1.0
BEGIN
1.0
CRAP 7.3
↑ Summary Expander.pm »
1 package MIME::Expander::Plugin::ApplicationZip;
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 4 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 $VERSION = '0.01';
7  
8 4 ▶use parent qw(MIME::Expander::Plugin);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 __PACKAGE__->mk_classdata('ACCEPT_TYPES' => [qw(
10 application/zip
11 application/x-zip
12 )]);
13  
14 4 ▶use IO::Uncompress::Unzip;
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 sub expand {
17 3 ▶ my $self = shift;
Subroutine expand: called CC=10 SCAR=23.5
Pod undocumented
18 3 my $contents = shift;
19 3 my $callback = shift;
20 3 my $c = 0;
21  
22 3 ▶ my $uzip = IO::Uncompress::Unzip->new(
Branch: 2 branches
BranchTrueFalseTotal
my $uzip = "IO::Uncompress::Unzip"->new(ref $contents eq "SCALAR" ? $contents : \$contents, "Append", 1) or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n" 0 3 3
ref $contents eq 'SCALAR' ? : 3 0 3
23 ref $contents eq 'SCALAR' ? $contents : \$contents
24 , Append => 1)
25 or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n";
26  
27 3 my $status;
28 3 ▶ for( $status = 1; 0 < $status; $status = $uzip->nextStream ){
Branch: 1 branch
BranchTrueFalseTotal
if (0 < $status) 9 3 12
29  
30 9 ▶ die "Error processing as zip: $!"
Branch: 1 branch
BranchTrueFalseTotal
if $status < 0 0 9 9
31 if( $status < 0 );
32  
33 9 my $bytes;
34 my $buff;
35 9 ▶ 1 while( 0 < ($bytes = $uzip->read($buff)) );
Branch: 1 branch
BranchTrueFalseTotal
0 < ($bytes = $uzip->read($buff)) and do { '???' } 12 9 21
36  
37 9 ▶ last if( $bytes < 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $bytes < 0 0 9 9
38  
39 9 my $name = $uzip->getHeaderInfo->{Name};
40 9 ▶ next if( $name and $name =~ m,/$, );
Branch: 1 branch
BranchTrueFalseTotal
if $name and $name =~ m[/$] 3 6 9
Condition66%2/3
$name and $name =~ m[/$]
!ll&&!rl&&r
063
MC/DC50%1/2
$name and $name =~ m[/$]
$name $name =~ m[/$]
Truth table66%2/3
A and B
A= $nameB= $name =~ m[/$]
ABresult
0X0
100
111
41
42 6 ▶ $callback->( \$buff, {
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback eq "CODE" 6 0 6
43 filename => $name,
44 } ) if( ref $callback eq 'CODE' );
45 6 ++$c;
46 }
47  
48 3 return $c;
49 }
50  
51 4 1;
52 __END__
↑ Summary Expander.pm »