Enbld/Archivefile.pm

filter: Statementstmt 90.6% 29 / 32 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 0.0% 0 / 2 totaltotal 79.5% 39 / 49 SCAR 16.4
CC
5
Cov
82%
extract
5.2
_err
2.0
BEGIN
1.0
CRAP 5.1
« Enbld/Target/Attribute/CopyFiles.pm ↑ Summary Enbld/HTML.pm »
1 package Enbld::Archivefile;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use Archive::Tar;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 sub new {
10 30 ▶ my ( $class, $path ) = @_;
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
11  
12 30 my $self = {
13 archivefile => $path,
14 };
15  
16 30 return bless $self, $class;
17 }
18  
19 2 require Enbld::Error;
20  
21 sub extract {
22 30 ▶ my ( $self, $dir ) = @_;
Subroutine extract: called CC=5 SCAR=16.5
Pod undocumented
23  
24 30 my ( undef, undef, $file ) = File::Spec->splitpath( $self->{archivefile} );
25  
26 30 require Enbld::Message;
27 30 Enbld::Message->notify( "--> Extract archive file '$file'." );
28  
29 30 my $tar = Archive::Tar->new;
30 30 ▶ $tar->read( $self->{archivefile} ) or
Branch: 1 branch
BranchTrueFalseTotal
$tar->read($self->{"archivefile"}) or _err("Can't read archive file.", $tar->error) 0 30 30
31 _err( "Can't read archive file.", $tar->error );
32  
33 30 ▶ my @list = $tar->list_files or _err( "Can't list up file.", $tar->error );
Branch: 1 branch
BranchTrueFalseTotal
my(@list) = $tar->list_files or _err("Can't list up file.", $tar->error) 0 30 30
34  
35 30 my @frag = split( '/', $list[0] );
36  
37 30 my $path = File::Spec->catdir( $dir, $frag[0] );
38 30 ▶ $tar->setcwd( $dir ) or _err( "Can't move to cwd dir.", $tar->error );
Branch: 1 branch
BranchTrueFalseTotal
$tar->setcwd($dir) or _err("Can't move to cwd dir.", $tar->error) 0 30 30
39 30 ▶ $tar->extract or _err( "Can't extract archive file.", $tar->error );
Branch: 1 branch
BranchTrueFalseTotal
$tar->extract or _err("Can't extract archive file.", $tar->error) 0 30 30
40  
41 30 return $path;
42 }
43  
44 sub _err {
45 0 ▶ my ( $err, $msg ) = @_;
Subroutine _err: not called CC=1 SCAR=6.9
46  
47 0 require Enbld::Error;
48 0 die( Enbld::Error->new( $err, $msg ) );
49 }
50  
51 2 1;
« Enbld/Target/Attribute/CopyFiles.pm ↑ Summary Enbld/HTML.pm »