Permalink
Browse files

use Module::Metadata for better handling of version and package extra…

…ction.
  • Loading branch information...
1 parent a72e5ee commit 41f576aa34a1af29fb9c0041544cd07f6d56a6aa @miyagawa miyagawa committed Dec 11, 2011
Showing with 8 additions and 16 deletions.
  1. +1 −0 Makefile.PL
  2. +7 −16 bin/cpan-outdated
View
@@ -10,6 +10,7 @@ WriteMakefile(
'local::lib' => 1.006008,
'ExtUtils::MakeMaker' => 6.56,
'CPAN::DistnameInfo' => 0.10,
+ 'Module::Metadata' => 1.000007,
},
EXE_FILES => ['bin/cpan-outdated'],
MIN_PERL_VERSION => '5.008001',
View
23 bin/cpan-outdated 100644 → 100755
@@ -3,14 +3,14 @@ use strict;
use warnings;
use Getopt::Long;
use Pod::Usage;
-use ExtUtils::MakeMaker;
use File::Temp;
use File::Spec;
use Config;
use version;
use LWP::Simple ();
use IO::Zlib;
use CPAN::DistnameInfo;
+use Module::Metadata;
use constant WIN32 => $^O eq 'MSWin32';
our $VERSION = "0.18";
@@ -89,9 +89,12 @@ sub main {
}
$dist_latest_version{$info->dist} = $info->version;
- my $inst_version = parse_version($path);
- $inst_version =~ s/\s+//; # workaround for Attribute::Params::Validate
- next if $inst_version eq 'undef';
+ my $meta = do {
+ local $SIG{__WARN__} = sub {};
+ Module::Metadata->new_from_file($path);
+ };
+ my $inst_version = $meta->version($pkg);
+ next unless defined $inst_version;
if (compare_version($inst_version, $version)) {
next if $seen{$dist}++;
if ($verbose) {
@@ -131,18 +134,6 @@ sub permissive_filter {
$_;
}
-sub parse_version {
- my $path = shift;
- local $SIG{__WARN__} = sub {
- # This is workaround for EU::MM's issue.
- # following one-liner makes too long warnings.
- # perl -e 'use ExtUtils::MM; MM->parse_version("/usr/local/app/perl-5.10.1/lib/site_perl/5.10.1/Authen/Simple/Apache.pm")'
- return if @_ && $_[0] =~ /^Could not eval/;
- CORE::warn(@_);
- };
- MM->parse_version($path);
-}
-
# taken from cpanminus
sub which {
my($name) = @_;

0 comments on commit 41f576a

Please sign in to comment.