Module-Starter-1.73/0000755000175000017500000000000013143242255013714 5ustar grinnzgrinnzModule-Starter-1.73/README0000644000175000017500000000126613064625343014606 0ustar grinnzgrinnzNAME
Module::Starter - a simple starter kit for any module
Module::Starter is used to create a skeletal CPAN distribution,
including basic builder scripts, tests, documentation, and module code.
For more information, refer to the documentation for module-starter,
Module::Starter, and Module::Starter::Simple.
AUTHORS
Andy Lester, ""
Ricardo Signes, ""
C.J. Adams-Collier, ""
COPYRIGHT
Copyright 2004-7 Andy Lester, Ricardo Signes, C.J. Adams-Collier,
All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Module-Starter-1.73/bin/0000755000175000017500000000000013143242255014464 5ustar grinnzgrinnzModule-Starter-1.73/bin/module-starter0000755000175000017500000000632113064625343017370 0ustar grinnzgrinnz#!/usr/bin/perl -w
=head1 NAME
module-starter - creates a skeleton module distribution
=cut
use warnings;
use strict;
use Module::Starter::App;
Module::Starter::App->run;
=head1 SYNOPSIS
module-starter [options]
Options:
--module=module Module name (required, repeatable)
--distro=name Distribution name (optional)
--dir=dirname Directory name to create new module in (optional)
--builder=module Build with 'ExtUtils::MakeMaker' or 'Module::Build'
--eumm Same as --builder=ExtUtils::MakeMaker
--mb Same as --builder=Module::Build
--mi Same as --builder=Module::Install
--author=name Author's name (taken from getpwuid if not provided)
--email=email Author's email (taken from EMAIL if not provided)
--ignores=type Ignore type files to include (repeatable)
--license=type License under which the module will be distributed
(default is artistic2)
--minperl=ver Minimum Perl version required (optional;
default is 5.006)
--fatalize Generate code that causes all warnings to be fatal with:
use warnings FATAL => 'all'
--verbose Print progress messages while working
--force Delete pre-existing files if needed
--help Show this message
Available Licenses:
perl, artistic, artistic2, mit, mozilla, mozilla2, bsd, freebsd, cc0,
gpl, lgpl, gpl3, lgpl3, agpl3, apache, qpl
Available Ignore Types:
cvs, git, hg, manifest, generic
(NOTE: If manifest is included, the MANIFEST file will be skipped
and only a MANIFEST.SKIP file will be included.)
Example:
module-starter --module=Foo::Bar,Foo::Bat \
--author="Andy Lester" --email=andy@petdance.com
=head1 DESCRIPTION
C is a command-line interface to L, which it
uses to perform all the work of creating distributions. An alternate backend
for C can be specified with the C<--class> option. Plugins to
the standard Module::Starter module can be specified with one or more
C<--plugin> options.
If no directory name is supplied, the distribution name will be used for the
directory. If no distribution name is supplied, the first listed module name
will be used as the distribution name.
Multiple --builder options may be supplied to produce the files for multiple
builders.
=head1 CONFIGURATION
module-starter will look for a configuration file before reading its command
line parameters. The default location is C<$HOME/.module-starter/config> but
if the MODULE_STARTER_DIR environment variable is set, module-starter will look
for C in that directory.
The configuration file is just a list of names and values, separated by
colons. Values that take lists are just space separated. Note that the
C<--ignores> command line parameter corresponds to the C
configuration file entry. A sample configuration file might read:
author: Ricardo SIGNES
email: rjbs@cpan.org
ignores_type: git
plugins: Module::Starter::Simple Module::Starter::Plugin::XYZ
xyz_option: red green blue
This format may become more elaborate in the future, but a file of this type
should remain valid.
=cut
Module-Starter-1.73/MANIFEST0000644000175000017500000000145713143242255015054 0ustar grinnzgrinnzbin/module-starter
Changes
getting-started.html
lib/Module/Starter.pm
lib/Module/Starter/App.pm
lib/Module/Starter/BuilderSet.pm
lib/Module/Starter/Plugin.pod
lib/Module/Starter/Plugin/Template.pm
lib/Module/Starter/Simple.pm
LICENSE
Makefile.PL
MANIFEST
perlcriticrc
README
t/00-load.t
t/BuilderSet.t
t/data/templates/Build.PL
t/data/templates/Changes
t/data/templates/Makefile.PL
t/data/templates/Module.pm
t/data/templates/README
t/data/templates/t/00-load.t
t/data/templates/t/boilerplate.t
t/data/templates/t/pod-coverage.t
t/data/templates/t/pod.t
t/lib/Module/Starter/TestPlugin.pm
t/module-starter.t
t/pod-coverage.t
t/pod.t
t/test-dist.t
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
Module-Starter-1.73/lib/0000755000175000017500000000000013143242255014462 5ustar grinnzgrinnzModule-Starter-1.73/lib/Module/0000755000175000017500000000000013143242255015707 5ustar grinnzgrinnzModule-Starter-1.73/lib/Module/Starter.pm0000644000175000017500000001147313143167764017712 0ustar grinnzgrinnzpackage Module::Starter;
use warnings;
use strict;
use Carp qw( croak );
use Module::Runtime qw( require_module );
=head1 NAME
Module::Starter - a simple starter kit for any module
=head1 VERSION
Version 1.73
=cut
our $VERSION = '1.73';
=head1 SYNOPSIS
Nothing in here is meant for public consumption. Use F
from the command line.
module-starter --module=Foo::Bar,Foo::Bat \
--author="Andy Lester" --email=andy@petdance.com
=head1 DESCRIPTION
This is the core module for Module::Starter. If you're not looking to extend
or alter the behavior of this module, you probably want to look at
L instead.
Module::Starter is used to create a skeletal CPAN distribution, including basic
builder scripts, tests, documentation, and module code. This is done through
just one method, C.
=head1 METHODS
=head2 Module::Starter->create_distro(%args)
C is the only method you should need to use from outside this
module; all the other methods are called internally by this one.
This method creates orchestrates all the work; it creates distribution and
populates it with the all the requires files.
It takes a hash of params, as follows:
distro => $distroname, # distribution name (defaults to first module)
modules => [ module names ], # modules to create in distro
dir => $dirname, # directory in which to build distro
builder => 'Module::Build', # defaults to ExtUtils::MakeMaker
# or specify more than one builder in an
# arrayref
license => $license, # type of license; defaults to 'artistic2'
author => $author, # author's full name (taken from C if not provided)
email => $email, # author's email address (taken from C if not provided)
ignores_type => $type, # ignores file type ('generic', 'cvs', 'git', 'hg', 'manifest' )
fatalize => $fatalize, # generate code that makes warnings fatal
verbose => $verbose, # bool: print progress messages; defaults to 0
force => $force # bool: overwrite existing files; defaults to 0
The ignores_type is a new feature that allows one to create SCM-specific ignore files.
These are the mappings:
ignores_type => 'generic' # default, creates 'ignore.txt'
ignores_type => 'cvs' # creates .cvsignore
ignores_type => 'git' # creates .gitignore
ignores_type => 'hg' # creates .hgignore
ignores_type => 'manifest' # creates MANIFEST.SKIP
It is also possible to provide an array ref with multiple types wanted:
ignores_type => [ 'git', 'manifest' ]
=head1 PLUGINS
Module::Starter itself doesn't actually do anything. It must load plugins that
implement C and other methods. This is done by the class's C
routine, which accepts a list of plugins to be loaded, in order.
For more information, refer to L.
=cut
sub import {
my $class = shift;
my @plugins = ((@_ ? @_ : 'Module::Starter::Simple'), $class);
my $parent;
while (my $child = shift @plugins) {
require_module $child;
## no critic
no strict 'refs'; #Violates ProhibitNoStrict
push @{"${child}::ISA"}, $parent if $parent;
use strict 'refs';
## use critic
if ( @plugins && $child->can('load_plugins') ) {
$parent->load_plugins(@plugins);
last;
}
$parent = $child;
}
return;
}
=head1 AUTHORS
Sawyer X, C<< >>
Andy Lester, C<< >>
Ricardo Signes, C<< >>
C.J. Adams-Collier, C<< >>
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Module::Starter
You can also look for information at:
=over 4
=item * Source code at GitHub
L
=item * AnnoCPAN: Annotated CPAN documentation
L
=item * CPAN Ratings
L
=item * GitHub issue tracker
L
=item * Metacpan
L
=back
=head1 BUGS
Please report any bugs or feature requests to the bugtracker for this project
on GitHub at: L. I will be
notified, and then you'll automatically be notified of progress on your bug
as I make changes.
=head1 COPYRIGHT
Copyright 2005-2009 Andy Lester, Ricardo Signes and C.J. Adams-Collier,
All Rights Reserved.
Copyright 2010 Sawyer X, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
1;
# vi:et:sw=4 ts=4
Module-Starter-1.73/lib/Module/Starter/0000755000175000017500000000000013143242255017333 5ustar grinnzgrinnzModule-Starter-1.73/lib/Module/Starter/BuilderSet.pm0000644000175000017500000001673313143171066021746 0ustar grinnzgrinnzpackage Module::Starter::BuilderSet;
use strict;
use warnings;
use Carp qw( carp );
=head1 NAME
Module::Starter::BuilderSet - determine builder metadata
=head1 VERSION
Version 1.73
=cut
our $VERSION = '1.73';
=head1 SYNOPSIS
use Module::Starter::BuilderSet;
my $builder_set = Module::Starter::BuilderSet->new;
my @supported_builders = $builder_set->supported_builders();
my $default_builder = $builder_set->default_builder();
my $output_file = $builder_set->file_for_builder($default_builder);
my $create_method = $builder_set->method_for_builder($default_builder);
Module::Starter::Simple->$create_method($default_builder); # eeew.
my @build_commands = $builder_set->instructions_for_builder($default_builder);
my @builder_dependencies = $builder_set->deps_for_builder($default_builder);
my @compatible_builders = $builder_set->check_compatibility(@builder_list);
my $ms_simple = Module::Starter::Simple->new();
my $build_method = $builder_set->manifest_method($builder);
$ms_simple->$build_method();
=head1 DESCRIPTION
Module::Starter::BuilderSet is a collection of utility methods used to
provide metadata about builders supported by Module::Starter.
=head1 CLASS METHODS
=head2 C<< new() >>
This method initializes and returns an object representing the set of
Builders supported by Module::Starter
=cut
sub new {
my $class = shift;
my $self =
{
'Module::Build' =>
{
file => "Build.PL",
build_method => "create_Build_PL",
build_deps => [],
build_manifest => 'create_MB_MANIFEST',
instructions => [ 'perl Build.PL',
'./Build',
'./Build test',
'./Build install',
],
},
'Module::Install' =>
{
file => "Makefile.PL",
build_method => "create_MI_Makefile_PL",
build_deps => [],
build_manifest => 'create_MI_MANIFEST',
instructions => [ 'perl Makefile.PL',
'make',
'make test',
'make install',
],
},
'ExtUtils::MakeMaker' =>
{
file => "Makefile.PL",
build_method => "create_Makefile_PL",
build_manifest => 'create_EUMM_MANIFEST',
build_deps => [ { command => 'make',
aliases => [ 'make', 'gmake' ],
},
{ command => 'chmod',
aliases => [ 'chmod' ],
},
],
instructions => [ 'perl Makefile.PL',
'make',
'make test',
'make install',
],
}
};
return bless $self, $class;
}
sub _builder {
my $self = shift;
my $builder = shift;
$builder = $self->default_builder unless $builder;
unless (exists $self->{$builder}) {
carp("Don't know anything about builder '$builder'.");
return undef;
}
return $self->{$builder};
}
=head2 C<< supported_builders() >>
This method returns a list of builders supported by Module::Starter
=cut
sub supported_builders {
my $self = shift;
return keys %$self;
}
=head2 C<< file_for_builder($builder) >>
This method returns the name of the file generated by Module::Starter
that will be used to build the generated module
=cut
sub file_for_builder {
my $self = shift;
my $builder = shift;
return $self->_builder($builder)->{file};
}
=head2 C<< method_for_builder($builder) >>
This method returns the name of the method in the
C package that is called to create the file
returned by C
=cut
sub method_for_builder {
my $self = shift;
my $builder = shift;
return $self->_builder($builder)->{build_method};
}
=head2 C<< instructions_for_builder($builder) >>
This method returns a list of commands that, when run from the command
line (or with C), will cause the generated module to be
built, tested and installed.
=cut
sub instructions_for_builder {
my $self = shift;
my $builder = shift;
return @{ $self->_builder($builder)->{instructions} };
}
=head2 C<< deps_for_builder($builder) >>
This method returns a list of dependencies in the following format:
C<<
( { command => "make",
aliases => [ 'make', 'gmake' ],
},
{ command => "another_command",
aliases => [ 'alias0', 'alias1', '...' ],
},
)
>>
=cut
sub deps_for_builder {
my $self = shift;
my $builder = shift;
return @{ $self->_builder($builder)->{build_deps} };
}
=head2 C<< manifest_method($builder) >>
This method returns the command to run to create the manifest according to the
builder asked.
=cut
sub manifest_method {
my ( $self, $builder ) = @_;
return $self->_builder($builder)->{'build_manifest'};
}
=head2 C<< check_compatibility(@builders) >>
This method accepts a list of builders and filters out the ones that
are unsupported or mutually exclusive, returning the builders that
passed the filter. If none pass the filter, the default builder is
returned.
=cut
sub check_compatibility {
my $self = shift;
my @builders = @_;
# if we're passed an array reference (or even a list of array
# references), de-reference the first one passed and assign
# @builders its contents
@builders = @{$builders[0]} if(@builders && ref $builders[0] eq 'ARRAY');
# remove empty and unsupported builders
@builders = grep { $self->_builder($_) } @builders;
# if we stripped all of them, use the default
push(@builders, $self->default_builder) unless int( @builders ) > 0;
my %uniq;
my @good;
foreach my $builder (@builders) {
# Builders that generate the same build file are mutually exclusive
# If given a list of builder modules that includes mutually
# exclusive modules, we'll use the first in the list
my $file = $self->file_for_builder($builder);
if (exists $uniq{$file}) {
# don't print a warning if the same builder was listed twice.
# Otherwise, inform the caller that these builders are mutually
# exclusive
carp("Builders '$builder' and '$uniq{$file}' are mutually exclusive.".
" Using '$uniq{$file}'."
) unless $builder eq $uniq{$file};
} else {
$uniq{$file} = $builder;
push(@good, $uniq{$file});
}
}
return( @good );
}
=head2 C<< default_builder() >>
This method returns the module name of the default builder.
=cut
sub default_builder {
my $self = shift;
return 'ExtUtils::MakeMaker';
}
=head1 BUGS
Please report any bugs or feature requests to the bugtracker for this project
on GitHub at: L. I will be
notified, and then you'll automatically be notified of progress on your bug
as I make changes.
=head1 AUTHOR
C.J. Adams-Collier, C<< >>
=head1 Copyright & License
Copyright 2007 C.J. Adams-Collier, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
Please note that these modules are not products of or supported by the
employers of the various contributors to the code.
=cut
1;
# vi:et:sw=4 ts=4
Module-Starter-1.73/lib/Module/Starter/Plugin/0000755000175000017500000000000013143242255020571 5ustar grinnzgrinnzModule-Starter-1.73/lib/Module/Starter/Plugin/Template.pm0000644000175000017500000001175113140533215022703 0ustar grinnzgrinnzpackage Module::Starter::Plugin::Template;
use warnings;
use strict;
use Carp qw( confess );
=head1 NAME
Module::Starter::Plugin::Template - module starter with templates
=head1 VERSION
Version 1.73
=cut
our $VERSION = '1.73';
=head1 SYNOPSIS
use Module::Starter qw(
Module::Starter::Simple
Module::Starter::Plugin::Template
);
Module::Starter->create_distro(%args);
=head1 DESCRIPTION
This plugin is designed to be added to a Module::Starter::Simple-compatible
Module::Starter class. It adds stub methods for template retrieval and
rendering, and it replaces all of Simple's _guts methods with methods that will
retrieve and render the appropriate templates.
=head1 CLASS METHODS
=head2 C<< new(%args) >>
This plugin calls the C supermethod and then initializes the template
store and renderer. (See C and C below.)
=cut
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
$self->{templates} = { $self->templates };
$self->{renderer} = $self->renderer;
return bless $self => $class;
}
=head1 OBJECT METHODS
=head2 C<< templates() >>
This method is used to initialize the template store on the Module::Starter
object. It returns a hash of templates; each key is a filename and each value
is the body of the template. The filename F is used for the module
template.
=cut
sub templates {
confess 'attempted to use abstract base templates method';
}
=head2 C<< renderer() >>
This method is used to initialize the template renderer. Its result is stored
in the object's C entry. The implementation will determine its use.
=cut
sub renderer {
confess 'attempted to use abstract base renderer method';
}
=head2 C<< render($template, \%options) >>
The C method will render the template passed to it, using the
data in the Module::Starter object and in the hash of passed parameters.
=cut
sub render {
my $self = shift;
my $template = shift;
my $options = shift;
confess 'attempted to use abstract base render method';
}
=head2 _guts methods
All of the C methods from Module::Starter::Simple are subclassed to
look something like this:
sub file_guts {
my $self = shift;
my %options;
@options{qw(first second third)} = @_;
my $template = $self->{templates}{filename};
$self->render($template, \%options);
}
These methods will need to be rewritten when (as is likely)
Module::Starter::Simple's _guts methods are refactored into a registry.
=over 4
=item module_guts
=cut
sub module_guts {
my $self = shift;
my %options;
@options{qw(module rtname)} = @_;
my $template = $self->{templates}{'Module.pm'};
$self->render($template, \%options);
}
=item Makefile_PL_guts
=cut
sub Makefile_PL_guts {
my $self = shift;
my %options;
@options{qw(main_module main_pm_file)} = @_;
my $template = $self->{templates}{'Makefile.PL'};
$self->render($template, \%options);
}
=item MI_Makefile_PL_guts
=cut
sub MI_Makefile_PL_guts {
my $self = shift;
my %options;
@options{qw(main_module main_pm_file)} = @_;
my $template = $self->{templates}{'MI_Makefile.PL'};
$self->render($template, \%options);
}
=item Build_PL_guts
=cut
sub Build_PL_guts {
my $self = shift;
my %options;
@options{qw(main_module main_pm_file)} = @_;
my $template = $self->{templates}{'Build.PL'};
$self->render($template, \%options);
}
=item Changes_guts
=cut
sub Changes_guts {
my $self = shift;
my $template = $self->{templates}{'Changes'};
$self->render($template);
}
=item README_guts
=cut
sub README_guts {
my $self = shift;
my %options;
@options{qw(build_instructions)} = @_;
my $template = $self->{templates}{'README'};
$self->render($template, \%options);
}
=item t_guts
=cut
sub t_guts {
my $self = shift;
my %options;
$options{modules} = [ @_ ];
my %t_files;
foreach (grep { /\.t$/ } keys %{$self->{templates}}) {
my $template = $self->{templates}{$_};
$t_files{$_} = $self->render($template, \%options);
}
return %t_files;
}
=item MANIFEST_guts
=cut
sub MANIFEST_guts {
my $self = shift;
my %options;
$options{files} = [ sort @_ ];
my $template = $self->{templates}{MANIFEST};
$self->render($template, \%options);
}
=item ignores_guts
=cut
sub ignores_guts {
my $self = shift;
my $template = $self->{templates}{ignores};
$self->render($template);
}
=back
=head1 AUTHOR
Ricardo SIGNES, C<< >>
=head1 Bugs
Please report any bugs or feature requests to the bugtracker for this project
on GitHub at: L. I will be
notified, and then you'll automatically be notified of progress on your bug
as I make changes.
=head1 COPYRIGHT
Copyright 2005-2007 Ricardo SIGNES, All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
# vi:et:sw=4 ts=4
1;
Module-Starter-1.73/lib/Module/Starter/Plugin.pod0000644000175000017500000000431013064625343021300 0ustar grinnzgrinnz=pod
=head1 NAME
Module::Starter::Plugin -- how Module::Starter plugins work
=head1 DESCRIPTION
This document is a guide to writing plugins for Module::Starter. Currently, as
is evident, it isn't very comprehensive. It should provide enough information
for writing effective plugins, though. After all, Module::Starter's guts are
nice and simple.
=head2 C<< Module::Starter->import >>
Module::Starter provides an import method, the arguments to which are plugins,
in the order in which they should be loaded. If no plugins are given,
L (and only Module::Starter::Simple) is loaded.
By default, the given modules are required and arranged in an I chain.
That is, Module::Starter subclasses the last plugin given, which subclasses the
second-to-last, up to the first plugin given, which is the base class. If a
plugin provides a C method, however, the remaining plugins to be
loaded are passed to that method, which is responsible for loading the rest of
the plugins.
This architecture suggests two kinds of plugins:
=head2 engine plugins
An engine is a plugin that stands alone, implementing the public
C method and all the functionality required to carry out that
implementation. The only engine included with Module::Starter is
Module::Starter::Simple, and I'm not sure any more will be seen in the wild any
time soon.
=head2 plain old plugins
Other plugins are designed to subclass an engine and alter its behavior,
just as a normal subclass alters its parent class's. These plugins may add
features to Module::Starter engines, or may just provide general APIs for other
plugins to exploit (like L.)
The template plugin is a simple example of a plugin that alters an engine to
accept further plugins. Other plugins like template will probably be written
in the near future, and plugins that exploit the API provided by
Module::Starter::Plugin::Template will be available on the CPAN.
=head1 AUTHOR
Ricardo SIGNES C<< >>
=head1 COPYRIGHT
Copyright 2005, Ricardo SIGNES. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=cut
Module-Starter-1.73/lib/Module/Starter/App.pm0000644000175000017500000000702413143171010020402 0ustar grinnzgrinnzpackage Module::Starter::App;
=head1 NAME
Module::Starter::App - the code behind the command line program
=cut
use warnings;
use strict;
our $VERSION = '1.73';
use File::Spec;
use Getopt::Long;
use Pod::Usage;
use Carp qw( croak );
use Module::Runtime qw( require_module );
sub _config_file {
my $self = shift;
my $configdir = $ENV{'MODULE_STARTER_DIR'} || '';
if ( !$configdir && $ENV{'HOME'} ) {
$configdir = File::Spec->catdir( $ENV{'HOME'}, '.module-starter' );
}
return File::Spec->catfile( $configdir, 'config' );
}
sub _config_read {
my $self = shift;
my $filename = $self->_config_file;
return () unless -e $filename;
open( my $config_file, '<', $filename )
or die "couldn't open config file $filename: $!\n";
my %config;
while (my $line = <$config_file>) {
chomp $line;
next if $line =~ /\A\s*\Z/sm;
if ($line =~ /\A(\w+):\s*(.+)\Z/sm) { $config{$1} = $2; }
}
return $self->_config_multi_process(%config);
}
sub _config_multi_process {
my ( $self, %config ) = @_;
# The options that accept multiple arguments must be set to an arrayref
foreach my $key (qw( builder ignores_type modules plugins )) {
$config{$key} = [ split /(?:\s*,\s*|\s+)/, (ref $config{$key} ? join(',', @{$config{$key}}) : $config{$key}) ] if $config{$key};
$config{$key} = [] unless exists $config{$key};
}
return %config;
}
sub _process_command_line {
my ( $self, %config ) = @_;
$config{'argv'} = [ @ARGV ];
pod2usage(2) unless @ARGV;
GetOptions(
'class=s' => \$config{class},
'plugin=s@' => \$config{plugins},
'dir=s' => \$config{dir},
'distro=s' => \$config{distro},
'module=s@' => \$config{modules},
'builder=s@' => \$config{builder},
'ignores=s@' => \$config{ignores_type},
eumm => sub { push @{$config{builder}}, 'ExtUtils::MakeMaker' },
mb => sub { push @{$config{builder}}, 'Module::Build' },
mi => sub { push @{$config{builder}}, 'Module::Install' },
'author=s' => \$config{author},
'email=s' => \$config{email},
'license=s' => \$config{license},
'minperl=s' => \$config{minperl},
'fatalize' => \$config{fatalize},
force => \$config{force},
verbose => \$config{verbose},
version => sub {
require Module::Starter;
print "module-starter v$Module::Starter::VERSION\n";
exit 1;
},
help => sub { pod2usage(1); },
) or pod2usage(2);
if (@ARGV) {
pod2usage(
-msg => "Unparseable arguments received: " . join(',', @ARGV),
-exitval => 2,
);
}
$config{class} ||= 'Module::Starter';
$config{builder} = ['ExtUtils::MakeMaker'] unless $config{builder};
return %config;
}
=head2 run
Module::Starter::App->run;
This is equivalent to running F. Its behavior is still subject
to change.
=cut
sub run {
my $self = shift;
my %config = $self->_config_read;
%config = $self->_process_command_line(%config);
%config = $self->_config_multi_process(%config);
require_module $config{class};
$config{class}->import( @{ $config{'plugins'} } );
my $starter = $config{class}->new( %config );
$starter->postprocess_config;
$starter->pre_create_distro;
$starter->create_distro;
$starter->post_create_distro;
$starter->pre_exit;
return 1;
}
1;
Module-Starter-1.73/lib/Module/Starter/Simple.pm0000644000175000017500000014102713143171335021127 0ustar grinnzgrinnzpackage Module::Starter::Simple;
use 5.006;
use strict;
use warnings;
use Cwd 'cwd';
use ExtUtils::Command qw( rm_rf mkpath touch );
use File::Spec ();
use Carp qw( carp confess croak );
use Module::Starter::BuilderSet;
=head1 NAME
Module::Starter::Simple - a simple, comprehensive Module::Starter plugin
=head1 VERSION
Version 1.73
=cut
our $VERSION = '1.73';
=head1 SYNOPSIS
use Module::Starter qw(Module::Starter::Simple);
Module::Starter->create_distro(%args);
=head1 DESCRIPTION
Module::Starter::Simple is a plugin for Module::Starter that will perform all
the work needed to create a distribution. Given the parameters detailed in
L, it will create content, create directories, and populate
the directories with the required files.
=head1 CLASS METHODS
=head2 C<< new(%args) >>
This method is called to construct and initialize a new Module::Starter object.
It is never called by the end user, only internally by C, which
creates ephemeral Module::Starter objects. It's documented only to call it to
the attention of subclass authors.
=cut
sub new {
my $class = shift;
return bless { @_ } => $class;
}
=head1 OBJECT METHODS
All the methods documented below are object methods, meant to be called
internally by the ephemeral objects created during the execution of the class
method C above.
=head2 postprocess_config
A hook to do any work after the configuration is initially processed.
=cut
sub postprocess_config { 1 };
=head2 pre_create_distro
A hook to do any work right before the distro is created.
=cut
sub pre_create_distro { 1 };
=head2 C<< create_distro(%args) >>
This method works as advertised in L.
=cut
sub create_distro {
my $either = shift;
( ref $either ) or $either = $either->new( @_ );
my $self = $either;
my $modules = $self->{modules} || [];
my @modules = map { split /,/ } @{$modules};
croak "No modules specified.\n" unless @modules;
for (@modules) {
croak "Invalid module name: $_" unless /\A[a-z_]\w*(?:::[\w]+)*\Z/i;
}
if ( ( not $self->{author} ) && ( $^O ne 'MSWin32' ) ) {
( $self->{author} ) = split /,/, ( getpwuid $> )[6];
}
if ( not $self->{email} and exists $ENV{EMAIL} ) {
$self->{email} = $ENV{EMAIL};
}
croak "Must specify an author\n" unless $self->{author};
croak "Must specify an email address\n" unless $self->{email};
($self->{email_obfuscated} = $self->{email}) =~ s/@/ at /;
$self->{license} ||= 'artistic2';
$self->{minperl} ||= '5.006';
$self->{ignores_type} ||= ['generic'];
$self->{manifest_skip} = !! grep { /manifest/ } @{ $self->{ignores_type} };
$self->{license_record} = $self->_license_record();
$self->{main_module} = $modules[0];
if ( not defined $self->{distro} or not length $self->{distro} ) {
$self->{distro} = $self->{main_module};
$self->{distro} =~ s/::/-/g;
}
$self->{basedir} = $self->{dir} || $self->{distro};
$self->create_basedir;
my @files;
push @files, $self->create_modules( @modules );
push @files, $self->create_t( @modules );
push @files, $self->create_ignores;
my %build_results = $self->create_build();
push(@files, @{ $build_results{files} } );
push @files, $self->create_Changes;
push @files, $self->create_README( $build_results{instructions} );
$self->create_MANIFEST( $build_results{'manifest_method'} ) unless ( $self->{manifest_skip} );
# TODO: put files to ignore in a more standard form?
# XXX: no need to return the files created
return;
}
=head2 post_create_distro
A hook to do any work after creating the distribution.
=cut
sub post_create_distro { 1 };
=head2 pre_exit
A hook to do any work right before exit time.
=cut
sub pre_exit {
print "Created starter directories and files\n";
}
=head2 create_basedir
Creates the base directory for the distribution. If the directory already
exists, and I<$force> is true, then the existing directory will get erased.
If the directory can't be created, or re-created, it dies.
=cut
sub create_basedir {
my $self = shift;
# Make sure there's no directory
if ( -e $self->{basedir} ) {
die( "$self->{basedir} already exists. ".
"Use --force if you want to stomp on it.\n"
) unless $self->{force};
local @ARGV = $self->{basedir};
rm_rf();
die "Couldn't delete existing $self->{basedir}: $!\n"
if -e $self->{basedir};
}
CREATE_IT: {
$self->progress( "Created $self->{basedir}" );
local @ARGV = $self->{basedir};
mkpath();
die "Couldn't create $self->{basedir}: $!\n" unless -d $self->{basedir};
}
return;
}
=head2 create_modules( @modules )
This method will create a starter module file for each module named in
I<@modules>.
=cut
sub create_modules {
my $self = shift;
my @modules = @_;
my @files;
for my $module ( @modules ) {
my $rtname = lc $module;
$rtname =~ s/::/-/g;
push @files, $self->_create_module( $module, $rtname );
}
return @files;
}
=head2 module_guts( $module, $rtname )
This method returns the text which should serve as the contents for the named
module. I<$rtname> is the email suffix which rt.cpan.org will use for bug
reports. (This should, and will, be moved out of the parameters for this
method eventually.)
=cut
our $LICENSES = {
perl => {
license => 'perl',
slname => 'perl_5',
url => 'http://dev.perl.org/licenses/',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or modify it
under the terms of either: the GNU General Public License as published
by the Free Software Foundation; or the Artistic License.
See L for more information.
EOT
},
artistic => {
license => 'artistic',
slname => 'artistic_1',
url => 'http://www.perlfoundation.org/artistic_license_1_0',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (1.0). You may obtain a
copy of the full license at:
L
Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
EOT
},
artistic2 => {
license => 'artistic2',
slname => 'artistic_2',
url => 'http://www.perlfoundation.org/artistic_license_2_0',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or modify it
under the terms of the the Artistic License (2.0). You may obtain a
copy of the full license at:
L
Any use, modification, and distribution of the Standard or Modified
Versions is governed by this Artistic License. By using, modifying or
distributing the Package, you accept this license. Do not use, modify,
or distribute the Package, if you do not accept this license.
If your Modified Version has been derived from a Modified Version made
by someone other than you, you are nevertheless required to ensure that
your Modified Version complies with the requirements of this license.
This license does not grant you the right to use any trademark, service
mark, tradename, or logo of the Copyright Holder.
This license includes the non-exclusive, worldwide, free-of-charge
patent license to make, have made, use, offer to sell, sell, import and
otherwise transfer the Package with respect to any patent claims
licensable by the Copyright Holder that are necessarily infringed by the
Package. If you institute patent litigation (including a cross-claim or
counterclaim) against any party alleging that the Package constitutes
direct or contributory patent infringement, then this Artistic License
to you shall terminate on the date that such litigation is filed.
Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER
AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY
YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR
CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR
CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EOT
},
mit => {
license => 'mit',
slname => 'mit',
url => 'http://www.opensource.org/licenses/mit-license.php',
blurb => <<'EOT',
This program is distributed under the MIT (X11) License:
L
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
EOT
},
mozilla => {
license => 'mozilla',
slname => 'mozilla_1_1',
url => 'http://www.mozilla.org/MPL/1.1/',
blurb => <<'EOT',
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
L
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
EOT
},
mozilla2 => {
license => 'mozilla2',
slname => 'open_source',
url => 'http://www.mozilla.org/MPL/2.0/',
blurb => <<'EOT',
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at L.
EOT
},
bsd => {
license => 'bsd',
slname => 'bsd',
url => 'http://www.opensource.org/licenses/BSD-3-Clause',
blurb => <<"EOT",
This program is distributed under the (Revised) BSD License:
L
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of ___AUTHOR___'s Organization
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EOT
},
freebsd => {
license => 'freebsd',
slname => 'freebsd',
url => 'http://www.opensource.org/licenses/BSD-2-Clause',
blurb => <<"EOT",
This program is distributed under the (Simplified) BSD License:
L
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EOT
},
cc0 => {
license => 'cc0',
slname => 'unrestricted',
url => 'http://creativecommons.org/publicdomain/zero/1.0/',
blurb => <<'EOT',
This program is distributed under the CC0 1.0 Universal License:
L
The person who associated a work with this deed has dedicated the work
to the public domain by waiving all of his or her rights to the work
worldwide under copyright law, including all related and neighboring
rights, to the extent allowed by law.
You can copy, modify, distribute and perform the work, even for
commercial purposes, all without asking permission. See Other
Information below.
Other Information:
* In no way are the patent or trademark rights of any person affected
by CC0, nor are the rights that other persons may have in the work or
in how the work is used, such as publicity or privacy rights.
* Unless expressly stated otherwise, the person who associated a work
with this deed makes no warranties about the work, and disclaims
liability for all uses of the work, to the fullest extent permitted
by applicable law.
* When using or citing the work, you should not imply endorsement by
the author or the affirmer.
EOT
},
gpl => {
license => 'gpl',
slname => 'gpl_2',
url => 'http://www.gnu.org/licenses/gpl-2.0.html',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991 or at your option
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
A copy of the GNU General Public License is available in the source tree;
if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
EOT
},
lgpl => {
license => 'lgpl',
slname => 'lgpl_2_1',
url => 'http://www.gnu.org/licenses/lgpl-2.1.html',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write to the Free
Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
EOT
},
gpl3 => {
license => 'gpl3',
slname => 'gpl_3',
url => 'http://www.gnu.org/licenses/gpl-3.0.html',
blurb => <<'EOT',
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see L.
EOT
},
lgpl3 => {
license => 'lgpl3',
slname => 'lgpl_3_0',
url => 'http://www.gnu.org/licenses/lgpl-3.0.html',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
L.
EOT
},
agpl3 => {
license => 'agpl3',
slname => 'agpl_3',
url => 'http://www.gnu.org/licenses/agpl-3.0.html',
blurb => <<'EOT',
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU Affero General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public
License along with this program. If not, see
L.
EOT
},
apache => {
license => 'apache',
slname => 'apache_2_0',
url => 'http://www.apache.org/licenses/LICENSE-2.0',
blurb => <<'EOT',
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
L
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
EOT
},
qpl => {
license => 'qpl',
slname => 'qpl_1_0',
url => 'http://www.opensource.org/licenses/QPL-1.0',
blurb => <<'EOT',
This program is distributed under the Q Public License (QPL-1.0):
L
The Software and this license document are provided AS IS with NO
WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE.
EOT
},
};
sub _license_record { $LICENSES->{ shift->{license} }; }
sub _license_blurb {
my $self = shift;
my $record = $self->{license_record};
my $license_blurb = defined($record) ?
$record->{blurb} :
<<"EOT";
This program is released under the following license: $self->{license}
EOT
$license_blurb =~ s/___AUTHOR___/$self->{author}/ge;
chomp $license_blurb;
return $license_blurb;
}
# _create_module: used by create_modules to build each file and put data in it
sub _create_module {
my $self = shift;
my $module = shift;
my $rtname = shift;
my @parts = split( /::/, $module );
my $filepart = (pop @parts) . '.pm';
my @dirparts = ( $self->{basedir}, 'lib', @parts );
my $SLASH = q{/};
my $manifest_file = join( $SLASH, 'lib', @parts, $filepart );
if ( @dirparts ) {
my $dir = File::Spec->catdir( @dirparts );
if ( not -d $dir ) {
local @ARGV = $dir;
mkpath @ARGV;
$self->progress( "Created $dir" );
}
}
my $module_file = File::Spec->catfile( @dirparts, $filepart );
$self->{module_file}{$module} = File::Spec->catfile('lib', @parts, $filepart);
$self->create_file( $module_file, $self->module_guts( $module, $rtname ) );
$self->progress( "Created $module_file" );
return $manifest_file;
}
sub _thisyear {
return (localtime())[5] + 1900;
}
sub _module_to_pm_file {
my $self = shift;
my $module = shift;
my @parts = split( /::/, $module );
my $pm = pop @parts;
my $pm_file = File::Spec->catfile( 'lib', @parts, "${pm}.pm" );
$pm_file =~ s{\\}{/}g; # even on Win32, use forward slash
return $pm_file;
}
sub _reference_links {
return (
{ nickname => 'RT',
title => 'CPAN\'s request tracker (report bugs here)',
link => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=%s',
},
{ nickname => 'AnnoCPAN',
title => 'Annotated CPAN documentation',
link => 'http://annocpan.org/dist/%s',
},
{ title => 'CPAN Ratings',
link => 'http://cpanratings.perl.org/d/%s',
},
{ title => 'Search CPAN',
link => 'http://search.cpan.org/dist/%s/',
},
);
}
=head2 create_Makefile_PL( $main_module )
This will create the Makefile.PL for the distribution, and will use the module
named in I<$main_module> as the main module of the distribution.
=cut
sub create_Makefile_PL {
my $self = shift;
my $main_module = shift;
my $builder_name = 'ExtUtils::MakeMaker';
my $output_file =
Module::Starter::BuilderSet->new()->file_for_builder($builder_name);
my $fname = File::Spec->catfile( $self->{basedir}, $output_file );
$self->create_file(
$fname,
$self->Makefile_PL_guts(
$main_module,
$self->_module_to_pm_file($main_module),
),
);
$self->progress( "Created $fname" );
return $output_file;
}
=head2 create_MI_Makefile_PL( $main_module )
This will create a Module::Install Makefile.PL for the distribution, and will
use the module named in I<$main_module> as the main module of the distribution.
=cut
sub create_MI_Makefile_PL {
my $self = shift;
my $main_module = shift;
my $builder_name = 'Module::Install';
my $output_file =
Module::Starter::BuilderSet->new()->file_for_builder($builder_name);
my $fname = File::Spec->catfile( $self->{basedir}, $output_file );
$self->create_file(
$fname,
$self->MI_Makefile_PL_guts(
$main_module,
$self->_module_to_pm_file($main_module),
),
);
$self->progress( "Created $fname" );
return $output_file;
}
=head2 Makefile_PL_guts( $main_module, $main_pm_file )
This method is called by create_Makefile_PL and returns text used to populate
Makefile.PL; I<$main_pm_file> is the filename of the distribution's main
module, I<$main_module>.
=cut
sub Makefile_PL_guts {
my $self = shift;
my $main_module = shift;
my $main_pm_file = shift;
(my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g;
my $slname = $self->{license_record} ? $self->{license_record}->{slname} : $self->{license};
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all'" : '');
return <<"HERE";
use $self->{minperl};
use strict;
use $warnings
use ExtUtils::MakeMaker;
WriteMakefile(
NAME => '$main_module',
AUTHOR => q{$author},
VERSION_FROM => '$main_pm_file',
ABSTRACT_FROM => '$main_pm_file',
LICENSE => '$slname',
PL_FILES => {},
MIN_PERL_VERSION => '$self->{minperl}',
CONFIGURE_REQUIRES => {
'ExtUtils::MakeMaker' => '0',
},
BUILD_REQUIRES => {
'Test::More' => '0',
},
PREREQ_PM => {
#'ABC' => '1.6',
#'Foo::Bar::Module' => '5.0401',
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => '$self->{distro}-*' },
);
HERE
}
=head2 MI_Makefile_PL_guts( $main_module, $main_pm_file )
This method is called by create_MI_Makefile_PL and returns text used to populate
Makefile.PL; I<$main_pm_file> is the filename of the distribution's main
module, I<$main_module>.
=cut
sub MI_Makefile_PL_guts {
my $self = shift;
my $main_module = shift;
my $main_pm_file = shift;
my $author = "$self->{author} <$self->{email}>";
$author =~ s/'/\'/g;
my $license_url = $self->{license_record} ? $self->{license_record}->{url} : '';
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all'" : '');
return <<"HERE";
use $self->{minperl};
use strict;
use $warnings
use inc::Module::Install;
name '$self->{distro}';
all_from '$main_pm_file';
author q{$author};
license '$self->{license}';
perl_version '$self->{minperl}';
tests_recursive('t');
resources (
#homepage => 'http://yourwebsitehere.com',
#IRC => 'irc://irc.perl.org/#$self->{distro}',
license => '$license_url',
#repository => 'git://github.com/$self->{author}/$self->{distro}.git',
#repository => 'https://bitbucket.org/$self->{author}/$self->{distro}',
bugtracker => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=$self->{distro}',
);
configure_requires (
'Module::Install' => '0',
);
build_requires (
'Test::More' => '0',
);
requires (
#'ABC' => '1.6',
#'Foo::Bar::Module' => '5.0401',
);
install_as_cpan;
auto_install;
WriteAll;
HERE
}
=head2 create_Build_PL( $main_module )
This will create the Build.PL for the distribution, and will use the module
named in I<$main_module> as the main module of the distribution.
=cut
sub create_Build_PL {
my $self = shift;
my $main_module = shift;
my $builder_name = 'Module::Build';
my $output_file =
Module::Starter::BuilderSet->new()->file_for_builder($builder_name);
my $fname = File::Spec->catfile( $self->{basedir}, $output_file );
$self->create_file(
$fname,
$self->Build_PL_guts(
$main_module,
$self->_module_to_pm_file($main_module),
),
);
$self->progress( "Created $fname" );
return $output_file;
}
=head2 Build_PL_guts( $main_module, $main_pm_file )
This method is called by create_Build_PL and returns text used to populate
Build.PL; I<$main_pm_file> is the filename of the distribution's main module,
I<$main_module>.
=cut
sub Build_PL_guts {
my $self = shift;
my $main_module = shift;
my $main_pm_file = shift;
(my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g;
my $slname = $self->{license_record} ? $self->{license_record}->{slname} : $self->{license};
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all'" : '');
return <<"HERE";
use $self->{minperl};
use strict;
use $warnings
use Module::Build;
my \$builder = Module::Build->new(
module_name => '$main_module',
license => '$slname',
dist_author => q{$author},
dist_version_from => '$main_pm_file',
release_status => 'stable',
configure_requires => {
'Module::Build' => '0',
},
build_requires => {
'Test::More' => '0',
},
requires => {
#'ABC' => '1.6',
#'Foo::Bar::Module' => '5.0401',
},
add_to_cleanup => [ '$self->{distro}-*' ],
);
\$builder->create_build_script();
HERE
}
=head2 create_Changes( )
This method creates a skeletal Changes file.
=cut
sub create_Changes {
my $self = shift;
my $fname = File::Spec->catfile( $self->{basedir}, 'Changes' );
$self->create_file( $fname, $self->Changes_guts() );
$self->progress( "Created $fname" );
return 'Changes';
}
=head2 Changes_guts
Called by create_Changes, this method returns content for the Changes file.
=cut
sub Changes_guts {
my $self = shift;
return <<"HERE";
Revision history for $self->{distro}
0.01 Date/time
First version, released on an unsuspecting world.
HERE
}
=head2 create_README( $build_instructions )
This method creates the distribution's README file.
=cut
sub create_README {
my $self = shift;
my $build_instructions = shift;
my $fname = File::Spec->catfile( $self->{basedir}, 'README' );
$self->create_file( $fname, $self->README_guts($build_instructions) );
$self->progress( "Created $fname" );
return 'README';
}
=head2 README_guts
Called by create_README, this method returns content for the README file.
=cut
sub _README_intro {
my $self = shift;
return <<"HERE";
The README is used to introduce the module and provide instructions on
how to install the module, any machine dependencies it may have (for
example C compilers and installed libraries) and any other information
that should be provided before the module is installed.
A README file is required for CPAN modules since CPAN extracts the README
file from a module distribution so that people browsing the archive
can use it to get an idea of the module's uses. It is usually a good idea
to provide version information here so that people can decide whether
fixes for the module are worth downloading.
HERE
}
sub _README_information {
my $self = shift;
my @reference_links = _reference_links();
my $content = "You can also look for information at:\n";
foreach my $ref (@reference_links){
my $title;
$title = "$ref->{nickname}, " if exists $ref->{nickname};
$title .= $ref->{title};
my $link = sprintf($ref->{link}, $self->{distro});
$content .= qq[
$title
$link
];
}
return $content;
}
sub _README_license {
my $self = shift;
my $year = $self->_thisyear();
my $license_blurb = $self->_license_blurb();
return <<"HERE";
LICENSE AND COPYRIGHT
Copyright (C) $year $self->{author}
$license_blurb
HERE
}
sub README_guts {
my $self = shift;
my $build_instructions = shift;
my $intro = $self->_README_intro();
my $information = $self->_README_information();
my $license = $self->_README_license();
return <<"HERE";
$self->{distro}
$intro
INSTALLATION
$build_instructions
SUPPORT AND DOCUMENTATION
After installing, you can find documentation for this module with the
perldoc command.
perldoc $self->{main_module}
$information
$license
HERE
}
=head2 create_t( @modules )
This method creates a bunch of *.t files. I<@modules> is a list of all modules
in the distribution.
=cut
sub create_t {
my $self = shift;
my @modules = @_;
my %t_files = $self->t_guts(@modules);
my %xt_files = $self->xt_guts(@modules);
my @files;
push @files, map { $self->_create_t('t', $_, $t_files{$_}) } keys %t_files;
push @files, map { $self->_create_t('xt', $_, $xt_files{$_}) } keys %xt_files;
return @files;
}
=head2 t_guts( @modules )
This method is called by create_t, and returns a description of the *.t files
to be created.
The return value is a hash of test files to create. Each key is a filename and
each value is the contents of that file.
=cut
sub t_guts {
my $self = shift;
my @modules = @_;
my %t_files;
my $minperl = $self->{minperl};
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all'" : '');
my $header = <<"EOH";
#!perl -T
use $minperl;
use strict;
use $warnings
use Test::More;
EOH
$t_files{'pod.t'} = $header.<<'HERE';
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
# Ensure a recent version of Test::Pod
my $min_tp = 1.22;
eval "use Test::Pod $min_tp";
plan skip_all => "Test::Pod $min_tp required for testing POD" if $@;
all_pod_files_ok();
HERE
$t_files{'manifest.t'} = $header.<<'HERE';
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
my $min_tcm = 0.9;
eval "use Test::CheckManifest $min_tcm";
plan skip_all => "Test::CheckManifest $min_tcm required" if $@;
ok_manifest();
HERE
$t_files{'pod-coverage.t'} = $header.<<'HERE';
unless ( $ENV{RELEASE_TESTING} ) {
plan( skip_all => "Author tests not required for installation" );
}
# Ensure a recent version of Test::Pod::Coverage
my $min_tpc = 1.08;
eval "use Test::Pod::Coverage $min_tpc";
plan skip_all => "Test::Pod::Coverage $min_tpc required for testing POD coverage"
if $@;
# Test::Pod::Coverage doesn't require a minimum Pod::Coverage version,
# but older versions don't recognize some common documentation styles
my $min_pc = 0.18;
eval "use Pod::Coverage $min_pc";
plan skip_all => "Pod::Coverage $min_pc required for testing POD coverage"
if $@;
all_pod_coverage_ok();
HERE
my $nmodules = @modules;
my $main_module = $modules[0];
my $use_lines = join(
"\n", map { qq{ use_ok( '$_' ) || print "Bail out!\\n";} } @modules
);
$t_files{'00-load.t'} = $header.<<"HERE";
plan tests => $nmodules;
BEGIN {
$use_lines
}
diag( "Testing $main_module \$${main_module}::VERSION, Perl \$], \$^X" );
HERE
return %t_files;
}
=head2 xt_guts( @modules )
This method is called by create_t, and returns a description of the author
only *.t files to be created in the xt directory.
The return value is a hash of test files to create. Each key is a filename and
each value is the contents of that file.
=cut
sub xt_guts {
my $self = shift;
my @modules = @_;
my %xt_files;
my $minperl = $self->{minperl};
my $warnings = sprintf 'warnings%s;', ($self->{fatalize} ? " FATAL => 'all'" : '');
my $header = <<"EOH";
#!perl -T
use $minperl;
use strict;
use $warnings
use Test::More;
EOH
my $module_boilerplate_tests;
$module_boilerplate_tests .=
" module_boilerplate_ok('".$self->_module_to_pm_file($_)."');\n" for @modules;
my $boilerplate_tests = @modules + 2;
$xt_files{'boilerplate.t'} = $header.<<"HERE";
plan tests => $boilerplate_tests;
sub not_in_file_ok {
my (\$filename, \%regex) = \@_;
open( my \$fh, '<', \$filename )
or die "couldn't open \$filename for reading: \$!";
my \%violated;
while (my \$line = <\$fh>) {
while (my (\$desc, \$regex) = each \%regex) {
if (\$line =~ \$regex) {
push \@{\$violated{\$desc}||=[]}, \$.;
}
}
}
if (\%violated) {
fail("\$filename contains boilerplate text");
diag "\$_ appears on lines \@{\$violated{\$_}}" for keys \%violated;
} else {
pass("\$filename contains no boilerplate text");
}
}
sub module_boilerplate_ok {
my (\$module) = \@_;
not_in_file_ok(\$module =>
'the great new \$MODULENAME' => qr/ - The great new /,
'boilerplate description' => qr/Quick summary of what the module/,
'stub function definition' => qr/function[12]/,
);
}
TODO: {
local \$TODO = "Need to replace the boilerplate text";
not_in_file_ok(README =>
"The README is used..." => qr/The README is used/,
"'version information here'" => qr/to provide version information/,
);
not_in_file_ok(Changes =>
"placeholder date/time" => qr(Date/time)
);
$module_boilerplate_tests
}
HERE
return %xt_files;
}
sub _create_t {
my $self = shift;
my $directory = shift; # 't' or 'xt'
my $filename = shift;
my $content = shift;
my @dirparts = ( $self->{basedir}, $directory );
my $tdir = File::Spec->catdir( @dirparts );
if ( not -d $tdir ) {
local @ARGV = $tdir;
mkpath();
$self->progress( "Created $tdir" );
}
my $fname = File::Spec->catfile( @dirparts, $filename );
$self->create_file( $fname, $content );
$self->progress( "Created $fname" );
return join('/', $directory, $filename );
}
=head2 create_MB_MANIFEST
This methods creates a MANIFEST file using Module::Build's methods.
=cut
sub create_MB_MANIFEST {
my $self = shift;
$self->create_EUMM_MANIFEST;
}
=head2 create_MI_MANIFEST
This method creates a MANIFEST file using Module::Install's methods.
Currently runs ExtUtils::MakeMaker's methods.
=cut
sub create_MI_MANIFEST {
my $self = shift;
$self->create_EUMM_MANIFEST;
}
=head2 create_EUMM_MANIFEST
This method creates a MANIFEST file using ExtUtils::MakeMaker's methods.
=cut
sub create_EUMM_MANIFEST {
my $self = shift;
my $orig_dir = cwd();
# create the MANIFEST in the correct path
chdir $self->{'basedir'} || die "Can't reach basedir: $!\n";
require ExtUtils::Manifest;
$ExtUtils::Manifest::Quiet = 0;
ExtUtils::Manifest::mkmanifest();
# return to our original path, wherever it was
chdir $orig_dir || die "Can't return to original dir: $!\n";
}
=head2 create_MANIFEST( $method )
This method creates the distribution's MANIFEST file. It must be run last,
because all the other create_* functions have been returning the functions they
create.
It receives a method to run in order to create the MANIFEST file. That way it
can create a MANIFEST file according to the builder used.
=cut
sub create_MANIFEST {
my ( $self, $manifest_method ) = @_;
my $fname = File::Spec->catfile( $self->{basedir}, 'MANIFEST' );
$self->$manifest_method();
$self->filter_lines_in_file(
$fname,
qr/^xt\/boilerplate\.t$/,
qr/^ignore\.txt$/,
);
$self->progress( "Created $fname" );
return 'MANIFEST';
}
=head2 get_builders( )
This methods gets the correct builder(s).
It is called by C, and returns an arrayref with the builders.
=cut
sub get_builders {
my $self = shift;
# pass one: pull the builders out of $self->{builder}
my @tmp =
ref $self->{'builder'} eq 'ARRAY' ? @{ $self->{'builder'} }
: $self->{'builder'};
my @builders;
my $COMMA = q{,};
# pass two: expand comma-delimited builder lists
foreach my $builder (@tmp) {
push( @builders, split( $COMMA, $builder ) );
}
return \@builders;
}
=head2 create_build( )
This method creates the build file(s) and puts together some build
instructions. The builders currently supported are:
ExtUtils::MakeMaker
Module::Build
Module::Install
=cut
sub create_build {
my $self = shift;
# get the builders
my @builders = @{ $self->get_builders };
my $builder_set = Module::Starter::BuilderSet->new();
# Remove mutually exclusive and unsupported builders
@builders = $builder_set->check_compatibility( @builders );
# compile some build instructions, create a list of files generated
# by the builders' create_* methods, and call said methods
my @build_instructions;
my @files;
my $manifest_method;
foreach my $builder ( @builders ) {
if ( !@build_instructions ) {
push( @build_instructions,
'To install this module, run the following commands:'
);
}
else {
push( @build_instructions,
"Alternatively, to install with $builder, you can ".
"use the following commands:"
);
}
push( @files, $builder_set->file_for_builder($builder) );
my @commands = $builder_set->instructions_for_builder($builder);
push( @build_instructions, join("\n", map { "\t$_" } @commands) );
my $build_method = $builder_set->method_for_builder($builder);
$self->$build_method($self->{main_module});
$manifest_method = $builder_set->manifest_method($builder);
}
return(
files => [ @files ],
instructions => join( "\n\n", @build_instructions ),
manifest_method => $manifest_method,
);
}
=head2 create_ignores()
This creates a text file for use as MANIFEST.SKIP, .cvsignore,
.gitignore, or whatever you use.
=cut
sub create_ignores {
my $self = shift;
my $type = $self->{ignores_type};
my %names = (
generic => 'ignore.txt',
cvs => '.cvsignore',
git => '.gitignore',
hg => '.hgignore',
manifest => 'MANIFEST.SKIP',
);
my $create_file = sub {
my $type = shift;
my $name = $names{$type};
my $fname = File::Spec->catfile( $self->{basedir}, $names{$type} );
$self->create_file( $fname, $self->ignores_guts($type) );
$self->progress( "Created $fname" );
};
if ( ref $type eq 'ARRAY' ) {
foreach my $single_type ( @{$type} ) {
$create_file->($single_type);
}
} elsif ( ! ref $type ) {
$create_file->($type);
}
return; # Not a file that goes in the MANIFEST
}
=head2 ignores_guts()
Called by C, this method returns the contents of the
ignore file.
=cut
sub ignores_guts {
my ($self, $type) = @_;
my $ms = $self->{manifest_skip} ? "MANIFEST\nMANIFEST.bak\n" : '';
my $guts = {
generic => $ms.<<"EOF",
Makefile
Makefile.old
Build
Build.bat
META.*
MYMETA.*
.build/
_build/
cover_db/
blib/
inc/
.lwpcookies
.last_cover_stats
nytprof.out
pod2htm*.tmp
pm_to_blib
$self->{distro}-*
$self->{distro}-*.tar.gz
EOF
# make this more restrictive, since MANIFEST tends to be less noticeable
# (also, manifest supports REs.)
manifest => <<'EOF',
# Top-level filter (only include the following...)
^(?!(?:script|examples|lib|inc|t|xt|maint)/|(?:(?:Makefile|Build)\.PL|README|MANIFEST|Changes|META\.(?:yml|json))$)
# Avoid version control files.
\bRCS\b
\bCVS\b
,v$
\B\.svn\b
\b_darcs\b
# (.git or .hg only in top-level, hence it's blocked above)
# Avoid temp and backup files.
~$
\.tmp$
\.old$
\.bak$
\..*?\.sw[po]$
\#$
\b\.#
# avoid OS X finder files
\.DS_Store$
# ditto for Windows
\bdesktop\.ini$
\b[Tt]humbs\.db$
# Avoid patch remnants
\.orig$
\.rej$
EOF
};
$guts->{hg} = $guts->{cvs} = $guts->{git} = $guts->{generic};
return $guts->{$type};
}
=head1 HELPER METHODS
=head2 verbose
C tells us whether we're in verbose mode.
=cut
sub verbose { return shift->{verbose} }
=head2 create_file( $fname, @content_lines )
Creates I<$fname>, dumps I<@content_lines> in it, and closes it.
Dies on any error.
=cut
sub create_file {
my $self = shift;
my $fname = shift;
my @content = @_;
open( my $fh, '>', $fname ) or confess "Can't create $fname: $!\n";
print {$fh} @content;
close $fh or die "Can't close $fname: $!\n";
return;
}
=head2 progress( @list )
C