File Coverage

blib/lib/Alien/Build/Plugin/Extract/ArchiveZip.pm
Criterion Covered Total %
statement 16 23 69.5
branch 0 2 0.0
condition 3 3 100.0
subroutine 6 8 75.0
pod 3 3 100.0
total 28 39 71.7


line stmt bran cond sub pod time code
1             package Alien::Build::Plugin::Extract::ArchiveZip;
2              
3 5     5   1508 use strict;
  5         15  
  5         189  
4 5     5   27 use warnings;
  5         20  
  5         127  
5 5     5   110 use 5.008004;
  5         27  
6 5     5   404 use Alien::Build::Plugin;
  5         11  
  5         32  
7              
8             # ABSTRACT: Plugin to extract a tarball using Archive::Zip
9             our $VERSION = '2.45'; # VERSION
10              
11              
12             has '+format' => 'zip';
13              
14              
15             sub handles
16             {
17 0     0 1 0 my($class, $ext) = @_;
18              
19 0 0       0 return 1 if $ext eq 'zip';
20              
21 0         0 return 0;
22             }
23              
24              
25             sub available
26             {
27 4     4 1 12815 my(undef, $ext) = @_;
28              
29 4   100     35 !! ( $ext eq 'zip' && eval { require Archive::Zip; 1} );
30             }
31              
32             sub init
33             {
34 1     1 1 6 my($self, $meta) = @_;
35              
36 1         4 $meta->add_requires('share' => 'Archive::Zip' => 0);
37              
38             $meta->register_hook(
39             extract => sub {
40 0     0     my($build, $src) = @_;
41 0           my $zip = Archive::Zip->new;
42 0           $zip->read($src);
43 0           $zip->extractTree;
44             }
45 1         6 );
46             }
47              
48             1;
49              
50             __END__