r30801 - in /branches/upstream/libmodule-starter-perl/current: ./ lib/Module/ lib/Module/Starter/ lib/Module/Starter/Plugin/ t/
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Wed Feb 18 12:31:04 UTC 2009
Author: dmn
Date: Wed Feb 18 12:31:00 2009
New Revision: 30801
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=30801
Log:
[svn-upgrade] Integrating new upstream version, libmodule-starter-perl (1.500)
Added:
branches/upstream/libmodule-starter-perl/current/getting-started.html
branches/upstream/libmodule-starter-perl/current/t/test-dist.t
Modified:
branches/upstream/libmodule-starter-perl/current/Changes
branches/upstream/libmodule-starter-perl/current/MANIFEST
branches/upstream/libmodule-starter-perl/current/META.yml
branches/upstream/libmodule-starter-perl/current/lib/Module/Starter.pm
branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/App.pm
branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/BuilderSet.pm
branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Plugin/Template.pm
branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Simple.pm
Modified: branches/upstream/libmodule-starter-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/Changes?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/Changes (original)
+++ branches/upstream/libmodule-starter-perl/current/Changes Wed Feb 18 12:31:00 2009
@@ -1,7 +1,15 @@
Revision history for Perl extension Module::Starter
+1.50 Tue Oct 28 00:27:37 CDT 2008
+ * Added Perl Training Australia's getting-started.html
+
+ * Add license setting to default Makefile.PL output (Thanks, Gabor!)
+
+ * Fixed the RT link in the boilerplate. (Thanks, Shlomi)
+
+
1.46 Fri Nov 9 18:36 America/New_York 2007
- [ENHANCEMENTS
+ [ENHANCEMENTS]
* add Module::Install compat for ::Template plugin
* boilerplate.t no longer appears in default MANIFEST
* META.yml no longer appears in default MANIFEST
Modified: branches/upstream/libmodule-starter-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/MANIFEST?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/MANIFEST (original)
+++ branches/upstream/libmodule-starter-perl/current/MANIFEST Wed Feb 18 12:31:00 2009
@@ -1,7 +1,9 @@
+Changes
+getting-started.html
+MANIFEST
+Makefile.PL
README
-MANIFEST
-Changes
-Makefile.PL
+
bin/module-starter
lib/Module/Starter.pm
lib/Module/Starter/App.pm
@@ -13,6 +15,7 @@
t/pod-coverage.t
t/pod.t
t/module-starter.t
+t/test-dist.t
t/BuilderSet.t
t/lib/Module/Starter/TestPlugin.pm
t/data/templates/Module.pm
@@ -25,5 +28,4 @@
t/data/templates/Build.PL
t/data/templates/README
perlcriticrc
-
META.yml Module meta-data (added by MakeMaker)
Modified: branches/upstream/libmodule-starter-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/META.yml?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/META.yml (original)
+++ branches/upstream/libmodule-starter-perl/current/META.yml Wed Feb 18 12:31:00 2009
@@ -1,9 +1,11 @@
--- #YAML:1.0
name: Module-Starter
-version: 1.470
+version: 1.50
abstract: a simple starter kit for any module
license: perl
-generated_by: ExtUtils::MakeMaker version 6.36_01
+author:
+ - Andy Lester <andy at petdance.com>
+generated_by: ExtUtils::MakeMaker version 6.44
distribution_type: module
requires:
ExtUtils::Command: 0
@@ -14,7 +16,5 @@
Test::Pod: 1.22
Test::Pod::Coverage: 1.08
meta-spec:
- url: http://module-build.sourceforge.net/META-spec-v1.2.html
- version: 1.2
-author:
- - Andy Lester <andy at petdance.com>
+ url: http://module-build.sourceforge.net/META-spec-v1.3.html
+ version: 1.3
Added: branches/upstream/libmodule-starter-perl/current/getting-started.html
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/getting-started.html?rev=30801&op=file
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/getting-started.html (added)
+++ branches/upstream/libmodule-starter-perl/current/getting-started.html Wed Feb 18 12:31:00 2009
@@ -1,0 +1,235 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>
+Perl Training Australia -
+Starting a module with Module::Starter</title>
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <link rel="stylesheet" type="text/css" href="/pta.css" />
+
+<link rel="alternate" title="Atom" href="/tips/index.atom" type="application/atom+xml" />
+
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+ </head>
+ <body>
+
+<h1>
+
+Starting a module with Module::Starter
+</h1>
+
+
+
+
+<p>
+<a href="http://perltraining.com.au/tips/"><b>[ Perl tips index] </b></a><br />
+<a href="http://perltraining.com.au/tips/cgi-bin/mailman/listinfo/perl-tips"><b>[ Subscribe to Perl tips ]</b></a>
+</p>
+
+
+<p>Starting a new module can be a lot of work. A good module should have
+a build system, documentation, a test suite, and numerous other bits
+and pieces to assist in its easy packaging and development. These are
+useful even if we never release our module to CPAN.</p>
+<p>Setting this up can be a lot of work, especially if you've never done
+it before. While the <code>h2xs</code> tool that comes with Perl will do some
+of this for you, it's showing its age, and doesn't allow us to take
+advantage of recent tools. We want to spend our time writing code,
+not trying to decode our build system.</p>
+<p>That's where <code>Module::Starter</code> comes in handy. It provides
+a simple, command-line tool to create a skeleton module quickly and
+easily.</p>
+
+<!-- END_SUMMARY -->
+
+<h2>Using module-starter</h2>
+<p>Before we can build our module, we need to install <code>Module::Starter</code>
+from the CPAN. <code>Module::Starter</code> allows us to choose from a variety
+of build frameworks, from the aging <code>ExtUtils::MakeMaker</code> to
+<code>Module::Install</code> and <code>Module::Build</code>. While <code>ExtUtils::MakeMaker</code>
+comes standard with Perl, you may need to install the other build
+frameworks. At Perl Training Australia we generally use
+<code>Module::Install</code>.</p>
+<p>Creating a module with <code>Module::Starter</code> couldn't be easier. On
+the command line we simply write:</p>
+<pre>
+ module-starter --module=My::Module --author="Jane Smith"
+ --email=jane.smith at example.com --builder=Module::Install</pre>
+<p>The module name, author, and e-mail switches are all required.
+We've used the optional <code>--builder</code> switch to specify we want
+to use <code>Module::Install</code> as our build-system, instead of
+the default <code>ExtUtils::MakeMaker</code>.</p>
+<p>Once this is done, you should have a <code>My-Module</code> directory with a
+skeleton module inside.</p>
+<p>
+</p>
+<h2>A skeleton tour</h2>
+<p>If you've never created a module before, or you've been making them
+by hand, then it's nice to take a look at what you get for your
+<code>Module::Starter</code> skeleton.</p>
+<pre>
+ $ ls -la</pre>
+<pre>
+ total 8
+ drwxr-xr-x 4 pjf pjf 0 Jul 4 16:59 .
+ drwxr-xr-x 51 pjf pjf 0 Jul 4 16:59 ..
+ -rw-r--r-- 1 pjf pjf 96 Jul 4 16:59 .cvsignore
+ -rw-r--r-- 1 pjf pjf 109 Jul 4 16:59 Changes
+ -rw-r--r-- 1 pjf pjf 90 Jul 4 16:59 MANIFEST
+ -rw-r--r-- 1 pjf pjf 183 Jul 4 16:59 Makefile.PL
+ -rw-r--r-- 1 pjf pjf 1378 Jul 4 16:59 README
+ drwxr-xr-x 3 pjf pjf 0 Jul 4 16:59 lib
+ drwxr-xr-x 2 pjf pjf 0 Jul 4 16:59 t</pre>
+<p>Let's look at each of these files in turn:</p>
+<dl>
+<dt><strong>.cvsignore</strong></dt>
+
+<dd>
+<p><code>Module::Starter</code> assumes you'll be using CVS for revision control, and
+provides a <em>.cvsignore</em> file with the names of files that are auto-generated
+and not to be tracked with revision control. At Perl Training Australia
+we use git for new projects, and so we rename this to <em>.gitignore</em>.</p>
+</dd>
+<dt><strong>Changes</strong></dt>
+
+<dd>
+<p>This is a human-readable file tracking module revisions and changes.
+If you're going to release your code to the CPAN, it's essential for
+your users to know what has changed in each release. Even if you're
+only using your code internally, this is a good place to document the
+history of your project.</p>
+</dd>
+<dt><strong>MANIFEST</strong></dt>
+
+<dd>
+<p>The <em>MANIFEST</em> file tracks all the files that should be packaged when
+you run a <code>make tardist</code> to distribute your module. Normally it
+includes your source code, any file needed for the build system,
+a <em>META.yml</em> that contains module meta-data (usually auto-generated
+by your build system), tests, documentation, and anything else that
+you want your end-user to have.</p>
+</dd>
+<dd>
+<p>If you don't want to manually worry about adding entries to the
+<em>MANIFEST</em> file yourself, most build systems (including
+<code>Module::Install</code>) allow you to write <code>make manifest</code> to auto-generate
+it. For this to work, you'll want to make a <em>MANIFEST.skip</em> file
+which contains filenames and regular expressions that match files
+which should be excluded from the <em>MANIFEST</em>.</p>
+</dd>
+<dt><strong>Makefile.PL</strong></dt>
+
+<dd>
+<p>This is the front-end onto our build system. When we wish to build,
+test, or install our module, we'll always invoke <em>Makefile.PL</em> first:</p>
+</dd>
+<dd>
+<pre>
+ perl Makefile.PL
+ make
+ make test
+ make install</pre>
+</dd>
+<dd>
+<p>Most build systems will provide a <code>make tardist</code> target for
+building a tarball of all the files in our <em>MANIFEST</em>, a
+<code>make disttest</code> for making sure our tests work with only the
+<em>MANIFEST</em> listed files, and <code>make clean</code> and <code>make distclean</code>
+targets for clearing up auto-generated files, including those
+from the build system itself if a <code>make distclean</code> is run.</p>
+</dd>
+<dd>
+<p>You'll almost certainly wish to customise your <em>Makefile.PL</em> a little,
+especially if your module has dependencies. You'll want to consult
+your build system documentation for what options you can uses. For
+<code>Module::Install</code> this documentation can be found at
+<a href="http://search.cpan.org/perldoc?Module::Install">http://search.cpan.org/perldoc</a>.</p>
+</dd>
+<dt><strong>README</strong></dt>
+
+<dd>
+<p>The <em>README</em> file should contain basic information for someone thinking
+of installing your module. Mentioning dependencies, how to build, and
+how to find/report bugs are all good things to mention in the <em>README</em>
+file. Some systems (including the CPAN) will extract the <em>README</em>
+and make it available separate from the main distribution.</p>
+</dd>
+<dt><strong>lib/</strong></dt>
+
+<dd>
+<p>The <em>lib/</em> directory will contain your skeleton module, and is
+where you'll be doing much of your work. <code>Module::Starter</code> will
+have already added some skeleton documentation, a version number,
+and some skeleton functions.</p>
+</dd>
+<dd>
+<p>You can add more modules to the <em>lib/</em> directory if you wish. Splitting
+a very large module into smaller, logical pieces can significantly
+improve maintainability.</p>
+</dd>
+<dt><strong>t/</strong></dt>
+
+<dd>
+<p>The <em>t/</em> directory contains all the tests that will be executed
+when you run a <code>make test</code>. By default, <code>Module::Starter</code> will
+provide some simple tests to ensure that your module compiles, that
+you'll filled in relevant sections of the boilerplate documentation,
+and that your documentation covers all your subroutines and doesn't
+contain any syntax errors.</p>
+</dd>
+<dd>
+<p>If you're new to testing in Perl, then you should start by reading
+the <code>Test::Tutorial</code> at <a href="http://search.cpan.org/perldoc?Test::Tutorial">http://search.cpan.org/perldoc</a>.</p>
+</dd>
+<dd>
+<p>At Perl Training Australia, we usually add a test based on
+<code>Test::Perl::Critic</code> <a href="http://search.cpan.org/perldoc?Test::Perl::Critic">http://search.cpan.org/perldoc</a>
+to encourage good coding practices, and <code>Test::Kwalitee</code>
+<a href="http://search.cpan.org/perldoc?Test::Kwalittee">http://search.cpan.org/perldoc</a> to catch common
+mistakes that are made in distributions.</p>
+</dd>
+<dd>
+<p>Ideally when developing your module, the more tests you have, the better.
+If you already have a test suite and you're wondering which parts of
+your code are not being tested, you can use the excellent
+<code>Devel::Cover</code> tool from <a href="http://search.cpan.org/perldoc?Devel::Cover">http://search.cpan.org/perldoc</a>.</p>
+</dd>
+</dl>
+
+<p>
+<a href="http://perltraining.com.au/tips/"><b>[ Perl tips index ] </b></a><br />
+<a href="http://perltraining.com.au/cgi-bin/mailman/listinfo/perl-tips"><b>[ Subscribe to Perl tips ]</b></a>
+</p>
+
+<hr />
+
+<p>
+This Perl tip and associated text is copyright Perl Training
+Australia. You may freely distribute this text so long as it is
+distributed in full with this Copyright noticed attached.
+</p>
+<p>
+If you have any questions please don't hesitate to contact us:
+</p>
+<table>
+<tbody><tr>
+<td>Email: </td><td>contact at perltraining.com.au</td>
+</tr>
+<tr>
+<td>Phone: </td><td>03 9354 6001 (Australia)</td>
+</tr>
+<tr>
+<td>International: </td><td>+61 3 9354 6001</td>
+</tr>
+</tbody></table>
+
+
+<p id="copyright">Copyright 2001-2008 Perl Training Australia. Contact us at <a href="mailto:contact at perltraining.com.au">contact at perltraining.com.au</a></p>
+
+
+</body>
+</html>
+
+
+
Modified: branches/upstream/libmodule-starter-perl/current/lib/Module/Starter.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/lib/Module/Starter.pm?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/lib/Module/Starter.pm (original)
+++ branches/upstream/libmodule-starter-perl/current/lib/Module/Starter.pm Wed Feb 18 12:31:00 2009
@@ -11,11 +11,11 @@
=head1 VERSION
-version 1.470
+version 1.50
=cut
-our $VERSION = '1.470';
+our $VERSION = '1.50';
=head1 SYNOPSIS
Modified: branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/App.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/App.pm?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/App.pm (original)
+++ branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/App.pm Wed Feb 18 12:31:00 2009
@@ -7,7 +7,7 @@
=cut
-our $VERSION = '1.470';
+our $VERSION = '1.50';
use Getopt::Long;
use Pod::Usage;
Modified: branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/BuilderSet.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/BuilderSet.pm?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/BuilderSet.pm (original)
+++ branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/BuilderSet.pm Wed Feb 18 12:31:00 2009
@@ -12,27 +12,27 @@
=head1 VERSION
-Version 1.470
-
-=cut
-
-our $VERSION = '1.470';
+Version 1.50
+
+=cut
+
+our $VERSION = '1.50';
=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);
+ 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);
=head1 DESCRIPTION
Modified: branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Plugin/Template.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Plugin/Template.pm?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Plugin/Template.pm (original)
+++ branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Plugin/Template.pm Wed Feb 18 12:31:00 2009
@@ -11,13 +11,11 @@
=head1 VERSION
-Version 1.470
-
- $Id: Template.pm 54 2007-02-06 22:04:46Z andy $
-
-=cut
-
-our $VERSION = '1.470';
+Version 1.50
+
+=cut
+
+our $VERSION = '1.50';
=head1 SYNOPSIS
Modified: branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Simple.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Simple.pm?rev=30801&op=diff
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Simple.pm (original)
+++ branches/upstream/libmodule-starter-perl/current/lib/Module/Starter/Simple.pm Wed Feb 18 12:31:00 2009
@@ -16,17 +16,17 @@
=head1 VERSION
-Version 1.470
-
-=cut
-
-our $VERSION = '1.470';
+Version 1.50
+
+=cut
+
+our $VERSION = '1.50';
=head1 SYNOPSIS
- use Module::Starter qw(Module::Starter::Simple);
-
- Module::Starter->create_distro(%args);
+ use Module::Starter qw(Module::Starter::Simple);
+
+ Module::Starter->create_distro(%args);
=head1 DESCRIPTION
@@ -253,7 +253,7 @@
link => 'http://cpanratings.perl.org/d/%s',
},
{ title => 'Search CPAN',
- link => 'http://search.cpan.org/dist/%s',
+ link => 'http://search.cpan.org/dist/%s/',
},
);
}
@@ -339,6 +339,9 @@
AUTHOR => '$author',
VERSION_FROM => '$main_pm_file',
ABSTRACT_FROM => '$main_pm_file',
+ (\$ExtUtils::MakeMaker::VERSION >= 6.3002
+ ? ('LICENSE'=> '$self->{license}')
+ : ()),
PL_FILES => {},
PREREQ_PM => {
'Test::More' => 0,
@@ -371,6 +374,7 @@
name '$self->{distro}';
all_from '$main_pm_file';
author '$author';
+license '$self->{license}';
build_requires 'Test::More';
@@ -990,7 +994,7 @@
my $module = shift;
my $rtname = shift;
- my $bug_email = "bug-$rtname at rt.cpan.org";
+ my $bug_email = "bug-\L$self->{distro}\E at rt.cpan.org";
my $bug_link =
"http://rt.cpan.org/NoAuth/ReportBug.html?Queue=$self->{distro}";
@@ -1016,7 +1020,7 @@
You can find documentation for this module with the perldoc command.
- perldoc $self->{main_module}
+ perldoc $module
];
my @reference_links = _reference_links();
Added: branches/upstream/libmodule-starter-perl/current/t/test-dist.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libmodule-starter-perl/current/t/test-dist.t?rev=30801&op=file
==============================================================================
--- branches/upstream/libmodule-starter-perl/current/t/test-dist.t (added)
+++ branches/upstream/libmodule-starter-perl/current/t/test-dist.t Wed Feb 18 12:31:00 2009
@@ -1,0 +1,644 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 61;
+
+use Module::Starter;
+use File::Spec;
+use File::Path;
+use Carp;
+
+sub chomp_me {
+ my $string = shift;
+ chomp($string);
+ return $string;
+}
+
+package TestParseFile;
+
+use Test::More;
+
+sub new {
+ my $class = shift;
+ my $self = {};
+
+ bless $self, $class;
+
+ $self->_init(@_);
+
+ return $self;
+}
+
+sub _filename {
+ my $self = shift;
+
+ $self->{_filename} = shift if @_;
+
+ return $self->{_filename};
+}
+
+sub _text {
+ my $self = shift;
+
+ $self->{_text} = shift if @_;
+
+ return $self->{_text};
+}
+
+sub _init {
+ my ($self, $args) = @_;
+
+ $self->_filename($args->{fn});
+
+ $self->_text(_slurp_to_ref($self->_filename()));
+
+ return;
+}
+
+sub _slurp_to_ref {
+ my $filename = shift;
+ my $text;
+
+ local $/;
+ open my $in, '<', $filename
+ or Carp::confess( "Cannot open file $filename: $!" );
+ $text = <$in>;
+ close($in);
+
+ return \$text;
+}
+
+sub parse {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my ($self, $re, $msg) = @_;
+
+ my $verdict = ok (scalar(${$self->_text()} =~ s{$re}{}ms), $self->format_msg($msg));
+
+ if ( !$verdict ) {
+ diag("Filename == " . $self->_filename());
+ }
+
+ return $verdict;
+}
+
+sub consume {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my ($self, $prefix, $msg) = @_;
+
+ my $verdict =
+ is( substr(${$self->_text()}, 0, length($prefix)),
+ $prefix,
+ $self->format_msg($msg));
+
+ if ($verdict) {
+ ${$self->_text()} = substr(${$self->_text()}, length($prefix));
+ }
+ else {
+ diag("Filename == " . $self->_filename());
+ }
+
+ return $verdict;
+}
+
+sub is_end {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my ($self, $msg) = @_;
+
+ my $verdict = is (${$self->_text()}, "", $self->format_msg($msg));
+
+ if ( !$verdict ) {
+ diag("Filename == " . $self->_filename());
+ }
+
+ return $verdict;
+}
+
+=head2 $file_parser->parse_paras(\@paras, $message)
+
+Parse the paragraphs paras. Paras can either be strings, in which case
+they'll be considered plain texts. Or they can be hash refs with the key
+'re' pointing to a regex string.
+
+Here's an example:
+
+ my @synopsis_paras = (
+ '=head1 SYNOPSIS',
+ 'Quick summary of what the module does.',
+ 'Perhaps a little code snippet.',
+ { re => q{\s*} . quotemeta(q{use MyModule::Test;}), },
+ { re => q{\s*} .
+ quotemeta(q{my $foo = MyModule::Test->new();})
+ . q{\n\s*} . quotemeta("..."), },
+ );
+
+ $mod1->parse_paras(
+ \@synopsis_paras,
+ 'MyModule::Test - SYNOPSIS',
+ );
+
+=cut
+
+sub parse_paras {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+
+ my ($self, $paras, $msg) = @_;
+
+ # Construct a large regex.
+ my $regex =
+ join '',
+ map { $_.q{\n\n+} }
+ map { (ref($_) eq 'HASH') ? $_->{re} : quotemeta($_) }
+ @{$paras};
+
+ return $self->parse(
+ $regex,
+ $msg,
+ );
+}
+
+sub format_msg {
+ my ($self, $msg) = @_;
+
+ return $msg;
+}
+
+package TestParseModuleFile;
+
+use vars qw(@ISA);
+
+ at ISA = qw(TestParseFile);
+
+sub _perl_name {
+ my $self = shift;
+
+ $self->{_perl_name} = shift if @_;
+
+ return $self->{_perl_name};
+}
+
+sub _dist_name {
+ my $self = shift;
+
+ $self->{_dist_name} = shift if @_;
+
+ return $self->{_dist_name};
+}
+
+sub _init {
+ my ($self, $args) = @_;
+
+ $self->SUPER::_init($args);
+
+ $self->_perl_name($args->{perl_name});
+
+ $self->_dist_name($args->{dist_name});
+
+ return;
+}
+
+sub format_msg {
+ my ($self, $msg) = @_;
+
+ return $self->_perl_name() . " - $msg";
+}
+
+# TEST:$cnt=0;
+sub parse_module_start {
+ my $self = shift;
+
+ my $perl_name = $self->_perl_name();
+ my $dist_name = $self->_dist_name();
+ my $lc_dist_name = lc($dist_name);
+
+ # TEST:$cnt++;
+ $self->parse(
+ qr/\Apackage \Q$perl_name\E;\n\nuse warnings;\nuse strict;\n\n/ms,
+ "start",
+ );
+
+ {
+ my $s1 = qq{$perl_name - The great new $perl_name!};
+
+ # TEST:$cnt++;
+ $self->parse(
+ qr/\A=head1 NAME\n\n\Q$s1\E\n\n/ms,
+ 'NAME Pod.',
+ );
+ }
+
+ # TEST:$cnt++;
+ $self->parse(
+ qr/\A=head1 VERSION\n\nVersion 0\.01\n\n=cut\n\nour \$VERSION = '0\.01';\n+/,
+ 'module version',
+ );
+
+ {
+ my @synopsis_paras =
+ (
+ '=head1 SYNOPSIS',
+ 'Quick summary of what the module does.',
+ 'Perhaps a little code snippet.',
+ { re => q{\s*} . quotemeta(qq{use $perl_name;}), },
+ { re => q{\s*} .
+ quotemeta(q{my $foo = } . $perl_name . q{->new();})
+ . q{\n\s*} . quotemeta("..."),
+ },
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ \@synopsis_paras,
+ 'SYNOPSIS',
+ );
+ }
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 EXPORT',
+ (
+"A list of functions that can be exported. You can delete this section\n"
+. "if you don't export anything, such as for a purely object-oriented module."
+ ),
+ ],
+ 'EXPORT',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 FUNCTIONS',
+ '=head2 function1',
+ '=cut',
+ "sub function1 {\n}",
+ ],
+ 'function1',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head2 function2',
+ '=cut',
+ "sub function2 {\n}",
+ ],
+ 'function2',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 AUTHOR',
+ { re => q{Baruch Spinoza[^\n]+} },
+ ],
+ 'AUTHOR',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 BUGS',
+ { re =>
+ q/Please report any bugs.*C<bug-/
+ . quotemeta($lc_dist_name)
+ . q/ at rt\.cpan\.org>.*changes\./
+ },
+ ],
+ 'BUGS',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 SUPPORT',
+ { re => q/You can find documentation for this module.*/ },
+ { re => q/\s+perldoc / . quotemeta($perl_name), },
+ 'You can also look for information at:',
+ '=over 4',
+ ],
+ 'Support 1',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ { re => q/=item \* RT:[^\n]*/, },
+ "L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=$dist_name>",
+ ],
+ 'Support - RT',
+ );
+
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ { re => q/=item \* AnnoCPAN:[^\n]*/, },
+ "L<http://annocpan.org/dist/$dist_name>",
+ ],
+ 'AnnoCPAN',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ { re => q/=item \* CPAN Ratings[^\n]*/, },
+ "L<http://cpanratings.perl.org/d/$dist_name>",
+ ],
+ 'CPAN Ratings',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ { re => q/=item \* Search CPAN[^\n]*/, },
+ "L<http://search.cpan.org/dist/$dist_name/>",
+ ],
+ 'CPAN Ratings',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=back',
+ ],
+ 'Support - =back',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 ACKNOWLEDGEMENTS',
+ ],
+ 'acknowledgements',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=head1 COPYRIGHT & LICENSE',
+ { re => q/Copyright \d+ Baruch Spinoza, all rights reserved\./ },
+ ::chomp_me(<<'EOF'),
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+EOF
+ ],
+ 'copyright',
+ );
+
+ # TEST:$cnt++
+ $self->parse_paras(
+ [
+ '=cut',
+ ],
+ '=cut POD end',
+ );
+
+ # TEST:$cnt++
+ $self->consume(
+ qq{1; # End of $perl_name},
+ 'End of module',
+ );
+
+ return;
+}
+
+# TEST:$parse_module_start_num_tests=$cnt;
+
+package main;
+
+
+{
+ my $module_base_dir = File::Spec->catdir('t', 'data', 'MyModule-Test');
+
+ Module::Starter->create_distro(
+ distro => 'MyModule-Test',
+ modules => ['MyModule::Test', 'MyModule::Test::App'],
+ dir => $module_base_dir,
+ builder => 'Module::Build',
+ license => 'perl',
+ author => 'Baruch Spinoza',
+ email => 'spinoza at philosophers.tld',
+ verbose => 0,
+ force => 0,
+ );
+
+ {
+ my $readme = TestParseFile->new( {
+ fn => File::Spec->catfile($module_base_dir, 'README'),
+ });
+
+ # TEST
+ $readme->parse(qr{\AMyModule-Test\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 Build.PL\E\n\s+\Q./Build\E\n\s+\Q./Build test\E\n\s+\Q./Build install\E\n\n},
+ 'INSTALLATION section',
+ );
+
+ # TEST
+ $readme->parse(qr{\ASUPPORT AND DOCUMENTATION\n\nAfter installing.*?^\s+perldoc MyModule::Test\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=MyModule-Test\E\n\n}ms,
+ 'README - RT'
+ );
+ }
+
+ {
+ my $build_pl = TestParseFile->new(
+ {
+ fn => File::Spec->catfile($module_base_dir, "Build.PL"),
+ }
+ );
+
+ # TEST
+ $build_pl->parse(qr{\Ause strict;\nuse warnings;\nuse Module::Build;\n\n}ms,
+ 'Build.PL - Standard stuff at the beginning'
+ );
+
+ # TEST
+ $build_pl->parse(qr{\A.*module_name *=> *'MyModule::Test',\n}ms,
+ 'Build.PL - module_name',
+ );
+
+ # TEST
+ $build_pl->parse(qr{\A\s*license *=> *'perl',\n}ms,
+ 'Build.PL - license',
+ );
+
+ # TEST
+ $build_pl->parse(qr{\A\s*dist_author *=> *\Q'Baruch Spinoza <spinoza\E\@\Qphilosophers.tld>',\E\n}ms,
+ 'Build.PL - dist_author',
+ );
+
+ # TEST
+ $build_pl->parse(qr{\A\s*dist_version_from *=> *\Q'lib/MyModule/Test.pm',\E\n}ms,
+ 'Build.PL - dist_version_from',
+ );
+
+ # TEST
+ $build_pl->parse(
+ qr/\A\s*build_requires => \{\n *\Q'Test::More' => 0\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',
+ );
+
+ # TEST
+ $build_pl->parse(
+ qr/\A\s*create_makefile_pl *=> \Q'traditional',\E\n/ms,
+ 'Build.PL - create_makefile_pl',
+ );
+
+ }
+
+ {
+ my $manifest = TestParseFile->new( {
+ fn => File::Spec->catfile($module_base_dir, 'MANIFEST'),
+ } );
+
+ # TEST
+ $manifest->consume(<<'EOF', 'MANIFEST - Contents');
+Build.PL
+Changes
+MANIFEST
+README
+lib/MyModule/Test.pm
+lib/MyModule/Test/App.pm
+t/00-load.t
+t/pod-coverage.t
+t/pod.t
+EOF
+
+ # TEST
+ $manifest->is_end("MANIFEST - that's all folks!");
+ }
+
+ {
+ my $pod_t = TestParseFile->new( {
+ fn => File::Spec->catfile($module_base_dir, 't', 'pod.t'),
+ } );
+
+ my $minimal_test_pod = "1.22";
+ # TEST
+ $pod_t->consume(<<"EOF", 'pod.t - contents');
+#!perl -T
+
+use strict;
+use warnings;
+use Test::More;
+
+# Ensure a recent version of Test::Pod
+my \$min_tp = $minimal_test_pod;
+eval "use Test::Pod \$min_tp";
+plan skip_all => "Test::Pod \$min_tp required for testing POD" if \$\@;
+
+all_pod_files_ok();
+EOF
+
+ # TEST
+ $pod_t->is_end("pod.t - end.");
+ }
+
+ {
+ my $pc_t = TestParseFile->new( {
+ fn => File::Spec->catfile( $module_base_dir, 't', 'pod-coverage.t' )
+ } );
+
+ # TEST
+ $pc_t->parse(
+ qr/\Ause strict;\nuse warnings;\nuse Test::More;\n\n/ms,
+ 'pod-coverage.t - header',
+ );
+
+ my $l1 = q{eval "use Test::Pod::Coverage $min_tpc";};
+
+ # TEST
+ $pc_t->parse(
+ qr/\A# Ensure a recent[^\n]+\nmy \$min_tpc = \d+\.\d+;\n\Q$l1\E\nplan skip_all[^\n]+\n *if \$\@;\n\n/ms,
+ 'pod-coverage.t - min_tpc block',
+ );
+
+ $l1 = q{eval "use Pod::Coverage $min_pc";};
+ my $s1 = q{# Test::Pod::Coverage doesn't require a minimum };
+
+ # TEST
+ $pc_t->parse(
+ qr/\A\Q$s1\E[^\n]+\n# [^\n]+\nmy \$min_pc = \d+\.\d+;\n\Q$l1\E\nplan skip_all[^\n]+\n *if \$\@;\n\n/ms,
+ 'pod-coverage.t - min_pod_coverage block',
+ );
+
+ # TEST
+ $pc_t->parse(
+ qr/all_pod_coverage_ok\(\);\n/,
+ 'pod-coverage.t - all_pod_coverage_ok',
+ );
+
+ # TEST
+ $pc_t->is_end(
+ 'pod-coverage.t - EOF',
+ );
+ }
+
+ {
+ my $mod1 = TestParseModuleFile->new( {
+ fn => File::Spec->catfile( $module_base_dir, qw(lib MyModule Test.pm) ),
+ perl_name => 'MyModule::Test',
+ dist_name => 'MyModule-Test',
+ } );
+
+ # TEST*$parse_module_start_num_tests
+ $mod1->parse_module_start();
+
+ }
+
+ {
+ my $mod2 = TestParseModuleFile->new( {
+ fn => File::Spec->catfile( $module_base_dir, qw(lib MyModule Test App.pm) ),
+ perl_name => 'MyModule::Test::App',
+ dist_name => 'MyModule-Test',
+ } );
+
+ # TEST*$parse_module_start_num_tests
+ $mod2->parse_module_start();
+
+ }
+
+ my $files_list;
+ if (!$ENV{'DONT_DEL'}) {
+ rmtree ($module_base_dir, {result => \$files_list});
+ }
+}
+
+=head1 NAME
+
+t/test-dist.t - test the integrity of prepared distributions.
+
+=head1 AUTHOR
+
+Shlomi Fish, L<http://www.shlomifish.org/>
+
More information about the Pkg-perl-cvs-commits
mailing list