Expander/Plugin/ApplicationZip.pm

filter: Statementstmt 100% 35 / 35 Branchbran 71.4% 10 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 88.5% 54 / 61 CC 9 SCAR 18.4
CC
9
Cov
90%
expand
9.3
BEGIN
1.0
BEGIN
1.0
CRAP 6.3
« Expander.pm ↑ Summary Expander/Plugin/ApplicationBzip2.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.02';
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 )]);
12  
13 4 ▶use IO::Uncompress::Unzip;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 4 ▶sub expand {
Subroutine expand: called CC=9 SCAR=22.3
Pod undocumented
16 4 my $self = shift;
17 4 my $part = shift;
18 4 my $callback = shift;
19 4 my $c = 0;
20  
21 4 my $contents = $part->body;
22 4 ▶ my $uzip = IO::Uncompress::Unzip->new(
Branch: 1 branch
BranchTrueFalseTotal
my $uzip = "IO::Uncompress::Unzip"->new(\$contents, "Append", 1) or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n" 4 0 4
23 \$contents, Append => 1
24 ) or die "unzip failed: $IO::Uncompress::Unzip::UnzipError\n";
25  
26 4 my $status;
27 4 ▶ for( $status = 1; 0 < $status; $status = $uzip->nextStream ){
Branch: 1 branch
BranchTrueFalseTotal
if (0 < $status) 11 4 15
28  
29 11 ▶ die "Error processing as zip: $!"
Branch: 1 branch
BranchTrueFalseTotal
if $status < 0 0 11 11
30 if( $status < 0 );
31  
32 11 my $bytes;
33 my $buff;
34 11 ▶ 1 while( 0 < ($bytes = $uzip->read($buff)) );
Branch: 1 branch
BranchTrueFalseTotal
0 < ($bytes = $uzip->read($buff)) and do { '???' } 14 11 25
35  
36 11 ▶ last if( $bytes < 0 );
Branch: 1 branch
BranchTrueFalseTotal
if $bytes < 0 0 11 11
37  
38 11 my $name = $uzip->getHeaderInfo->{Name};
39 11 ▶ next if( $name and $name =~ m,/$, );
Branch: 1 branch
BranchTrueFalseTotal
if $name and $name =~ m[/$] 3 8 11
Condition66%2/3
$name and $name =~ m[/$]
!ll&&!rl&&r
083
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
40
41 8 ▶ $callback->( \$buff, {
Branch: 1 branch
BranchTrueFalseTotal
if ref $callback eq "CODE" 8 0 8
42 filename => $name,
43 } ) if( ref $callback eq 'CODE' );
44 8 ++$c;
45 }
46  
47 4 return $c;
48 }
49  
50 4 1;
51 __END__
« Expander.pm ↑ Summary Expander/Plugin/ApplicationBzip2.pm »