Permalink
Browse files

Learn to deal with "package String::Lookup 0.08"

  • Loading branch information...
1 parent 589f878 commit 269415087258d1eed26365852352af37a93ac651 @andk committed May 5, 2012
Showing with 50 additions and 3 deletions.
  1. +14 −3 lib/PAUSE/pmfile.pm
  2. +3 −0 t/data/pmfile/packages_per_pmfile.yaml
  3. +33 −0 t/lib/PAUSE/Test/pmfile.pm
View
@@ -2,6 +2,10 @@ use strict;
use warnings;
package PAUSE::pmfile;
use vars qw($AUTOLOAD);
+use version (); # to get $version::STRICT
+
+BEGIN { die "Version of version.pm too low ($version::VERSION), does not define STRICT"
+ unless defined $version::STRICT }
sub parent {
my($self) = @_;
@@ -187,6 +191,7 @@ sub packages_per_pmfile {
my $filemtime = $self->{MTIME};
my $version = $self->{VERSION};
+ $DB::single++;
open my $fh, "<", "$pmfile" or return $ppp;
local $/ = "\n";
@@ -209,16 +214,18 @@ sub packages_per_pmfile {
}
my $pkg;
+ my $strict_version;
if (
$pline =~ m{
(.*)
\bpackage\s+
([\w\:\']+)
\s*
- ( $ | [\}\;] )
+ (?: $ | [\}\;] | ($version::STRICT) )
}x) {
$pkg = $2;
+ $strict_version = $3;
if ($pkg eq "DB"){
# XXX if pumpkin and perl make him comaintainer! I
# think I always made the pumpkins comaint on DB
@@ -260,8 +267,12 @@ sub packages_per_pmfile {
}
}
} else {
- $ppp->{$pkg}{version} ||= "";
- $ppp->{$pkg}{version} ||= $version;
+ if (defined $strict_version){
+ $ppp->{$pkg}{version} = $strict_version ;
+ } else {
+ $ppp->{$pkg}{version} ||= "";
+ $ppp->{$pkg}{version} ||= $version;
+ }
local($^W)=0;
$ppp->{$pkg}{version} =
$version
@@ -0,0 +1,3 @@
+- [ "My::Dist", "package My::Dist;\nour $VERSION = '1234.56';\n", "0.02" ]
+- [ "My::Dist", "package My::Dist 0.08;\nour $VERSION = '1234.56';\n", "0.08" ]
+- [ "My::Dist", "package My::Dist 0.10;\nour $VERSION = '1234.56';\n", "0.10" ]
View
@@ -143,4 +143,37 @@ sub examine_fio :Test :Plan(3) {
);
}
+sub packages_per_pmfile :Test :Plan(3) {
+ my ($self,$pkg,$pm_content,$version) = @_;
+ # pass("playing around");
+ my $selfpmfile = $self->{pmfile};
+ my $pmfile = $self->fake_dist_dir->file('lib/My/Dist.pm')->stringify;
+ open my $fh, ">", $pmfile or die "Could not open > '$pmfile': $!";
+ print $fh $pm_content;
+ close $fh or die "Could not close > '$pmfile': $!";
+ $selfpmfile->{PMFILE} = $pmfile;
+ $selfpmfile->{MTIME} = "42";
+ $selfpmfile->{VERSION_FROM_META_OK} = 0;
+ # $selfpmfile->{VERSION} = $version;
+ my $ppp = $selfpmfile->packages_per_pmfile;
+ is ref $ppp, "HASH", "ppp is a HASH";
+ is join(" ",keys %$ppp), $pkg, "only key in ppp is '$pkg'";
+ delete $ppp->{$pkg}{pause_reg};
+ cmp_deeply(
+ $ppp->{$pkg},
+ { version => $version,
+ filemtime => 42,
+ infile => $pmfile,
+ simile => $pmfile,
+ parsed => 1,
+ },
+ "correct version in packages_per_pmfile: $version",
+ );
+}
+
1;
+
+#Local Variables:
+#mode: cperl
+#cperl-indent-level: 2
+#End:

0 comments on commit 2694150

Please sign in to comment.