[libdist-zilla-plugin-test-podspelling-perl] 03/07: delay calling distmeta until filemunging phase
Axel Beckert
abe at deuxchevaux.org
Mon May 25 10:05:09 UTC 2015
This is an automated email from the git hooks/post-receive script.
abe pushed a commit to annotated tag 2.006003
in repository libdist-zilla-plugin-test-podspelling-perl.
commit bf70f634ee60ded452cfd3c69495a41c12941b89
Author: Karen Etheridge <ether at cpan.org>
Date: Sat Feb 22 20:01:32 2014 -0800
delay calling distmeta until filemunging phase
---
Changes | 2 ++
dist.ini | 3 ++
lib/Dist/Zilla/Plugin/Test/PodSpelling.pm | 54 ++++++++++++++++++++-----------
t/attributes.t | 10 ++++--
t/contributors.t | 10 ++++--
t/dashed.t | 10 ++++--
t/file.t | 6 +++-
7 files changed, 66 insertions(+), 29 deletions(-)
diff --git a/Changes b/Changes
index 08d85e4..b7eabe6 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,8 @@
Revision history for Perl extension {{$dist->name}}
{{$NEXT}}
+ - prevent distmeta from being populated too early by postponing
+ calling it until the file munging phase
2.006002 2013-12-19
- fix problem with compile tests stalling on windows (chorny) GH #20
diff --git a/dist.ini b/dist.ini
index 5d7aa9a..617205b 100644
--- a/dist.ini
+++ b/dist.ini
@@ -15,6 +15,7 @@ Test::Spelling = 0.12
[@Filter]
-bundle = @Basic
-remove = Readme
+ -remove = ExtraTests
[AutoPrereqs]
@@ -53,6 +54,8 @@ Test::Spelling = 0.12
filenames = dist.ini
filenames = weaver.ini
+[ExtraTests]
+
[Git::Remote::Check]
[ContributorsFromGit]
[@Git]
diff --git a/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm b/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm
index cdb6623..285a840 100644
--- a/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm
+++ b/lib/Dist/Zilla/Plugin/Test/PodSpelling.pm
@@ -8,6 +8,7 @@ use warnings;
use Moose;
extends 'Dist::Zilla::Plugin::InlineFiles';
with (
+ 'Dist::Zilla::Role::FileMunger',
'Dist::Zilla::Role::TextTemplate',
'Dist::Zilla::Role::FileFinderUser' => {
default_finders => [ ':InstallModules' ],
@@ -67,8 +68,23 @@ sub add_stopword {
return;
}
-around add_file => sub {
- my ($orig, $self, $file) = @_;
+sub munge_files {
+ my ($self) = @_;
+
+ my $data = $self->merged_section_data;
+ return unless $data and %$data;
+
+ for my $file (@{ $self->zilla->files }) {
+ next unless exists $data->{$file->name};
+
+ $self->munge_file($file);
+ }
+ return;
+}
+
+sub munge_file {
+ my ($self, $file) = @_;
+
my ($set_spell_cmd, $add_stopwords, $stopwords);
if ($self->spell_cmd) {
$set_spell_cmd = sprintf "set_spell_cmd('%s');", $self->spell_cmd;
@@ -97,26 +113,24 @@ around add_file => sub {
$stopwords = join "\n", '__DATA__', $self->uniq_stopwords;
}
- $self->$orig(
- Dist::Zilla::File::InMemory->new(
- { name => $file->name,
- content => $self->fill_in_string(
- $file->content,
- {
- name => __PACKAGE__,
- version => __PACKAGE__->VERSION
- || 'bootstrapped version',
- wordlist => \$self->wordlist,
- set_spell_cmd => \$set_spell_cmd,
- add_stopwords => \$add_stopwords,
- stopwords => \$stopwords,
- directories => \$self->print_directories,
- },
- ),
+ $file->content(
+ $self->fill_in_string(
+ $file->content,
+ {
+ name => __PACKAGE__,
+ version => __PACKAGE__->VERSION
+ || 'bootstrapped version',
+ wordlist => \$self->wordlist,
+ set_spell_cmd => \$set_spell_cmd,
+ add_stopwords => \$add_stopwords,
+ stopwords => \$stopwords,
+ directories => \$self->print_directories,
}
),
);
-};
+
+ return;
+}
__PACKAGE__->meta->make_immutable;
no Moose;
@@ -190,6 +204,8 @@ generated POD document. The same goes for contributors listed under the
=begin Pod::Coverage
mvp_multivalue_args
+munge_files
+munge_file
=end Pod::Coverage
diff --git a/t/attributes.t b/t/attributes.t
index b1e8710..a12abe6 100644
--- a/t/attributes.t
+++ b/t/attributes.t
@@ -3,6 +3,7 @@ use strict;
use warnings;
use Test::More 0.88;
use Test::DZil;
+use Path::Tiny;
# test the file content generated when various attributes are set
@@ -17,6 +18,7 @@ sub get_content {
{ dist_root => 'corpus/foo' },
{
add_files => {
+ 'source/lib/Spell/Checked.pm' => "package Spell::Checked;\n1;\n",
'source/dist.ini' => dist_ini(
{
name => 'Spell-Checked',
@@ -26,15 +28,17 @@ sub get_content {
author => $author,
copyright_holder => $author,
},
+ [GatherDir =>],
[$name => $args],
)
}
}
);
- my $plugin = $zilla->plugin_named($name);
- $plugin->gather_files;
- return $zilla->files->[0]->content;
+ $zilla->build;
+ my $build_dir = $zilla->tempdir->subdir('build');
+ my $file = path($build_dir, 'xt', 'author', 'pod-spell.t');
+ return $file->slurp_utf8;
}
my $content = get_content({});
diff --git a/t/contributors.t b/t/contributors.t
index e4fb2f1..efede56 100644
--- a/t/contributors.t
+++ b/t/contributors.t
@@ -4,6 +4,7 @@ use warnings;
use Test::More 0.88;
use Test::Requires 'Dist::Zilla::Plugin::Meta::Contributors';
use Test::DZil;
+use Path::Tiny;
# test the file content generated gets contributor
@@ -20,6 +21,7 @@ sub get_content {
{ dist_root => 'corpus/foo' },
{
add_files => {
+ 'source/lib/Spell/Checked.pm' => "package Spell::Checked;\n1;\n",
'source/dist.ini' => dist_ini(
{
name => 'Spell-Checked',
@@ -29,6 +31,7 @@ sub get_content {
author => 'John Doe <jdoe at example.com>',
copyright_holder => 'John Doe <jdoe at example.com>'
},
+ [GatherDir =>],
[$name => $args],
['Meta::Contributors',
{
@@ -40,9 +43,10 @@ sub get_content {
}
);
- my $plugin = $zilla->plugin_named($name);
- $plugin->gather_files;
- return $zilla->files->[0]->content;
+ $zilla->build;
+ my $build_dir = $zilla->tempdir->subdir('build');
+ my $file = path($build_dir, 'xt', 'author', 'pod-spell.t');
+ return $file->slurp_utf8;
}
my $content = get_content({});
diff --git a/t/dashed.t b/t/dashed.t
index 5c14030..fb74c56 100644
--- a/t/dashed.t
+++ b/t/dashed.t
@@ -3,6 +3,7 @@ use strict;
use warnings;
use Test::More 0.88;
use Test::DZil;
+use Path::Tiny;
# test the file content generated when various attributes are set
@@ -20,6 +21,7 @@ sub get_content {
{ dist_root => 'corpus/foo' },
{
add_files => {
+ 'source/lib/Spell/Checked.pm' => "package Spell::Checked;\n1;\n",
'source/dist.ini' => dist_ini(
{
name => 'Spell-Checked',
@@ -29,15 +31,17 @@ sub get_content {
author => $author,
copyright_holder => $author,
},
+ [GatherDir =>],
[$name => $args],
)
}
}
);
- my $plugin = $zilla->plugin_named($name);
- $plugin->gather_files;
- return $zilla->files->[0]->content;
+ $zilla->build;
+ my $build_dir = $zilla->tempdir->subdir('build');
+ my $file = path($build_dir, 'xt', 'author', 'pod-spell.t');
+ return $file->slurp_utf8;
}
my $content = get_content({});
diff --git a/t/file.t b/t/file.t
index 2dbaf94..5589d45 100644
--- a/t/file.t
+++ b/t/file.t
@@ -11,7 +11,11 @@ my $tzil
},
{
add_files => {
- 'source/dist.ini' => simple_ini(['Test::PodSpelling'])
+ 'source/lib/Foo.pm' => "package Foo;\n1;\n",
+ 'source/dist.ini' => simple_ini(
+ [ GatherDir => ],
+ ['Test::PodSpelling']
+ )
}
},
);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-plugin-test-podspelling-perl.git
More information about the Pkg-perl-cvs-commits
mailing list