r72426 - in /trunk/libmodule-starter-perl: ./ bin/ debian/ lib/Module/ lib/Module/Starter/ lib/Module/Starter/Plugin/ t/
periapt-guest at users.alioth.debian.org
periapt-guest at users.alioth.debian.org
Sat Apr 9 20:54:17 UTC 2011
Author: periapt-guest
Date: Sat Apr 9 20:54:07 2011
New Revision: 72426
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=72426
Log:
New upstream release
Added:
trunk/libmodule-starter-perl/getting-started.html
- copied unchanged from r72425, branches/upstream/libmodule-starter-perl/current/getting-started.html
Modified:
trunk/libmodule-starter-perl/Changes
trunk/libmodule-starter-perl/MANIFEST
trunk/libmodule-starter-perl/META.yml
trunk/libmodule-starter-perl/bin/module-starter
trunk/libmodule-starter-perl/debian/changelog
trunk/libmodule-starter-perl/lib/Module/Starter.pm
trunk/libmodule-starter-perl/lib/Module/Starter/App.pm
trunk/libmodule-starter-perl/lib/Module/Starter/BuilderSet.pm
trunk/libmodule-starter-perl/lib/Module/Starter/Plugin/Template.pm
trunk/libmodule-starter-perl/lib/Module/Starter/Simple.pm
trunk/libmodule-starter-perl/t/test-dist.t
Modified: trunk/libmodule-starter-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/Changes?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/Changes (original)
+++ trunk/libmodule-starter-perl/Changes Sat Apr 9 20:54:07 2011
@@ -1,4 +1,31 @@
Revision history for Perl extension Module::Starter
+
+1.56 Thu Apr 7 17:01:11 IDT 2011
+
+ * No functional changes, productionizing.
+
+1.55_01 Fri Jun 11 16:56:00 IDT 2010
+
+ Special thanks goes to Andy Lester, who has been, still is and
+ will remain an inspiration to many programmers, myself included.
+
+ [ENHANCEMENTS]
+ Added hooks for distribution building in App. Thanks to Brian D. Foy.
+ MANIFEST is now created via the proper builder.
+ Kept create_MANIFEST to act as hook.
+ Added Apache license by pfig.
+
+ * [RT #53539] Refactoring, adding hooks, described above.
+ (Patch provided by brian d. foy)
+
+ * [RT #27304] Minimal version of perl (5.006)
+ (Patch provided by Alexandr Ciornii)
+
+ * [RT #53339] ::Simple uses the builder to create the MANIFEST
+
+ * Moved repository to Github
+
+ * Some more refactoring in Simple::create_builder()
1.54 Tue Dec 8 09:11:00 CST 2009
Modified: trunk/libmodule-starter-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/MANIFEST?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/MANIFEST (original)
+++ trunk/libmodule-starter-perl/MANIFEST Sat Apr 9 20:54:07 2011
@@ -1,4 +1,5 @@
Changes
+getting-started.html
MANIFEST
Makefile.PL
README
Modified: trunk/libmodule-starter-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/META.yml?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/META.yml (original)
+++ trunk/libmodule-starter-perl/META.yml Sat Apr 9 20:54:07 2011
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Module-Starter
-version: 1.54
+version: 1.56
abstract: a simple starter kit for any module
author:
- Andy Lester <andy at petdance.com>
@@ -25,7 +25,7 @@
directory:
- t
- inc
-generated_by: ExtUtils::MakeMaker version 6.50
+generated_by: ExtUtils::MakeMaker version 6.55_02
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: 1.4
Modified: trunk/libmodule-starter-perl/bin/module-starter
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/bin/module-starter?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/bin/module-starter (original)
+++ trunk/libmodule-starter-perl/bin/module-starter Sat Apr 9 20:54:07 2011
@@ -39,7 +39,7 @@
--help Show this message
Available Licenses:
- perl, bsd, gpl, lgpl, mit
+ perl, bsd, gpl, lgpl, mit, apache
Example:
Modified: trunk/libmodule-starter-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/debian/changelog?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/debian/changelog (original)
+++ trunk/libmodule-starter-perl/debian/changelog Sat Apr 9 20:54:07 2011
@@ -1,8 +1,9 @@
-libmodule-starter-perl (1.540+dfsg-2) UNRELEASED; urgency=low
+libmodule-starter-perl (1.560-1) UNRELEASED; urgency=low
* Added myself to Uploaders
+ * New upstream release
- -- Nicholas Bamber <nicholas at periapt.co.uk> Sat, 09 Apr 2011 21:52:07 +0100
+ -- Nicholas Bamber <nicholas at periapt.co.uk> Sat, 09 Apr 2011 21:56:33 +0100
libmodule-starter-perl (1.540+dfsg-1) unstable; urgency=low
Modified: trunk/libmodule-starter-perl/lib/Module/Starter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/lib/Module/Starter.pm?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/lib/Module/Starter.pm (original)
+++ trunk/libmodule-starter-perl/lib/Module/Starter.pm Sat Apr 9 20:54:07 2011
@@ -10,11 +10,11 @@
=head1 VERSION
-version 1.54
+Version 1.56
=cut
-our $VERSION = '1.54';
+our $VERSION = '1.56';
=head1 SYNOPSIS
@@ -111,6 +111,8 @@
=head1 AUTHORS
+Sawyer X, C<< <xsawyerx at cpan.org> >>
+
Andy Lester, C<< <petdance at cpan.org> >>
Ricardo Signes, C<< <rjbs at cpan.org> >>
@@ -161,6 +163,8 @@
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.
Modified: trunk/libmodule-starter-perl/lib/Module/Starter/App.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/lib/Module/Starter/App.pm?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/lib/Module/Starter/App.pm (original)
+++ trunk/libmodule-starter-perl/lib/Module/Starter/App.pm Sat Apr 9 20:54:07 2011
@@ -9,14 +9,29 @@
use warnings;
use strict;
-our $VERSION = '1.54';
+our $VERSION = '1.56';
+use Path::Class;
use Getopt::Long;
use Pod::Usage;
use Carp qw( croak );
+sub _config_file {
+ my $class = shift;
+ my $configdir = $ENV{'MODULE_STARTER_DIR'} || '';
+
+ if ( !$configdir && $ENV{'HOME'} ) {
+ $configdir = dir( $ENV{'HOME'}, '.module-starter' );
+ }
+
+ return file( $configdir, 'config' );
+}
+
+
sub _config_read {
- my $filename = shift;
+ my $class = shift;
+
+ my $filename = $class->_config_file;
return unless -e $filename;
@@ -29,30 +44,9 @@
next if /\A\s*\Z/sm;
if (/\A(\w+):\s*(.+)\Z/sm) { $config{$1} = $2; }
}
- return %config;
-}
-
-=head2 run
-
- Module::Starter::App->run;
-
-This is equivalent to runnint F<module-starter>. Its behavior is still subject
-to change.
-
-=cut
-
-sub run {
-
- my $configdir = $ENV{MODULE_STARTER_DIR} || '';
- if ( !$configdir && $ENV{HOME} ) {
- $configdir = "$ENV{HOME}/.module-starter";
- }
-
- my %config = _config_read( "$configdir/config" );
# The options that accept multiple arguments must be set to an
# arrayref
-
$config{plugins} = [ split /(?:\s*,\s*|\s+)/, $config{plugins} ] if $config{plugins};
$config{builder} = [ split /(?:\s*,\s*|\s+)/, $config{builder} ] if $config{builder};
@@ -60,15 +54,23 @@
$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},
+ 'plugin=s@' => \$config{plugins},
'dir=s' => \$config{dir},
'distro=s' => \$config{distro},
- 'module=s' => $config{modules},
- 'builder=s' => $config{builder},
+ 'module=s@' => \$config{modules},
+ 'builder=s@' => \$config{builder},
eumm => sub { push @{$config{builder}}, 'ExtUtils::MakeMaker' },
mb => sub { push @{$config{builder}}, 'Module::Build' },
mi => sub { push @{$config{builder}}, 'Module::Install' },
@@ -84,26 +86,49 @@
exit 1;
},
help => sub { pod2usage(1); },
- ) or pod2usage(2);
+ ) or pod2usage(2);
- if (@ARGV) {
- pod2usage(
- -msg => "Unparseable arguments received: " . join(',', @ARGV),
- -exitval => 2,
- );
- }
+ if (@ARGV) {
+ pod2usage(
+ -msg => "Unparseable arguments received: " . join(',', @ARGV),
+ -exitval => 2,
+ );
+ }
- $config{class} ||= 'Module::Starter';
+ $config{class} ||= 'Module::Starter';
- $config{builder} = ['ExtUtils::MakeMaker'] unless @{$config{builder}};
+ $config{builder} = ['ExtUtils::MakeMaker'] unless $config{builder};
- eval "require $config{class};";
- croak "invalid starter class $config{class}: $@" if $@;
- $config{class}->import(@{$config{plugins}});
+ return %config;
+}
- $config{class}->create_distro( %config );
+=head2 run
- print "Created starter directories and files\n";
+ Module::Starter::App->run;
+
+This is equivalent to running F<module-starter>. Its behavior is still subject
+to change.
+
+=cut
+
+sub run {
+ my $class = shift;
+ my %config = $class->_config_read;
+
+ %config = $class->_process_command_line(%config);
+
+ eval "require $config{class};";
+ croak "Could not load starter class $config{class}: $@" if $@;
+ $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;
Modified: trunk/libmodule-starter-perl/lib/Module/Starter/BuilderSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/lib/Module/Starter/BuilderSet.pm?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/lib/Module/Starter/BuilderSet.pm (original)
+++ trunk/libmodule-starter-perl/lib/Module/Starter/BuilderSet.pm Sat Apr 9 20:54:07 2011
@@ -11,11 +11,11 @@
=head1 VERSION
-Version 1.54
-
-=cut
-
-our $VERSION = '1.54';
+Version 1.56
+
+=cut
+
+our $VERSION = '1.56';
=head1 SYNOPSIS
@@ -33,6 +33,10 @@
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
@@ -54,42 +58,45 @@
{
'Module::Build' =>
{
- file => "Build.PL",
- build_method => "create_Build_PL",
- build_deps => [],
- instructions => [ 'perl Build.PL',
- './Build',
- './Build test',
- './Build install',
- ],
+ 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 => [],
- instructions => [ 'perl Makefile.PL',
- 'make',
- 'make test',
- 'make 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_deps => [ { command => 'make',
- aliases => [ 'make', 'gmake' ],
- },
- { command => 'chmod',
- aliases => [ 'chmod' ],
- },
- ],
- instructions => [ 'perl Makefile.PL',
- 'make',
- 'make test',
- 'make install',
- ],
+ 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',
+ ],
}
};
@@ -186,6 +193,19 @@
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) >>
Modified: trunk/libmodule-starter-perl/lib/Module/Starter/Plugin/Template.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/lib/Module/Starter/Plugin/Template.pm?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/lib/Module/Starter/Plugin/Template.pm (original)
+++ trunk/libmodule-starter-perl/lib/Module/Starter/Plugin/Template.pm Sat Apr 9 20:54:07 2011
@@ -10,11 +10,11 @@
=head1 VERSION
-Version 1.54
-
-=cut
-
-our $VERSION = '1.54';
+Version 1.56
+
+=cut
+
+our $VERSION = '1.56';
=head1 SYNOPSIS
Modified: trunk/libmodule-starter-perl/lib/Module/Starter/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/lib/Module/Starter/Simple.pm?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/lib/Module/Starter/Simple.pm (original)
+++ trunk/libmodule-starter-perl/lib/Module/Starter/Simple.pm Sat Apr 9 20:54:07 2011
@@ -1,8 +1,10 @@
package 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 );
@@ -15,11 +17,11 @@
=head1 VERSION
-Version 1.54
-
-=cut
-
-our $VERSION = '1.54';
+Version 1.56
+
+=cut
+
+our $VERSION = '1.56';
=head1 SYNOPSIS
@@ -36,6 +38,42 @@
=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<create_distro>, 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 ephemperal objects created during the execution of the class
+method C<create_distro> 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<Module::Starter>.
@@ -43,10 +81,11 @@
=cut
sub create_distro {
- my $class = shift;
-
- my $self = $class->new( @_ );
-
+ 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;
@@ -80,31 +119,31 @@
push @files, $self->create_Changes;
push @files, $self->create_README( $build_results{instructions} );
- push @files, 'MANIFEST';
- $self->create_MANIFEST( grep { $_ ne 't/boilerplate.t' } @files );
+
+ $self->create_MANIFEST( $build_results{'manifest_method'} );
+ # TODO: put files to ignore in a more standard form?
+ # XXX: no need to return the files created
return;
}
-=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<create_distro>, 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 ephemperal objects created during the execution of the class
-method C<create_distro> above.
+=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
@@ -289,6 +328,22 @@
02111-1307 USA.
EOT
},
+ {
+ license => 'apache',
+ 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<http://www.apache.org/licenses/LICENSE-2.0>
+
+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
+ },
];
}
@@ -371,7 +426,7 @@
sub _reference_links {
return (
{ nickname => 'RT',
- title => 'CPAN\'s request tracker',
+ title => 'CPAN\'s request tracker (report bugs here)',
link => 'http://rt.cpan.org/NoAuth/Bugs.html?Dist=%s',
},
{ nickname => 'AnnoCPAN',
@@ -459,6 +514,7 @@
(my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g;
return <<"HERE";
+use 5.006;
use strict;
use warnings;
use ExtUtils::MakeMaker;
@@ -560,6 +616,7 @@
(my $author = "$self->{author} <$self->{email}>") =~ s/'/\'/g;
return <<"HERE";
+use 5.006;
use strict;
use warnings;
use Module::Build;
@@ -572,6 +629,9 @@
build_requires => {
'Test::More' => 0,
},
+ requires => {
+ 'perl' => 5.006,
+ },
add_to_cleanup => [ '$self->{distro}-*' ],
create_makefile_pl => 'traditional',
);
@@ -811,7 +871,7 @@
my $nmodules = @modules;
my $main_module = $modules[0];
my $use_lines = join(
- "\n", map { qq{ use_ok( '$_' ) || print "Bail out!\n";} } @modules
+ "\n", map { qq{ use_ok( '$_' ) || print "Bail out!\\n";} } @modules
);
$t_files{'00-load.t'} = <<"HERE";
@@ -834,6 +894,7 @@
$t_files{'boilerplate.t'} = <<"HERE";
#!perl -T
+use 5.006;
use strict;
use warnings;
use Test::More tests => $boilerplate_tests;
@@ -911,64 +972,120 @@
return "t/$filename";
}
-=head2 create_MANIFEST( @files )
+=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 = shift;
- my @files = @_;
-
+ my ( $self, $manifest_method ) = @_;
my $fname = File::Spec->catfile( $self->{basedir}, 'MANIFEST' );
- $self->create_file( $fname, $self->MANIFEST_guts(@files) );
+
+ $self->$manifest_method();
+ $self->filter_lines_in_file(
+ $fname,
+ qr/^t\/boilerplate\.t$/,
+ qr/^ignore\.txt$/,
+ );
+
$self->progress( "Created $fname" );
return 'MANIFEST';
}
-=head2 MANIFEST_guts( @files )
-
-This method is called by C<create_MANIFEST>, and returns content for the
-MANIFEST file.
-
-=cut
-
-sub MANIFEST_guts {
- my $self = shift;
- my @files = sort @_;
-
- return join( "\n", @files, '' );
-}
-
-=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 {
+=head2 get_builders( )
+
+This methods gets the correct builder(s).
+
+It is called by C<create_build>, 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};
+ 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) );
- }
-
+ 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
@@ -979,6 +1096,7 @@
my @build_instructions;
my @files;
+ my $manifest_method;
foreach my $builder ( @builders ) {
if ( !@build_instructions ) {
@@ -997,12 +1115,15 @@
push( @build_instructions, join("\n", map { "\t$_" } @commands) );
my $build_method = $builder_set->method_for_builder($builder);
- $self->$build_method($self->{main_module})
+ $self->$build_method($self->{main_module});
+
+ $manifest_method = $builder_set->manifest_method($builder);
}
return(
- files => [ @files ],
- instructions => join( "\n\n", @build_instructions ),
+ files => [ @files ],
+ instructions => join( "\n\n", @build_instructions ),
+ manifest_method => $manifest_method,
);
}
@@ -1111,6 +1232,39 @@
return;
}
+=head2 filter_lines_in_file( $filename, @compiled_regexes )
+
+C<filter_lines_in_file> goes over a file and removes lines with the received
+regexes.
+
+For example, removing t/boilerplate.t in the MANIFEST.
+
+=cut
+
+sub filter_lines_in_file {
+ my ( $self, $file, @regexes ) = @_;
+ my @read_lines;
+ open my $fh, '<', $file or die "Can't open file $file: $!\n";
+ @read_lines = <$fh>;
+ close $fh or die "Can't close file $file: $!\n";
+
+ chomp @read_lines;
+
+ open $fh, '>', $file or die "Can't open file $file: $!\n";
+ foreach my $line (@read_lines) {
+ my $found;
+
+ foreach my $regex (@regexes) {
+ if ( $line =~ $regex ) {
+ $found++;
+ }
+ }
+
+ $found or print {$fh} "$line\n";
+ }
+ close $fh or die "Can't close file $file: $!\n";
+}
+
=head1 BUGS
Please report any bugs or feature requests to
@@ -1120,13 +1274,17 @@
=head1 AUTHOR
+Sawyer X, C<< <xsawyerx at cpan.org> >>
+
Andy Lester, C<< <andy at petdance.com> >>
C.J. Adams-Collier, C<< <cjac at colliertech.org> >>
=head1 Copyright & License
-Copyright 2005-2007 Andy Lester and C.J. Adams-Collier, All Rights Reserved.
+Copyright 2005-2009 Andy Lester 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.
@@ -1143,8 +1301,9 @@
my $content = <<"HERE";
package $module;
+use 5.006;
+use strict;
use warnings;
-use strict;
\=head1 NAME
Modified: trunk/libmodule-starter-perl/t/test-dist.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-starter-perl/t/test-dist.t?rev=72426&op=diff
==============================================================================
--- trunk/libmodule-starter-perl/t/test-dist.t (original)
+++ trunk/libmodule-starter-perl/t/test-dist.t Sat Apr 9 20:54:07 2011
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 471;
+use Test::More tests => 545;
use Module::Starter;
use File::Spec;
@@ -353,6 +353,22 @@
02111-1307 USA.
EOF
],
+ 'apache' =>
+ [
+ split(/\n\n+/, <<"EOF")
+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<http://www.apache.org/licenses/LICENSE-2.0>
+
+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.
+EOF
+ ],
};
return @{$texts->{$self->_license()}};
@@ -369,7 +385,7 @@
# TEST:$cnt++;
$self->parse(
- qr/\Apackage \Q$perl_name\E;\n\nuse warnings;\nuse strict;\n\n/ms,
+ qr/\Apackage \Q$perl_name\E;\n\nuse 5.006;\nuse strict;\nuse warnings;\n\n/ms,
'start',
);
@@ -628,7 +644,7 @@
);
# TEST
- $build_pl->parse(qr{\Ause strict;\nuse warnings;\nuse Module::Build;\n\n}ms,
+ $build_pl->parse(qr{\Ause 5.006;\nuse strict;\nuse warnings;\nuse Module::Build;\n\n}ms,
"Build.PL - Standard stuff at the beginning"
);
@@ -660,6 +676,12 @@
# TEST
$build_pl->parse(
+ qr/\A\s*requires => \{\n *\Q'perl' => 5.006\E,\n\s*\},\n/ms,
+ "Build.PL - Build Requires",
+ );
+
+ # TEST
+ $build_pl->parse(
qr/\A\s*add_to_cleanup *=> \Q[ 'MyModule-Test-*' ],\E\n/ms,
"Build.PL - add_to_cleanup",
);
@@ -680,13 +702,13 @@
);
# TEST
- $manifest->consume(<<'EOF', 'MANIFEST - Contents');
+ $manifest->consume(<<"EOF", 'MANIFEST - Contents');
Build.PL
Changes
-MANIFEST
-README
lib/MyModule/Test.pm
lib/MyModule/Test/App.pm
+MANIFEST\t\t\tThis list of files
+README
t/00-load.t
t/manifest.t
t/pod-coverage.t
@@ -1028,7 +1050,7 @@
);
# TEST
- $makefile_pl->parse(qr{\Ause strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
+ $makefile_pl->parse(qr{\Ause 5.006;\nuse strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
"Makefile.PL - Standard stuff at the beginning"
);
@@ -1076,15 +1098,15 @@
}
);
- my $contents = <<'EOF';
+ my $contents = <<"EOF";
Changes
-MANIFEST
-Makefile.PL
-README
lib/Book/Park/Mansfield.pm
lib/Book/Park/Mansfield/Base.pm
lib/Book/Park/Mansfield/FannyPrice.pm
lib/JAUSTEN/Utils.pm
+Makefile.PL
+MANIFEST\t\t\tThis list of files
+README
t/00-load.t
t/manifest.t
t/pod-coverage.t
@@ -1229,7 +1251,7 @@
);
# TEST
- $makefile_pl->parse(qr{\Ause strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
+ $makefile_pl->parse(qr{\Ause 5.006;\nuse strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
"Makefile.PL - Standard stuff at the beginning"
);
@@ -1277,15 +1299,15 @@
}
);
- my $contents = <<'EOF';
+ my $contents = <<"EOF";
Changes
-MANIFEST
-Makefile.PL
-README
lib/Book/Park/Mansfield.pm
lib/Book/Park/Mansfield/Base.pm
lib/Book/Park/Mansfield/FannyPrice.pm
lib/JAUSTEN/Utils.pm
+Makefile.PL
+MANIFEST\t\t\tThis list of files
+README
t/00-load.t
t/manifest.t
t/pod-coverage.t
@@ -1430,7 +1452,7 @@
);
# TEST
- $makefile_pl->parse(qr{\Ause strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
+ $makefile_pl->parse(qr{\Ause 5.006;\nuse strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
"Makefile.PL - Standard stuff at the beginning"
);
@@ -1478,15 +1500,15 @@
}
);
- my $contents = <<'EOF';
+ my $contents = <<"EOF";
Changes
-MANIFEST
-Makefile.PL
-README
lib/Book/Park/Mansfield.pm
lib/Book/Park/Mansfield/Base.pm
lib/Book/Park/Mansfield/FannyPrice.pm
lib/JAUSTEN/Utils.pm
+Makefile.PL
+MANIFEST\t\t\tThis list of files
+README
t/00-load.t
t/manifest.t
t/pod-coverage.t
@@ -1804,6 +1826,207 @@
}
}
+{
+ my $module_base_dir =
+ File::Spec->catdir("t", "data", "apache-Book-Park-Mansfield")
+ ;
+
+ Module::Starter->create_distro(
+ distro => 'Book-Park-Mansfield',
+ modules => [
+ 'Book::Park::Mansfield',
+ 'Book::Park::Mansfield::Base',
+ 'Book::Park::Mansfield::FannyPrice',
+ 'JAUSTEN::Utils',
+ ],
+ dir => $module_base_dir,
+ builder => 'ExtUtils::MakeMaker',
+ license => 'apache',
+ author => 'Jane Austen',
+ email => 'jane.austen at writers.tld',
+ verbose => 0,
+ force => 0,
+ );
+
+ {
+ my $readme = TestParseFile->new(
+ {
+ fn => File::Spec->catfile($module_base_dir, "README"),
+ }
+ );
+
+ # TEST
+ $readme->parse(qr{\ABook-Park-Mansfield\n\n}ms,
+ 'Starts with the package name',
+ );
+
+ # TEST
+ $readme->parse(qr{\AThe README is used to introduce the module and provide instructions.*?\n\n}ms,
+ 'README used to introduce',
+ );
+
+ # TEST
+ $readme->parse(
+ qr{\AA README file is required for CPAN modules since CPAN extracts the.*?\n\n\n}ms,
+ 'A README file is required',
+ );
+
+ # TEST
+ $readme->parse(qr{\A\n*INSTALLATION\n\nTo install this module, run the following commands:\n\n\s+\Qperl Makefile.PL\E\n\s+\Qmake\E\n\s+\Qmake test\E\n\s+\Qmake install\E\n\n},
+ 'INSTALLATION section',
+ );
+
+ # TEST
+ $readme->parse(qr{\ASUPPORT AND DOCUMENTATION\n\nAfter installing.*?^\s+perldoc Book::Park::Mansfield\n\n}ms,
+ 'Support and docs 1'
+ );
+
+ # TEST
+ $readme->parse(qr{\AYou can also look for information at:\n\n\s+RT[^\n]+\n\s+\Qhttp://rt.cpan.org/NoAuth/Bugs.html?Dist=Book-Park-Mansfield\E\n\n}ms,
+ 'README - RT'
+ );
+ }
+
+ {
+ my $makefile_pl = TestParseFile->new(
+ {
+ fn => File::Spec->catfile($module_base_dir, "Makefile.PL"),
+ }
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\Ause 5.006;\nuse strict;\nuse warnings;\nuse ExtUtils::MakeMaker;\n\n}ms,
+ "Makefile.PL - Standard stuff at the beginning"
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A.*NAME *=> *'Book::Park::Mansfield',\n}ms,
+ "Makefile.PL - NAME",
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A\s*AUTHOR *=> *\Qq{Jane Austen <jane.austen\E\@\Qwriters.tld>},\E\n}ms,
+ "Makefile.PL - AUTHOR",
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A\s*VERSION_FROM *=> *\Q'lib/Book/Park/Mansfield.pm',\E\n}ms,
+ "Makefile.PL - VERSION_FROM",
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A\s*ABSTRACT_FROM *=> *\Q'lib/Book/Park/Mansfield.pm',\E\n}ms,
+ "Makefile.PL - ABSTRACT_FROM",
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A\s*\(\$ExtUtils::MakeMaker::VERSION \>= \d+\.\d+\n\s*\? \(\s*'LICENSE'\s*=>\s*'apache'\s*\)\n\s*:\s*\(\s*\)\)\s*,\n}ms,
+ "Makefile.PL - LICENSE",
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A\s*PL_FILES *=> *\{\},\n}ms,
+ "Makefile.PL - PL_FILES",
+ );
+
+ # TEST
+ $makefile_pl->parse(qr{\A\s*PREREQ_PM *=> *\{\n\s*'Test::More' *=> *0,\n\s*\},\n}ms,
+ "Makefile.PL - PREREQ_PM",
+ );
+
+ }
+
+ {
+ my $manifest = TestParseFile->new(
+ {
+ fn => File::Spec->catfile($module_base_dir, 'MANIFEST'),
+ }
+ );
+
+ my $contents = <<"EOF";
+Changes
+lib/Book/Park/Mansfield.pm
+lib/Book/Park/Mansfield/Base.pm
+lib/Book/Park/Mansfield/FannyPrice.pm
+lib/JAUSTEN/Utils.pm
+Makefile.PL
+MANIFEST\t\t\tThis list of files
+README
+t/00-load.t
+t/manifest.t
+t/pod-coverage.t
+t/pod.t
+EOF
+
+ # TEST
+ $manifest->consume(
+ $contents,
+ "MANIFEST for Makefile.PL'ed Module",
+ );
+
+ # TEST
+ $manifest->is_end("MANIFEST - that's all folks!");
+ }
+
+ {
+ my $mod1 = TestParseModuleFile->new(
+ {
+ fn => File::Spec->catfile(
+ $module_base_dir, qw(lib Book Park Mansfield.pm),
+ ),
+ perl_name => 'Book::Park::Mansfield',
+ dist_name => 'Book-Park-Mansfield',
+ author_name => 'Jane Austen',
+ license => 'apache',
+ }
+ );
+
+ # TEST*$parse_module_start_num_tests
+ $mod1->parse_module_start();
+
+ }
+
+ {
+ my $jausten_mod = TestParseModuleFile->new(
+ {
+ fn => File::Spec->catfile(
+ $module_base_dir, qw(lib JAUSTEN Utils.pm),
+ ),
+ perl_name => 'JAUSTEN::Utils',
+ dist_name => 'Book-Park-Mansfield',
+ author_name => 'Jane Austen',
+ license => 'apache',
+ }
+ );
+
+ # TEST*$parse_module_start_num_tests
+ $jausten_mod->parse_module_start();
+ }
+
+ {
+ my $mod2 = TestParseModuleFile->new(
+ {
+ fn => File::Spec->catfile(
+ $module_base_dir, qw(lib Book Park Mansfield Base.pm),
+ ),
+ perl_name => 'Book::Park::Mansfield::Base',
+ dist_name => 'Book-Park-Mansfield',
+ author_name => 'Jane Austen',
+ license => 'apache',
+ }
+ );
+
+ # TEST*$parse_module_start_num_tests
+ $mod2->parse_module_start();
+
+ }
+
+ my $files_list;
+ if (!$ENV{'DONT_DEL_APACHE'}) {
+ rmtree ($module_base_dir, {result => \$files_list});
+ }
+}
+
=head1 NAME
More information about the Pkg-perl-cvs-commits
mailing list