view release on metacpan or search on metacpan
local/lib/perl5/Module/Build.pm view on Meta::CPAN
This can be a good idea, as it helps prevent multiple versions of a
module from being present on your system, which can be a confusing
situation indeed.
=item installdeps
[version 0.36]
This action will use the C<cpan_client> parameter as a command to install
missing prerequisites. You will be prompted whether to install
optional dependencies.
The C<cpan_client> option defaults to 'cpan' but can be set as an option or in
F<.modulebuildrc>. It must be a shell command that takes a list of modules to
install as arguments (e.g. 'cpanp -i' for CPANPLUS). If the program part is a
relative path (e.g. 'cpan' or 'cpanp'), it will be located relative to the perl
program that executed Build.PL.
/opt/perl/5.8.9/bin/perl Build.PL
./Build installdeps --cpan_client 'cpanp -i'
local/lib/perl5/Module/Build/API.pod view on Meta::CPAN
This method returns a reasonable facsimile of the currently-executing
C<Module::Build> object representing the current build. You can use
this object to query its L</notes()> method, inquire about installed
modules, and so on. This is a great way to share information between
different parts of your build process. For instance, you can ask
the user a question during C<perl Build.PL>, then use their answer
during a regression test:
# In Build.PL:
my $color = $build->prompt("What is your favorite color?");
$build->notes(color => $color);
# In t/colortest.t:
use Module::Build;
my $build = Module::Build->current;
my $color = $build->notes('color');
...
The way the C<current()> method is currently implemented, there may be
slight differences between the C<$build> object in Build.PL and the
local/lib/perl5/Module/Build/API.pod view on Meta::CPAN
[version 0.28]
Returns a human-readable (table-form) string showing all
prerequisites, the versions required, and the versions actually
installed. This can be useful for reviewing the configuration of your
system prior to a build, or when compiling data to send for a bug
report. The C<prereq_report> action is just a thin wrapper around the
C<prereq_report()> method.
=item prompt($message, $default)
[version 0.12]
Asks the user a question and returns their response as a string. The
first argument specifies the message to display to the user (for
example, C<"Where do you keep your money?">). The second argument,
which is optional, specifies a default answer (for example,
C<"wallet">). The user will be asked the question once.
If C<prompt()> detects that it is not running interactively and there
is nothing on STDIN or if the PERL_MM_USE_DEFAULT environment variable
is set to true, the $default will be used without prompting.
To prevent automated processes from blocking, the user must either set
PERL_MM_USE_DEFAULT or attach something to STDIN (this can be a
pipe/file containing a scripted set of answers or /dev/null.)
If no $default is provided an empty string will be used instead. In
non-interactive mode, the absence of $default is an error (though
explicitly passing C<undef()> as the default is valid as of 0.27.)
This method may be called as a class or object method.
local/lib/perl5/Module/Build/API.pod view on Meta::CPAN
derived files, it returns false. Additionally, if any of the derived
files do not exist, it returns false. Otherwise it returns true.
The arguments may be either a scalar or an array reference of file
names.
=item y_n($message, $default)
[version 0.12]
Asks the user a yes/no question using C<prompt()> and returns true or
false accordingly. The user will be asked the question repeatedly
until they give an answer that looks like "yes" or "no".
The first argument specifies the message to display to the user (for
example, C<"Shall I invest your money for you?">), and the second
argument specifies the default answer (for example, C<"y">).
Note that the default is specified as a string like C<"y"> or C<"n">,
and the return value is a Perl boolean value like 1 or 0. I thought
about this for a while and this seemed like the most useful way to do
local/lib/perl5/Module/Build/Base.pm view on Meta::CPAN
sub _readline {
my $self = shift;
return undef if $self->_is_unattended;
my $answer = <STDIN>;
chomp $answer if defined $answer;
return $answer;
}
sub prompt {
my $self = shift;
my $mess = shift
or die "prompt() called without a prompt message";
# use a list to distinguish a default of undef() from no default
my @def;
@def = (shift) if @_;
# use dispdef for output
my @dispdef = scalar(@def) ?
('[', (defined($def[0]) ? $def[0] . ' ' : ''), ']') :
(' ', '');
local $|=1;
local/lib/perl5/Module/Build/Base.pm view on Meta::CPAN
$ans = scalar(@def) ? $def[0] : '';
}
return $ans;
}
sub y_n {
my $self = shift;
my ($mess, $def) = @_;
die "y_n() called without a prompt message" unless $mess;
die "Invalid default value: y_n() default must be 'y' or 'n'"
if $def && $def !~ /^[yn]/i;
my $answer;
while (1) { # XXX Infinite or a large number followed by an exception ?
$answer = $self->prompt(@_);
return 1 if $answer =~ /^y/i;
return 0 if $answer =~ /^n/i;
local $|=1;
print "Please answer 'y' or 'n'.\n";
}
}
sub current_action { shift->{action} }
sub invoked_action { shift->{invoked_action} }
local/lib/perl5/Module/Build/Compat.pm view on Meta::CPAN
Module::Build::Compat->write_makefile(build_class => '%s');
EOF
} elsif ($type eq 'passthrough') {
printf {$fh} <<'EOF', $subclass_load, ref($build), ref($build);
unless (eval "use Module::Build::Compat 0.02; 1" ) {
print "This module requires Module::Build to install itself.\n";
require ExtUtils::MakeMaker;
my $yn = ExtUtils::MakeMaker::prompt
(' Install Module::Build now from CPAN?', 'y');
unless ($yn =~ /^y/i) {
die " *** Cannot install without Module::Build. Exiting ...\n";
}
require Cwd;
require File::Spec;
require CPAN;
local/lib/perl5/Net/SFTP/Foreign.pm view on Meta::CPAN
when running the Cygwin port of Perl.
=item asks_for_username_at_login =E<gt> 0|'auto'|1
During the interactive authentication dialog, most SSH servers only
ask for the user password as the login name is passed inside the SSH
protocol. But under some uncommon servers or configurations it is
possible that a username is also requested.
When this flag is set to C<1>, the username will be send
unconditionally at the first remote prompt and then the password at
the second.
When it is set to C<auto> the module will use some heuristics in order
to determine if it is being asked for an username.
When set to C<0>, the username will never be sent during the
authentication dialog. This is the default.
=item password_prompt => $regex_or_str
The module expects the password prompt from the remote server to end
in a colon or a question mark. This seems to cover correctly 99% of
real life cases.
Otherwise this option can be used to handle the exceptional cases. For
instance:
$sftp = Net::SFTP::Foreign->new($host, password => $password,
password_prompt => qr/\bpassword>\s*$/);
Note that your script will hang at the login phase if the wrong prompt
is used.
=item passphrase =E<gt> $passphrase
Logs into the remote server using a passphrase protected private key.
Requires also the module L<IO::Pty>.
=item expect_log_user =E<gt> $bool
local/lib/perl5/Net/SFTP/Foreign/Backend/Unix.pm view on Meta::CPAN
else {
$sftp->{ssh_in} = $sftp->{ssh_out} = $transport;
$sftp->{_ssh_out_is_not_dupped} = 1;
}
}
else {
my $user = delete $opts->{user};
my $pass = delete $opts->{passphrase};
my $ask_for_username_at_login;
my $pass_is_passphrase;
my $password_prompt;
if (defined $pass) {
$pass_is_passphrase = 1;
}
else {
$pass = delete $opts->{password};
if (defined $pass) {
$sftp->{_password_authentication} = 1;
$password_prompt = $sftp->{_password_prompt} = delete $opts->{password_prompt};
if (defined $password_prompt) {
unless (ref $password_prompt eq 'Regexp') {
$password_prompt = quotemeta $password_prompt;
$password_prompt = qr/$password_prompt\s*$/i;
}
}
$ask_for_username_at_login =
$sftp->{_ask_for_username_at_login} =
( delete($opts->{ask_for_username_at_login}) ||
delete($opts->{asks_for_username_at_login}) );
if ($ask_for_username_at_login) {
croak "ask_for_username_at_login set but user was not given" unless defined $user;
croak "ask_for_username_at_login can not be used with a custom password prompt"
if defined $password_prompt;
}
}
}
delete $opts->{expect_log_user}; # backward compatibility, not used anymore
my $stderr_discard = delete $opts->{stderr_discard};
my $stderr_fh = ($stderr_discard ? undef : delete $opts->{stderr_fh});
my $open2_cmd = delete $opts->{open2_cmd};
my $ssh_cmd_interface = delete $opts->{ssh_cmd_interface};
local/lib/perl5/Net/SFTP/Foreign/Backend/Unix.pm view on Meta::CPAN
$sftp->_conn_failed("the authenticity of the target host can't be established, " .
"the remote host public key is probably not present on the " .
"'~/.ssh/known_hosts' file");
return;
}
if ($password_sent) {
$debug and $debug & 65536 and _debug "looking for password ok";
last if substr($buffer, $at) =~ /\n$/;
}
else {
$debug and $debug & 65536 and _debug "looking for user/password prompt";
my $re = ( defined $password_prompt
? $password_prompt
: qr/(user|name|login)?[:?]\s*$/i );
$debug and $debug & 65536 and _debug "matching against $re";
if (substr($buffer, $at) =~ $re) {
if ($ask_for_username_at_login and
($ask_for_username_at_login ne 'auto' or defined $1)) {
$debug and $debug & 65536 and _debug "sending username";
print $pty "$user\n";
undef $ask_for_username_at_login;
local/lib/perl5/Test/Spec/Mocks.pm view on Meta::CPAN
Depending on context, these can refer to stubbed objects and methods, or
mocked objects and methods, respectively.
=back
=head2 Using stub objects (anonymous stubs)
Sometimes the code you're testing requires that you pass it an object that
conforms to a specific interface. For example, you are testing a console
prompting library, but you don't want to require a real person to stand by,
waiting to type answers into the console. The library requires an object
that returns a string when the C<read_line> method is called.
You could create a class specifically for returning test console input. But
why do that? You can create a stub object in one line:
describe "An Asker" => sub {
my $asker = Asker->new;
it "returns true when a yes_or_no question is answered 'yes'" => sub {