| 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
| |||||||||||
| 24 | 0 | path($self->workdir)->mkpath; | |||||||||
| 25 | } | ||||||||||
| 26 | |||||||||||
| 27 | 0 | my $archive; | |||||||||
| 28 | |||||||||||
| 29 | 0 | ▶ | if ( ! defined $self->distfile ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 30 | 0 | return 1; | |||||||||
| 31 | } | ||||||||||
| 32 | |||||||||||
| 33 | 0 | ▶ | if ( $self->distfile =~ /\.(tar|tgz|gz|Z|zip|bz2|tbz|lzma|xz|tx)$/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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 | ||||||||||