File Coverage

blib/lib/Alien/Build/Plugin/Fetch/PromptBeforeDownload.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::PromptBeforeDownload;
2              
3 2     2   382524 use strict;
  2         10  
  2         85  
4 2     2   18 use warnings;
  2         5  
  2         78  
5 2     2   1025 use Alien::Build::Plugin;
  2         5333  
  2         21  
6              
7             # ABSTRACT: Alien::Build plugin to prompt a user before making external download
8             our $VERSION = '0.57'; # VERSION
9              
10              
11             sub init
12             {
13 1     1 1 47161 my($self, $meta) = @_;
14              
15 1         9 $meta->add_requires('share' => 'ExtUtils::MakeMaker' => 0 );
16              
17             $meta->before_hook(
18             fetch => sub {
19 4     4   24897 my($build, $url) = @_;
20 4   66     33 $url ||= $build->meta_prop->{plugin_download_negotiate_default_url};
21 4   100     88 my $value = ExtUtils::MakeMaker::prompt("Downloading $url, is that okay?", $ENV{ALIEN_DOWNLOAD} || 'yes');
22 4 100       68 unless($value =~ /^(y|yes)$/i)
23             {
24 1         17 $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         175 exit 2;
27             }
28             }
29 1         33 );
30             }
31              
32             1;
33              
34             __END__