blib/lib/IO/Compress/Adapter/Deflate.pm

filter: Statementstmt 78.0% 64 / 82 Branchbran 50.0% 7 / 14 Conditioncond 66.6% 2 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 75.0% 12 / 16 Podpod 0.0% 0 / 11 totaltotal 66.4% 85 / 128 CC 9 SCAR 8.0
CC
9
Cov
74%
reset
6.0
flush
3.0
compr
2.1
CRAP 2.2
« blib/lib/IO/Compress/Adapter/Identity.pm ↑ Summary blib/lib/IO/Uncompress/AnyInflate.pm »
1 package IO::Compress::Adapter::Deflate ;
2  
3 103 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 103 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 103 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 103 ▶use IO::Compress::Base::Common 2.225 qw(:Status);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 103 ▶use Compress::Raw::Zlib 2.225 qw( !crc32 !adler32 ) ;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 103 require Exporter;
11 103 our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, @EXPORT, %DEFLATE_CONSTANTS);
12  
13 103 $VERSION = '2.225';
14 103 @ISA = qw(Exporter);
15 103 @EXPORT_OK = @Compress::Raw::Zlib::DEFLATE_CONSTANTS;
16 103 %EXPORT_TAGS = %Compress::Raw::Zlib::DEFLATE_CONSTANTS;
17 103 @EXPORT = @EXPORT_OK;
18 103 %DEFLATE_CONSTANTS = %EXPORT_TAGS ;
19  
20 sub mkCompObject
21 1081 ▶{
Subroutine mkCompObject: called CC=2 SCAR=7.0
Pod undocumented
22 1081 my $crc32 = shift ;
23 1081 my $adler32 = shift ;
24 1081 my $level = shift ;
25 1081 my $strategy = shift ;
26  
27 1081 my ($def, $status) = Compress::Raw::Zlib::Deflate->new(
28 -AppendOutput => 1,
29 -CRC32 => $crc32,
30 -ADLER32 => $adler32,
31 -Level => $level,
32 -Strategy => $strategy,
33 -WindowBits => - MAX_WBITS);
34  
35 1081 ▶ return (undef, "Cannot create Deflate object: $status", $status)
Branch: 1 branch
BranchTrueFalseTotal
if $status != Z_OK() 0 1081 1081
36 if $status != Z_OK;
37  
38 1081 return bless {'Def' => $def,
39 'Error' => '',
40 } ;
41 }
42  
43 sub mkCompObject1
44 299 ▶{
Subroutine mkCompObject1: called CC=2 SCAR=7.0
Pod undocumented
45 299 my $crc32 = shift ;
46 299 my $adler32 = shift ;
47 299 my $level = shift ;
48 299 my $strategy = shift ;
49  
50 299 my ($def, $status) = Compress::Raw::Zlib::Deflate->new(
51 -AppendOutput => 1,
52 -CRC32 => $crc32,
53 -ADLER32 => $adler32,
54 -Level => $level,
55 -Strategy => $strategy,
56 -WindowBits => MAX_WBITS);
57  
58 299 ▶ return (undef, "Cannot create Deflate object: $status", $status)
Branch: 1 branch
BranchTrueFalseTotal
if $status != Z_OK() 0 299 299
59 if $status != Z_OK;
60  
61 299 return bless {'Def' => $def,
62 'Error' => '',
63 } ;
64 }
65  
66 sub compr
67 1359 ▶{
Subroutine compr: called CC=2 SCAR=7.5
Pod undocumented
68 1359 my $self = shift ;
69  
70 1359 my $def = $self->{Def};
71  
72 1359 my $status = $def->deflate($_[0], $_[1]) ;
73 1359 $self->{ErrorNo} = $status;
74  
75 1359 ▶ if ($status != Z_OK)
Branch: 1 branch
BranchTrueFalseTotal
if ($status != Z_OK()) 0 1359 1359
76 {
77 0 $self->{Error} = "Deflate Error: $status";
78 0 return STATUS_ERROR;
79 }
80  
81 1359 return STATUS_OK;
82 }
83  
84 sub flush
85 31 ▶{
Subroutine flush: called CC=3 SCAR=11.0
Pod undocumented
86 31 my $self = shift ;
87  
88 31 my $def = $self->{Def};
89  
90 31 ▶ my $opt = $_[1] || Z_FINISH;
Condition66%2/3
$_[1] || Z_FINISH()
l!l&&r!l&&!r
14170
MC/DC0%0/2
$_[1] || Z_FINISH()
$_[1] Z_FINISH()
Truth table66%2/3
A || B
A= $_[1]B= Z_FINISH()
ABresult
1X1
011
000
91 31 my $status = $def->flush($_[0], $opt);
92 31 $self->{ErrorNo} = $status;
93  
94 31 ▶ if ($status != Z_OK)
Branch: 1 branch
BranchTrueFalseTotal
if ($status != Z_OK()) 1 30 31
95 {
96 1 $self->{Error} = "Deflate Error: $status";
97 1 return STATUS_ERROR;
98 }
99  
100 30 return STATUS_OK;
101 }
102  
103 sub close
104 1435 ▶{
Subroutine close: called CC=2 SCAR=7.1
Pod undocumented
105 1435 my $self = shift ;
106  
107 1435 my $def = $self->{Def};
108  
109 1435 ▶ $def->flush($_[0], Z_FINISH)
Branch: 1 branch
BranchTrueFalseTotal
if defined $def 1435 0 1435
110 if defined $def ;
111 }
112  
113 sub reset
114 0 ▶{
Subroutine reset: not called CC=2 SCAR=17.9
Pod undocumented
115 0 my $self = shift ;
116  
117 0 my $def = $self->{Def};
118  
119 0 my $status = $def->deflateReset() ;
120 0 $self->{ErrorNo} = $status;
121 0 ▶ if ($status != Z_OK)
Branch: 1 branch
BranchTrueFalseTotal
if ($status != Z_OK()) 0 0 0
122 {
123 0 $self->{Error} = "Deflate Error: $status";
124 0 return STATUS_ERROR;
125 }
126  
127 0 return STATUS_OK;
128 }
129  
130 sub deflateParams
131 4 ▶{
Subroutine deflateParams: called CC=2 SCAR=7.5
Pod undocumented
132 4 my $self = shift ;
133  
134 4 my $def = $self->{Def};
135  
136 4 my $status = $def->deflateParams(@_);
137 4 $self->{ErrorNo} = $status;
138 4 ▶ if ($status != Z_OK)
Branch: 1 branch
BranchTrueFalseTotal
if ($status != Z_OK()) 0 4 4
139 {
140 0 $self->{Error} = "deflateParams Error: $status";
141 0 return STATUS_ERROR;
142 }
143  
144 4 return STATUS_OK;
145 }
146  
147  
148  
149 #sub total_out
150 #{
151 # my $self = shift ;
152 # $self->{Def}->total_out();
153 #}
154 #
155 #sub total_in
156 #{
157 # my $self = shift ;
158 # $self->{Def}->total_in();
159 #}
160  
161 sub compressedBytes
162 0 ▶{
Subroutine compressedBytes: not called CC=1 SCAR=6.9
Pod undocumented
163 0 my $self = shift ;
164  
165 0 $self->{Def}->compressedBytes();
166 }
167  
168 sub uncompressedBytes
169 0 ▶{
Subroutine uncompressedBytes: not called CC=1 SCAR=6.9
Pod undocumented
170 0 my $self = shift ;
171 0 $self->{Def}->uncompressedBytes();
172 }
173  
174  
175  
176  
177 sub crc32
178 1144 ▶{
Subroutine crc32: called CC=1 SCAR=0.0
Pod undocumented
179 1144 my $self = shift ;
180 1144 $self->{Def}->crc32();
181 }
182  
183 sub adler32
184 0 ▶{
Subroutine adler32: not called CC=1 SCAR=6.9
Pod undocumented
185 0 my $self = shift ;
186 0 $self->{Def}->adler32();
187 }
188  
189  
190 103 1;
191  
192 __END__
« blib/lib/IO/Compress/Adapter/Identity.pm ↑ Summary blib/lib/IO/Uncompress/AnyInflate.pm »