Subject: | Some small patches |
Hello,
First of all, thanks for writing this! I originally wanted to use
ReportVersions but felt it was too "heayweight" and ignored it. I saw
this pop up in my CPAN feed and decided to check it out.
It works nicely for me! However, I have a distaste of "no_plan" and
wanted to see the prereq versions I requested. Here's 2 patches for
those features.
I hope it isn't too much trouble to merge in my patches, thanks!
--
~Apocalypse
Subject: | no_noplan.patch |
diff -urbd Dist-Zilla-Plugin-ReportVersions-Tiny-1.00/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm
--- Dist-Zilla-Plugin-ReportVersions-Tiny-1.00/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm 2010-05-30 05:53:25.000000000 -0700
+++ Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm 2010-05-30 09:29:32.000000000 -0700
@@ -11,11 +11,23 @@
sub mvp_multivalue_args { qw{exclude} };
has exclude => (is => 'ro', isa => 'ArrayRef', default => sub { [] });
-
our $template = q{use strict;
use warnings;
-use Test::More 'no_plan'; # the safest way to avoid Test::NoWarnings breaking
- # our expectations is no_plan, not done_testing!
+
+# Smart loading of tests
+my $numtests;
+BEGIN {
+ $numtests = 1;
+
+ eval "use Test::NoWarnings";
+ if ( ! $@ ) {
+ # increment by one
+ $numtests++;
+
+ }
+}
+
+use Test::More tests => $numtests;
my $v = "\n";
Subject: | showversion.patch |
diff -urbd Dist-Zilla-Plugin-ReportVersions-Tiny-1.00/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm
--- Dist-Zilla-Plugin-ReportVersions-Tiny-1.00/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm 2010-05-30 05:53:25.000000000 -0700
+++ Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/lib/Dist/Zilla/Plugin/ReportVersions/Tiny.pm 2010-05-30 09:58:18.000000000 -0700
@@ -26,7 +26,8 @@
# Now, our module version dependencies:
sub pmver {
- my ($module) = @_;
+ my ($module,$wanted) = @_;
+ $wanted = " (want $wanted)";
my $pmver;
eval "require $module;";
if ($@) {
@@ -50,13 +51,12 @@
}
# So, we should be good, right?
- return sprintf('%-40s => %s%s', $module, $pmver, "\n");
+ return sprintf('%-40s => %-10s%-15s%s', $module, $pmver, $wanted, "\n");
}
{{
for my $module (@modules) {
- my $text = "eval { \$v .= pmver('${module}') };\n";
- $OUT .= $text;
+ $OUT .= "eval { \$v .= pmver('" . $module->[0] . "','" . $module->[1] . "') };\n";
}
}}
@@ -78,36 +78,33 @@
my ($self) = @_;
# Extract the set of modules we depend on.
- my @modules;
- {
my %modules;
my $prereq = $self->zilla->prereqs->as_string_hash;
+
for my $phase (keys %{ $prereq || {} }) {
for my $type (keys %{ $prereq->{$phase} || {} }) {
for my $module (keys %{ $prereq->{$phase}->{$type} || {} }) {
- $modules{$module} = 1;
+ next if exists $modules{$module} and $modules{$module} > $prereq->{$phase}->{$type}->{$module};
+
+ $modules{$module} = $prereq->{$phase}->{$type}->{$module};
}
}
}
- # This is all I ever really cared about.
- @modules = sort { lc($a) cmp lc($b) }
- grep {
- my $name = $_;
- my $found = grep { $name =~ m{$_} } @{ $self->exclude };
- $found == 0;
+ # cleanup
+ foreach my $module ( keys %modules ) {
+ if ( $module eq 'perl' or grep { $module =~ m{$_} } @{ $self->exclude } ) {
+ delete $modules{$module};
}
- grep { $_ ne 'perl' }
- keys %modules;
}
- return @modules;
+ return [ map { [ $_ => $modules{$_} ] } sort keys %modules ];
}
sub generate_test_from_prereqs {
my ($self) = @_;
my $content = $self->fill_in_string($template, {
- modules => [$self->applicable_modules]
+ modules => $self->applicable_modules
});
return $content;
Only in Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/: Makefile.old
diff -urbd Dist-Zilla-Plugin-ReportVersions-Tiny-1.00/t/exclude.t Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/t/exclude.t
--- Dist-Zilla-Plugin-ReportVersions-Tiny-1.00/t/exclude.t 2010-05-30 05:53:25.000000000 -0700
+++ Dist-Zilla-Plugin-ReportVersions-Tiny-1.00-MYVER/t/exclude.t 2010-05-30 10:01:39.000000000 -0700
@@ -34,15 +34,15 @@
{
$prereq = {
- testing => { requires => { baz => 1, quux => 1 } },
+ testing => { requires => { baz => 1, quux => 1, Moose => 5 } },
build => { requires => { baz => 2, foox => 1 } },
};
- my @modules;
- lives_ok { @modules = $rv->applicable_modules }
+ my $modules;
+ lives_ok { $modules = $rv->applicable_modules }
"we can collect the applicable modules for the distribution";
- eq_or_diff \@modules, [qw{baz foox quux}],
+ eq_or_diff $modules, [[baz => 2], [foox => 1], [quux => 1]],
"we collected the first round of modules as expected";
}