blib/lib/Gzip/Libdeflate.pm

filter: Statementstmt 85.7% 42 / 49 Branchbran 44.4% 8 / 18 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 50.0% 2 / 4 totaltotal 75.9% 60 / 79 CC 10 SCAR 13.7
CC
10
Cov
75%
decompress_file
6.7
get_from
5.3
compress_file
2.1
CRAP 3.9
↑ Summary libdeflate-one.c »
1 package Gzip::Libdeflate;
2 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 our $VERSION = '0.13';
5 2 require XSLoader;
6 2 XSLoader::load ('Gzip::Libdeflate', $VERSION);
7  
8 2 ▶use File::Slurper qw!read_binary write_binary!;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 sub get_from
12 4 ▶{
Subroutine get_from: called CC=4 SCAR=16.6
Pod undocumented
13 4 my (%options) = @_;
14 4 my $from;
15 4 ▶ if ($options{in}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($options{'in'}) { } 4 0 4
elsif ($options{'from'}) { } 0 0 0
16 4 $from = read_binary ($options{in});
17 }
18 elsif ($options{from}) {
19 0 $from = $options{from};
20 }
21 4 ▶ if (! $from) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($from) 0 4 4
22 0 carp "Specify one of from => scalar or in => file";
23 }
24 4 return $from;
25 }
26  
27 sub make_out
28 4 ▶{
Subroutine make_out: called CC=2 SCAR=6.9
Pod undocumented
29 4 my ($out, %options) = @_;
30 4 my $outfile = $options{out};
31 4 ▶ if ($outfile) {
Branch: 1 branch
BranchTrueFalseTotal
if ($outfile) 2 2 4
32 2 write_binary ($outfile, $out);
33 }
34 4 return $out;
35 }
36  
37 sub compress_file
38 1 ▶{
Subroutine compress_file: called CC=2 SCAR=7.2
Pod documented
39 1 my ($o, %options) = @_;
40 1 my $from = get_from (%options);
41 1 ▶ if (! $from) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($from) 0 1 1
42 0 return undef;
43 }
44 1 my $out = $o->compress ($from);
45 1 return make_out ($out, %options);
46 }
47  
48 sub decompress_file
49 3 ▶{
Subroutine decompress_file: called CC=5 SCAR=19.0
Pod documented
50 3 my ($o, %options) = @_;
51 3 my $from = get_from (%options);
52 3 ▶ if (! $from) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($from) 0 3 3
53 0 return undef;
54 }
55 3 my $type = $o->get_type ();
56 3 ▶ if ($type ne 'gzip') {
Branch: 1 branch
BranchTrueFalseTotal
if ($type ne "gzip") 0 3 3
57 0 ▶ if (! $options{size}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($options{"size"}) 0 0 0
58 0 warn "A non-zero numerical size is required to decompress deflate/zlib inputs";
59 0 return undef;
60 }
61 }
62 3 my $size = $options{size};
63 3 ▶ if (! $size) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($size) 3 0 3
64 3 $size = 0;
65 }
66 3 my $out = $o->decompress ($from, $size);
67 3 return make_out ($out, %options);
68 }
69  
70 2 1;
↑ Summary libdeflate-one.c »