Alien-Selenium
view release on metacpan or search on metacpan
inc/My/Module/Build.pm view on Meta::CPAN
=item I<full_debugging=1>
Sets the FULL_DEBUGGING environment variable to 1 while running
C<./Build test>, in addition to any environment customization already
performed by L</customize_env>. Packages of mine that use L<Inline>
enable extra debugging when this environment variable is set.
=back
=head3 Dependent Option Graph
This feature wraps around L<Module::Build/prompt>,
L<Module::Build/get_options> and L<Module::Build/notes> to streamline
the programming of optional features into a ./Build.PL script. Here is
a short synopsis for this feature:
=for My::Tests::Below "option-graph" begin
my $class = My::Module::Build->subclass(code => <<'CODE');
sub install_everything: Config_Option {
question => "Install everything",
default => 1;
}
sub install_module_foo: Config_Option(type="boolean") {
my $build = shift;
return (default => 1) # Don't even bother asking the question
if $build->option_value("install_everything");
question => "Install module foo",
default => 0;
}
CODE
my $builder = $class->new(...) # See SYNOPSIS
=for My::Tests::Below "option-graph" end
Options can then be fed from the command line (e.g. C<< ./Build.PL
--gender=f >>) or by answering the questions interactively on the
terminal. I<My::Module::Build> will ask the questions at L</new>
time, in the correct order if they depend on each other (as shown in
the example), detect circular dependencies, and die if a mandatory
question does not get an appropriate answer.
=head3 Syntax
As shown above, options are methods in a subclass to
I<My::Module::Build> with a subroutine attribute of the form C<<
Config_Option(key1=value1, ...) >>. Right now the
following keys are defined:
=over
=item I<type>
The datatype of this option, either as a word (e.g. "boolean", "integer" or
"string") or as a L<GetOpt::Long> qualifier (e.g. "!", "=s" or "=i").
The default is to guess from the name of the option: "install_foo" and
"enable_bar" are supposed to be booleans, "baz_port" an integer, and
everything else a string.
=back
The name of the method is the internal key for the corresponding
option (e.g. for L</option_value>). It is also the name of the
corresponding command-line switch, except that all underscores are
converted to dashes.
The method shall return a (key, value) "flat hash" with the following
keys recognized:
=over
=item I<question>
The question to ask, as text. A question mark is appended
automatically for convenience if there isn't already one. If no
question is set, I<My::Module::Build> will not ask anything for this
question even in interactive mode, and will attempt to use the default
value instead (see below).
=item I<default>
In batch mode, the value to use if none is available from the command
line or the persisted answer set from previous attempts to run
./Build.PL. In interactive mode, the value to offer to the user as the
default.
=item I<mandatory>
A Boolean indicating whether answering the question with a non-empty
value is mandatory (see also L</prompt> for a twist on what
"non-empty" exactly means). The default mandatoryness is 1 if
I<default> is not returned, 0 if I<default> is returned (even with an
undef value).
=back
=head1 REFERENCE
=cut
package My::Module::Build;
use strict;
use warnings;
use base "Module::Build";
use IO::File;
use File::Path qw(mkpath);
use File::Spec::Functions qw(catfile catdir splitpath splitdir);
use File::Basename qw(dirname);
use File::Spec::Unix ();
use File::Find;
=begin internals
=head2 Global variables
=head3 $running_under_emacs_debugger
Set by L</_massage_ARGV> if (you guessed it) we are currently running
under the Emacs debugger.
=cut
our $running_under_emacs_debugger;
=head2 Constants
=head3 is_win32
Your usual bugware-enabling OS checks.
=cut
use constant is_win32 => scalar($^O =~ /^(MS)?Win32$/);
=head2 read_file($file)
=head2 write_file($file, @lines)
Like in L<File::Slurp>.
=cut
sub read_file {
my ($filename) = @_;
defined(my $file = IO::File->new($filename, "<")) or die <<"MESSAGE";
Cannot open $filename for reading: $!.
MESSAGE
return wantarray? <$file> : join("", <$file>);
}
sub write_file {
my ($filename, @contents) = @_;
defined(my $file = IO::File->new($filename, ">")) or die <<"MESSAGE";
Cannot open $filename for writing: $!.
MESSAGE
($file->print(join("", @contents)) and $file->close()) or die <<"MESSAGE";
Cannot write into $filename: $!.
MESSAGE
}
=end internals
=head2 Constructors and Class Methods
These are intended to be called directly from Build.PL
=over
=item I<new(%named_options)>
Overloaded from parent class in order to call
L</check_maintainer_dependencies> if L</maintainer_mode_enabled> is
true. Also sets the C<recursive_test_files> property to true by
default (see L<Module::Build/test_files>), since I like to store
maintainer-only tests in C<t/maintainer> (as documented in
L</find_test_files>).
In addition to the %named_options documented in L<Module::Build/new>,
( run in 0.405 second using v1.01-cache-2.11-cpan-efa8479b9fe )