blib/lib/EBook/Ishmael/EBook/CB7.pm

filter: Statementstmt 62.2% 28 / 45 Branchbran 25.0% 2 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 70.0% 7 / 10 Podpod 0.0% 0 / 3 totaltotal 56.0% 37 / 66 CC 4 SCAR 13.6
CC
4
Cov
57%
_un7zip
12.0
heuristic
2.2
extract
2.0
CRAP 3.9
« blib/lib/EBook/Ishmael/ShellQuote.pm ↑ Summary blib/lib/EBook/Ishmael/EBook/CBR.pm »
1 package EBook::Ishmael::EBook::CB7;
2 17 ▶use 5.016;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 17 our $VERSION = '2.04';
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 17 ▶use parent 'EBook::Ishmael::EBook::CB';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 17 ▶use File::Which;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 17 ▶use EBook::Ishmael::ShellQuote qw(safe_qx);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 17 my $MAGIC = pack "C*", 0x37, 0x7a, 0xbc, 0xaf, 0x27, 0x1c;
14  
15 17 my $SZIP;
16 17 for my $b (qw(7z 7za)) {
17 34 ▶ if (defined which($b)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined which($b)) 0 34 34
18 0 $SZIP = $b;
19 0 last;
20 }
21 }
22  
23 17 our $CAN_TEST = defined $SZIP;
24  
25 sub heuristic {
26  
27 126 ▶ my $class = shift;
Subroutine heuristic: called CC=2 SCAR=7.9
Pod undocumented
28 126 my $file = shift;
29 126 my $fh = shift;
30  
31 126 ▶ return 0 unless $file =~ /\.cb7$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ /\.cb7$/u 126 0 126
32  
33 0 read $fh, my $mag, length $MAGIC;
34  
35 0 return $mag eq $MAGIC;
36  
37 }
38  
39 sub _un7zip {
40  
41 0 ▶ my $zip = shift;
Subroutine _un7zip: not called CC=3 SCAR=24.8
42 0 my $out = shift;
43  
44 0 ▶ unless (defined $SZIP) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $SZIP) 0 0 0
45 0 die "Cannot un-7zip $zip; 7z not installed\n";
46 }
47  
48 0 safe_qx($SZIP, 'x', "-o$out", $zip);
49 0 ▶ unless ($? >> 8 == 0) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($? >> 8 == 0) 0 0 0
50 0 die "Failed to run '$SZIP' on $zip\n";
51 }
52  
53 0 return 1;
54  
55 }
56  
57 sub extract {
58  
59 0 ▶ my $self = shift;
Subroutine extract: not called CC=1 SCAR=6.9
Pod undocumented
60 0 my $out = shift;
61  
62 0 _un7zip($self->{Source}, $out);
63  
64 0 return 1;
65  
66 }
67  
68 0 ▶sub format { 'CB7' }
Subroutine format: not called CC=1 SCAR=6.9
Pod undocumented
69  
70 17 1;
« blib/lib/EBook/Ishmael/ShellQuote.pm ↑ Summary blib/lib/EBook/Ishmael/EBook/CBR.pm »