File Coverage

blib/lib/Alien/Build/Plugin/Fetch/Prompt.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition 4 5 80.0
subroutine 5 5 100.0
pod 1 1 100.0
total 30 31 96.7


line stmt bran cond sub pod time code
1             package Alien::Build::Plugin::Fetch::Prompt;
2              
3 2     2   274564 use strict;
  2         5  
  2         51  
4 2     2   10 use warnings;
  2         3  
  2         100  
5 2     2   462 use Alien::Build::Plugin;
  2         3880  
  2         14  
6              
7             # ABSTRACT: Alien::Build plugin to prompt a user before making external download
8             our $VERSION = '0.59'; # VERSION
9              
10              
11             sub init
12             {
13 1     1 1 33472 my($self, $meta) = @_;
14              
15 1         8 $meta->add_requires('share' => 'ExtUtils::MakeMaker' => 0 );
16              
17             $meta->before_hook(
18             fetch => sub {
19 4     4   14171 my($build, $url) = @_;
20 4   66     24 $url ||= $build->meta_prop->{plugin_download_negotiate_default_url};
21 4   100     55 my $value = ExtUtils::MakeMaker::prompt("Downloading $url, is that okay?", $ENV{ALIEN_DOWNLOAD} || 'yes');
22 4 100       45 unless($value =~ /^(y|yes)$/i)
23             {
24 1         15 $build->log("User refussed to download $url");
25             # Do a hard exit. If the user insists, there isn't a way to recover really.
26 1         64 exit 2;
27             }
28             }
29 1         39 );
30             }
31              
32             1;
33              
34             __END__