SimpleExtractor/Tar.pm

filter: Statementstmt 47.6% 20 / 42 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 1 totaltotal 43.3% 26 / 60 CC 8 SCAR 37.3
CC
8
Cov
38%
extract
72.0
BEGIN
1.0
BEGIN
1.0
CRAP 41.6
↑ Summary SimpleExtractor/Zip.pm »
1 package Archive::SimpleExtractor::Tar;
2  
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use Archive::Tar;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use File::Find;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use File::Path qw/rmtree/;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 =head1 NAME
11  
12 =head1 VERSION
13  
14 Version 0.03
15  
16 =cut
17  
18 1 our $VERSION = '0.03';
19  
20 =head1 SYNOPSIS
21  
22 =cut
23  
24 =head1 METHODS
25  
26 =head2 new
27  
28 =cut
29  
30 0 ▶sub extract {
Subroutine extract: not called CC=8 SCAR=42.8
Pod undocumented
31 0 my $self = shift;
32 0 my %arguments = @_;
33 0 my $tar = Archive::Tar->new;
34 0 my ($archive_file) = $arguments{archive} =~ /\/?([^\/]+)$/;
35 0 copy($arguments{archive}, $arguments{dir}.$archive_file);
36 0 chdir $arguments{dir};
37 0 ▶ unless ( $tar->read($archive_file) ) { return (0, 'Can not read archive file'.$arguments{archive}) }
Branch: 1 branch
BranchTrueFalseTotal
unless ($tar->read($archive_file)) 0 0 0
38 0 my @files = $tar->extract();
39 0 ▶ return (0, 'Can not extract archive' ) unless @files;
Branch: 1 branch
BranchTrueFalseTotal
unless @files 0 0 0
40 0 ▶ if ($arguments{tree}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($arguments{'tree'}) { } 0 0 0
41 0 unlink $archive_file;
42 0 return (1, 'Extract finished with directory tree');
43 } else {
44 0 foreach my $file (@files) {
45 0 ▶ next if -d $file->full_path;
Branch: 1 branch
BranchTrueFalseTotal
if -d $file->full_path 0 0 0
46 0 my ($filename) = $file->full_path =~ /\/([^\/]+)$/;
47 0 copy($file->full_path, $filename);
48 }
49 0 ▶ foreach my $item (<*>) {if (-d $item) {rmtree($item)}}
Branch: 1 branch
BranchTrueFalseTotal
if (-d $item) 0 0 0
50 0 unlink $archive_file;
51 0 return (1, 'Extract finished without directory tree');
52 }
53 }
54  
55 1 1;
↑ Summary SimpleExtractor/Zip.pm »