Skip Menu |

This queue is for tickets about the Module-Metadata CPAN distribution.

Maintainer(s)' notes

Attention bug reporters: issues MUST include the version of Module::Metadata that you are running that exhibit the stated symptoms. thank you!

Report information
The Basics
Id: 87782
Status: resolved
Priority: 0/
Queue: Module-Metadata

People
Owner: ether [...] cpan.org
Requestors: RWSTAUNER [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.000014
Fixed in: 1.000022



Subject: Versions parsed from "package NAME VERSION" lines are not returned as objects
I didn't see it specified in the documentation that the version() method should return a version object, but i added a test and confirmed that in all cases except for the package NAME VERSION line it does, so it seemed like an oversight.
Subject: 0001-Test-that-version-returns-an-object.patch
From bffab7bdffe7da6cd16d741834a11a7983e30360 Mon Sep 17 00:00:00 2001 From: Randy Stauner <rwstauner@cpan.org> Date: Sun, 11 Aug 2013 15:28:42 -0700 Subject: [PATCH 1/2] Test that version() returns an object which fails for package NAME VERSION lines. --- t/metadata.t | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/t/metadata.t b/t/metadata.t index 286b1ae..7e82e82 100644 --- a/t/metadata.t +++ b/t/metadata.t @@ -252,7 +252,9 @@ package Simple-Edward; ); my %pkg_names = reverse @pkg_names; -plan tests => 54 + (2 * keys( %modules )) + (2 * keys( %pkg_names )); +plan tests => 54 + (2 * keys( %modules )) + + (grep { defined } values( %modules )) + + (2 * keys( %pkg_names )); require_ok('Module::Metadata'); @@ -322,6 +324,7 @@ foreach my $module ( sort keys %modules ) { my $errs; my $got = $pm_info->version; if ( defined $expected ) { + isa_ok($got, 'version') or diag $module; ok( $got eq $expected, "correct module version (expected '$expected')" ) or $errs++; -- 1.7.9.5
Subject: 0002-Return-version-objects-from-package-NAME-VERSION.patch
From 283df20efa63f52f4ac5a5e7b8a627a8d69d5abf Mon Sep 17 00:00:00 2001 From: Randy Stauner <rwstauner@cpan.org> Date: Sun, 11 Aug 2013 15:56:43 -0700 Subject: [PATCH 2/2] Return version objects from package NAME VERSION Fixes previously added test. --- lib/Module/Metadata.pm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/Module/Metadata.pm b/lib/Module/Metadata.pm index 0a15924..8dd51a8 100644 --- a/lib/Module/Metadata.pm +++ b/lib/Module/Metadata.pm @@ -582,9 +582,16 @@ sub _parse_fh { if ( $line =~ /$PKG_REGEXP/o ) { $pkg = $1; + my $v = $2; push( @pkgs, $pkg ) unless grep( $pkg eq $_, @pkgs ); - $vers{$pkg} = $2 unless exists( $vers{$pkg} ); - $need_vers = defined $2 ? 0 : 1; + $need_vers = defined $v ? 0 : 1; + + unless( exists( $vers{$pkg} ) ){ + # Upgrade to a version object. + $v = $self->_dwim_version_or_croak($v, $line) + if defined $v; + $vers{$pkg} = $v; + } # VERSION defined with full package spec, i.e. $Module::VERSION } elsif ( $vers_fullname && $vers_pkg ) { @@ -680,12 +687,7 @@ sub _evaluate_version_line { if $@; # Upgrade it into a version object - my $version = eval { _dwim_version($result) }; - - croak "Version '$result' from $self->{filename} does not appear to be valid:\n$eval\n\nThe fatal error was: $@\n" - unless defined $version; # "0" is OK! - - return $version; + return $self->_dwim_version_or_croak($result, $eval); } } @@ -744,6 +746,16 @@ sub _evaluate_version_line { return $version; } + + sub _dwim_version_or_croak { + my ($self, $input, $code) = @_; + my $version = eval { _dwim_version($input) }; + + croak "Version '$input' from $self->{filename} does not appear to be valid:\n$code\n\nThe fatal error was: $@\n" + unless defined $version; # "0" is OK! + + return $version; + } } ############################################################ -- 1.7.9.5
Thanks! this was released today in 1.000022.