File Coverage

blib/lib/Alien/Build/Plugin/Extract/Directory.pm
Criterion Covered Total %
statement 29 29 100.0
branch 5 6 83.3
condition n/a
subroutine 10 10 100.0
pod 3 3 100.0
total 47 48 97.9


line stmt bran cond sub pod time code
1             package Alien::Build::Plugin::Extract::Directory;
2              
3 5     5   1246 use strict;
  5         17  
  5         160  
4 5     5   28 use warnings;
  5         9  
  5         122  
5 5     5   99 use 5.008004;
  5         19  
6 5     5   364 use Alien::Build::Plugin;
  5         11  
  5         34  
7 5     5   33 use Alien::Build::Util qw( _mirror );
  5         19  
  5         270  
8 5     5   41 use Path::Tiny ();
  5         12  
  5         1416  
9              
10             # ABSTRACT: Plugin to extract a downloaded directory to a build directory
11             our $VERSION = '2.45'; # VERSION
12              
13              
14             has '+format' => 'd';
15              
16              
17             sub handles
18             {
19 4     4 1 5754 my(undef, $ext) = @_;
20 4 100       25 $ext eq 'd' ? 1 : ();
21             }
22              
23              
24             sub available
25             {
26 2     2 1 2076 my(undef, $ext) = @_;
27 2         6 __PACKAGE__->handles($ext);
28             }
29              
30             sub init
31             {
32 2     2 1 9 my($self, $meta) = @_;
33              
34             $meta->register_hook(
35             extract => sub {
36 2     2   6 my($build, $src) = @_;
37              
38 2 50       236 die "not a directory: $src" unless -d $src;
39              
40 2 100       16 if($build->meta_prop->{out_of_source})
41             {
42 1         4 $build->install_prop->{extract} = Path::Tiny->new($src)->absolute->stringify;
43             }
44             else
45             {
46 1         5 my $dst = Path::Tiny->new('.')->absolute;
47             # Please note: _mirror and Alien::Build::Util are ONLY
48             # allowed to be used by core plugins. If you are writing
49             # a non-core plugin it may be removed. That is why it
50             # is private.
51 1         95 _mirror $src => $dst, { verbose => 1 };
52             }
53             }
54 2         14 );
55             }
56              
57             1;
58              
59             __END__