[libdist-zilla-plugin-test-eol-perl] 06/18: refactor [EOLTests] to use [Test::EOL], via overriding the new "filename" configuration option
Intrigeri
intrigeri at moszumanska.debian.org
Sun Aug 16 09:20:13 UTC 2015
This is an automated email from the git hooks/post-receive script.
intrigeri pushed a commit to annotated tag 0.13
in repository libdist-zilla-plugin-test-eol-perl.
commit 70cdacee4d8c89985a5426942e0eb07905b6acc6
Author: Karen Etheridge <ether at cpan.org>
Date: Sun Oct 12 16:44:22 2014 -0700
refactor [EOLTests] to use [Test::EOL], via overriding the new "filename" configuration option
---
Changes | 1 +
lib/Dist/Zilla/Plugin/EOLTests.pm | 33 ++------------------
lib/Dist/Zilla/Plugin/Test/EOL.pm | 63 ++++++++++++++++++++++++++-------------
3 files changed, 46 insertions(+), 51 deletions(-)
diff --git a/Changes b/Changes
index 688fc87..a882580 100644
--- a/Changes
+++ b/Changes
@@ -3,6 +3,7 @@ Revision history for {{$dist->name}}
{{$NEXT}}
- Dist::Zilla::Plugin::EOLTests and Dist::Zilla::Plugin::Test::EOL are
now combined into one distribution, Dist-Zilla-Plugin-Test-EOL
+ - add "filename" configuration option
0.12 2014-04-10
- readd Test::EOL prereq that was accidentally removed when moving to
diff --git a/lib/Dist/Zilla/Plugin/EOLTests.pm b/lib/Dist/Zilla/Plugin/EOLTests.pm
index ba8c88b..b819c23 100644
--- a/lib/Dist/Zilla/Plugin/EOLTests.pm
+++ b/lib/Dist/Zilla/Plugin/EOLTests.pm
@@ -6,8 +6,7 @@ use namespace::autoclean;
# VERSION
-extends 'Dist::Zilla::Plugin::InlineFiles';
-with 'Dist::Zilla::Role::TextTemplate';
+extends 'Dist::Zilla::Plugin::Test::EOL';
=head1 DESCRIPTION
@@ -26,36 +25,10 @@ L<Test::EOL/all_perl_files_ok>. It defaults to C<1>.
=cut
-has trailing_whitespace => (
- is => 'ro',
- isa => 'Bool',
- default => 1,
+has '+filename' => (
+ default => sub { return 'xt/release/eol.t' },
);
-around add_file => sub {
- my ($orig, $self, $file) = @_;
- return $self->$orig(
- Dist::Zilla::File::InMemory->new({
- name => $file->name,
- content => $self->fill_in_string(
- $file->content,
- { trailing_ws => \$self->trailing_whitespace },
- ),
- }),
- );
-};
-
__PACKAGE__->meta->make_immutable;
1;
-
-__DATA__
-___[ xt/release/eol.t ]___
-use strict;
-use warnings;
-use Test::More;
-
-eval 'use Test::EOL';
-plan skip_all => 'Test::EOL required' if $@;
-
-all_perl_files_ok({ trailing_whitespace => {{ $trailing_ws }} });
diff --git a/lib/Dist/Zilla/Plugin/Test/EOL.pm b/lib/Dist/Zilla/Plugin/Test/EOL.pm
index d97368d..a3c29ef 100644
--- a/lib/Dist/Zilla/Plugin/Test/EOL.pm
+++ b/lib/Dist/Zilla/Plugin/Test/EOL.pm
@@ -1,12 +1,16 @@
package Dist::Zilla::Plugin::Test::EOL;
use Moose;
+use Sub::Exporter::ForMethods 'method_installer';
+use Data::Section 0.004 # fixed header_re
+ { installer => method_installer }, '-setup';
use namespace::autoclean;
# VERSION
-extends 'Dist::Zilla::Plugin::InlineFiles';
-with 'Dist::Zilla::Role::TextTemplate';
-
+with
+ 'Dist::Zilla::Role::FileGatherer',
+ 'Dist::Zilla::Role::TextTemplate',
+;
has trailing_whitespace => (
is => 'ro',
@@ -14,23 +18,34 @@ has trailing_whitespace => (
default => 1,
);
-around add_file => sub {
- my ($orig, $self, $file) = @_;
- return $self->$orig(
- Dist::Zilla::File::InMemory->new({
- name => $file->name,
- content => $self->fill_in_string(
- $file->content,
- {
- name => __PACKAGE__,
- version => __PACKAGE__->VERSION
- || 'bootstrapped version',
- trailing_ws => \$self->trailing_whitespace
- },
- ),
- }),
- );
-};
+has filename => (
+ is => 'ro', isa => 'Str',
+ lazy => 1,
+ default => sub { return 'xt/author/test-eol.t' },
+);
+
+sub gather_files
+{
+ my $self = shift;
+
+ require Dist::Zilla::File::InMemory;
+
+ $self->add_file(
+ Dist::Zilla::File::InMemory->new(
+ name => $self->filename,
+ content => $self->fill_in_string(
+ ${$self->section_data('__TEST__')},
+ {
+ name => __PACKAGE__,
+ version => __PACKAGE__->VERSION
+ || 'bootstrapped version',
+ trailing_ws => \$self->trailing_whitespace
+ },
+ ),
+ )
+ );
+ return;
+}
__PACKAGE__->meta->make_immutable;
@@ -62,6 +77,12 @@ L<Test::EOL/all_perl_files_ok>. It defaults to C<1>.
What this option is going to do is test for the lack of trailing whitespace at
the end of the lines (also known as "trailing space").
+=head2 C<filename>
+
+The filename of the test to add - defaults to F<xt/author/test-eol.t>.
+
+=for Pod::Coverage gather_files
+
=head1 ACKNOWLEDGMENTS
This module is a fork of L<Dist::Zilla::Plugin::EOLTests> and was originally
@@ -72,7 +93,7 @@ be Author tests.
=cut
__DATA__
-___[ xt/author/test-eol.t ]___
+___[ __TEST__ ]___
use strict;
use warnings;
use Test::More;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libdist-zilla-plugin-test-eol-perl.git
More information about the Pkg-perl-cvs-commits
mailing list