File Coverage

blib/lib/Alien/Build/Plugin/Core/CleanInstall.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 4 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Alien::Build::Plugin::Core::CleanInstall;
2              
3 47     47   183576 use strict;
  47         115  
  47         1253  
4 47     47   209 use warnings;
  47         89  
  47         926  
5 47     47   679 use 5.008004;
  47         147  
6 47     47   594 use Alien::Build::Plugin;
  47         109  
  47         372  
7 47     47   978 use Path::Tiny ();
  47         9776  
  47         8517  
8              
9             # ABSTRACT: Implementation for clean_install hook.
10             our $VERSION = '2.47'; # VERSION
11              
12              
13             sub init
14             {
15 337     337 1 806 my($self, $meta) = @_;
16              
17             $meta->default_hook(
18             clean_install => sub {
19 2     2   14 my($build) = @_;
20             my $root = Path::Tiny->new(
21             $build->runtime_prop->{prefix}
22 2         8 );
23 2 100       60 if(-d $root)
24             {
25 1         26 foreach my $child ($root->children)
26             {
27 5 100       1234 if($child->basename eq '_alien')
28             {
29 1         27 $build->log("keeping $child");
30             }
31             else
32             {
33 4         105 $build->log("removing $child");
34 4         27 $child->remove_tree({ safe => 0});
35             }
36             }
37             }
38             }
39 337         2012 );
40             }
41              
42             1;
43              
44             __END__