Alien-Build-Plugin-Fetch-PromptBeforeDownload
view release on metacpan or search on metacpan
META.yml
Makefile.PL
README
author.yml
cpanfile
dist.ini
lib/Alien/Build/Plugin/Fetch/PromptBeforeDownload.pm
maint/travis-install-alienbuild
t/00_diag.t
t/01_use.t
t/alien_build_plugin_fetch_promptbeforedownload.t
xt/author/eol.t
xt/author/no_tabs.t
xt/author/pod.t
xt/author/pod_coverage.t
xt/author/pod_spelling_common.t
xt/author/pod_spelling_system.t
xt/author/strict.t
xt/author/version.t
xt/release/changes.t
xt/release/fixme.t
{
"abstract" : "Alien::Build plugin to prompt a user before making external download",
"author" : [
"Graham Ollis <plicease@cpan.org>"
],
"dynamic_config" : 0,
"generated_by" : "Dist::Zilla version 6.010, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
---
abstract: 'Alien::Build plugin to prompt a user before making external download'
author:
- 'Graham Ollis <plicease@cpan.org>'
build_requires:
ExtUtils::MakeMaker: '0'
Test2::Mock: '0.000060'
Test2::V0: '0.000060'
Test::Alien::Build: '0'
Test::Exit: '0.11'
perl: '5.006'
configure_requires:
Makefile.PL view on Meta::CPAN
}
# This file was automatically generated by Dist::Zilla::Plugin::Author::Plicease::MakeMaker v2.20.
use strict;
use warnings;
use 5.006;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
"ABSTRACT" => "Alien::Build plugin to prompt a user before making external download",
"AUTHOR" => "Graham Ollis <plicease\@cpan.org>",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "Alien-Build-Plugin-Fetch-PromptBeforeDownload",
"LICENSE" => "perl",
"MIN_PERL_VERSION" => "5.006",
"NAME" => "Alien::Build::Plugin::Fetch::PromptBeforeDownload",
"PM" => {
"lib/Alien/Build/Plugin/Fetch/PromptBeforeDownload.pm" => "\$(INST_LIB)/Alien/Build/Plugin/Fetch/PromptBeforeDownload.pm"
NAME
Alien::Build::Plugin::Fetch::PromptBeforeDownload - Alien::Build plugin
to prompt a user before making external download
VERSION
version 0.57
SYNOPSIS
export ALIEN_BUILD_PRELOAD=Fetch::PromptBeforeDownload
DESCRIPTION
This plugin allows you to force Alien::Build to prompt the user and ask
for permission before downloading anything from the internet. It uses
the ExtUtils::MakeMaker prompt function, so that it will do the
sensible thing, like not infinitely halt install on non-interactive
installs. The default response is yes, which is usually reasonable (and
the default if you do not use this plugin at all), but you may change
this by using the ALIEN_DOWNLOAD environment variable (see below).
ENVIRONMENT
ALIEN_DOWNLOAD
Set this environment variable to the default response. Should be either
lib/Alien/Build/Plugin/Fetch/PromptBeforeDownload.pm view on Meta::CPAN
package Alien::Build::Plugin::Fetch::PromptBeforeDownload;
use strict;
use warnings;
use Alien::Build::Plugin;
# ABSTRACT: Alien::Build plugin to prompt a user before making external download
our $VERSION = '0.57'; # VERSION
sub init
{
my($self, $meta) = @_;
$meta->add_requires('share' => 'ExtUtils::MakeMaker' => 0 );
$meta->before_hook(
fetch => sub {
my($build, $url) = @_;
$url ||= $build->meta_prop->{plugin_download_negotiate_default_url};
my $value = ExtUtils::MakeMaker::prompt("Downloading $url, is that okay?", $ENV{ALIEN_DOWNLOAD} || 'yes');
unless($value =~ /^(y|yes)$/i)
{
$build->log("User refussed to download $url");
# Do a hard exit. If the user insists, there isn't a way to recover really.
exit 2;
}
}
);
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Alien::Build::Plugin::Fetch::PromptBeforeDownload - Alien::Build plugin to prompt a user before making external download
=head1 VERSION
version 0.57
=head1 SYNOPSIS
export ALIEN_BUILD_PRELOAD=Fetch::PromptBeforeDownload
=head1 DESCRIPTION
This plugin allows you to force L<Alien::Build> to prompt the user and ask for permission
before downloading anything from the internet. It uses the L<ExtUtils::MakeMaker> C<prompt>
function, so that it will do the sensible thing, like not infinitely halt install on
non-interactive installs. The default response is C<yes>, which is usually reasonable
(and the default if you do not use this plugin at all), but you may change this by using
the C<ALIEN_DOWNLOAD> environment variable (see below).
=head1 ENVIRONMENT
=head2 ALIEN_DOWNLOAD
Set this environment variable to the default response. Should be either C<yes> or C<no>.
t/alien_build_plugin_fetch_promptbeforedownload.t view on Meta::CPAN
};
my $mock = Test2::Mock->new(
class => 'ExtUtils::MakeMaker',
);
subtest 'user says yes' => sub {
my($msg, $def);
$mock->override(prompt => sub ($;$) { ($msg,$def) = @_; return 'y' });
subtest 'default url' => sub {
never_exits_ok {
$build->fetch;
};
like $msg, qr{http://alienfile.org/foo/bar/baz};
note "msg = $msg";
t/alien_build_plugin_fetch_promptbeforedownload.t view on Meta::CPAN
};
is $def, 'no';
};
};
subtest 'user says no' => sub {
$mock->override(prompt => sub ($;$) { 'n' });
is exit_code { $build->fetch }, 2;
};
done_testing;
( run in 1.048 second using v1.01-cache-2.11-cpan-0b5f733616e )