blib/lib/OS/Package/Artifact/Role/Extract.pm

filter: Statementstmt 65.9% 29 / 44 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.0% 9 / 10 Podpod 100% 1 / 1 totaltotal 63.9% 39 / 61 SCAR 16.5
CC
4
Cov
58%
extract
20.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.2
« blib/lib/OS/Package/Maintainer.pm ↑ Summary blib/lib/OS/Package/Init.pm »
1 3 ▶use v5.14.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package OS::Package::Artifact::Role::Extract;
5  
6 3 ▶use Archive::Extract;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use File::Copy;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use File::Path qw( make_path remove_tree );
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Path::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use OS::Package::Config;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use OS::Package::Log;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use Role::Tiny;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 # ABSTRACT: Provides the extract method for Artifact role.
15 3 our $VERSION = '0.2.6'; # VERSION
16  
17 3 local $Archive::Extract::PREFER_BIN = 1;
18  
19 sub extract {
20  
21 0 ▶ my $self = shift;
Subroutine extract: not called CC=4 SCAR=30.0
Pod documented
22  
23 0 ▶ if ( ! path($self->workdir)->exists ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (path($self->workdir)->exists) 0 0 0
24 0 path($self->workdir)->mkpath;
25 }
26  
27 0 my $archive;
28  
29 0 ▶ if ( ! defined $self->distfile ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->distfile) 0 0 0
30 0 return 1;
31 }
32  
33 0 ▶ if ( $self->distfile =~ /\.(tar|tgz|gz|Z|zip|bz2|tbz|lzma|xz|tx)$/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->distfile =~ /\.(tar|tgz|gz|Z|zip|bz2|tbz|lzma|xz|tx)$/u) { } 0 0 0
34  
35 0 $archive = Archive::Extract->new( archive => $self->savefile );
36 0 $LOGGER->info( sprintf 'extracting archive: %s', $self->distfile );
37  
38 0 $archive->extract( to => $self->workdir );
39  
40 0 $self->archive($archive);
41  
42 0 $LOGGER->info( sprintf 'extracted archive: %s',
43 $self->archive->extract_path );
44 }
45 else {
46  
47 0 $LOGGER->info( sprintf 'staging distfile to workdir: %s',
48 $self->distfile );
49  
50 0 copy( $self->savefile,
51 sprintf( '%s/%s', $self->workdir, $self->distfile ) );
52 }
53  
54 0 return 1;
55  
56 }
57  
58 3 1;
59  
60 __END__
61  
62 =pod
63  
64 =encoding UTF-8
65  
66 =head1 NAME
67  
68 OS::Package::Artifact::Role::Extract - Provides the extract method for Artifact role.
69  
70 =head1 VERSION
71  
72 version 0.2.6
73  
74 =head1 METHODS
75  
76 =head2 extract
77  
78 =head1 AUTHOR
79  
80 James F Wilkus <jfwilkus@cpan.org>
81  
82 =head1 COPYRIGHT AND LICENSE
83  
84 This software is Copyright (c) 2014 by James F Wilkus.
85  
86 This is free software, licensed under:
87  
88 The (three-clause) BSD License
89  
90 =cut
« blib/lib/OS/Package/Maintainer.pm ↑ Summary blib/lib/OS/Package/Init.pm »