summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlperl/lib/Module/Metadata.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlperl/lib/Module/Metadata.pm')
-rw-r--r--Master/tlpkg/tlperl/lib/Module/Metadata.pm59
1 files changed, 42 insertions, 17 deletions
diff --git a/Master/tlpkg/tlperl/lib/Module/Metadata.pm b/Master/tlpkg/tlperl/lib/Module/Metadata.pm
index f7017cf90ff..7f49da6d59a 100644
--- a/Master/tlpkg/tlperl/lib/Module/Metadata.pm
+++ b/Master/tlpkg/tlperl/lib/Module/Metadata.pm
@@ -1,6 +1,6 @@
# -*- mode: cperl; tab-width: 8; indent-tabs-mode: nil; basic-offset: 2 -*-
-# vim:ts=8:sw=2:et:sta:sts=2
-package Module::Metadata; # git description: v1.000030-2-g52f466c
+# vim:ts=8:sw=2:et:sta:sts=2:tw=78
+package Module::Metadata; # git description: v1.000032-7-gb4e8a3f
# ABSTRACT: Gather package and POD information from perl module files
# Adapted from Perl-licensed code originally distributed with
@@ -14,7 +14,7 @@ sub __clean_eval { eval $_[0] }
use strict;
use warnings;
-our $VERSION = '1.000031'; # TRIAL
+our $VERSION = '1.000033';
use Carp qw/croak/;
use File::Spec;
@@ -411,15 +411,29 @@ sub _init {
}
$self->_parse_fh($handle);
+ @{$self->{packages}} = __uniq(@{$self->{packages}});
+
unless($self->{module} and length($self->{module})) {
- my ($v, $d, $f) = File::Spec->splitpath($self->{filename});
- if($f =~ /\.pm$/) {
+ # CAVEAT (possible TODO): .pmc files not treated the same as .pm
+ if ($self->{filename} =~ /\.pm$/) {
+ my ($v, $d, $f) = File::Spec->splitpath($self->{filename});
$f =~ s/\..+$//;
- my @candidates = grep /$f$/, @{$self->{packages}};
- $self->{module} = shift(@candidates); # punt
+ my @candidates = grep /(^|::)$f$/, @{$self->{packages}};
+ $self->{module} = shift(@candidates); # this may be undef
}
else {
- $self->{module} = 'main';
+ # this seems like an atrocious heuristic, albeit marginally better than
+ # what was here before. It should be rewritten entirely to be more like
+ # "if it's not a .pm file, it's not require()able as a name, therefore
+ # name() should be undef."
+ if ((grep /main/, @{$self->{packages}})
+ or (grep /main/, keys %{$self->{versions}})) {
+ $self->{module} = 'main';
+ }
+ else {
+ # TODO: this should maybe default to undef instead
+ $self->{module} = $self->{packages}[0] || '';
+ }
}
}
@@ -440,6 +454,7 @@ sub _do_find_module {
my $testfile = File::Spec->catfile($dir, $file);
return [ File::Spec->rel2abs( $testfile ), $dir ]
if -e $testfile and !-d _; # For stuff like ExtUtils::xsubpp
+ # CAVEAT (possible TODO): .pmc files are not discoverable here
$testfile .= '.pm';
return [ File::Spec->rel2abs( $testfile ), $dir ]
if -e $testfile;
@@ -649,6 +664,12 @@ sub _parse_fh {
$self->{pod_headings} = \@pod;
}
+sub __uniq (@)
+{
+ my (%seen, $key);
+ grep { not $seen{ $key = $_ }++ } @_;
+}
+
{
my $pn = 0;
sub _evaluate_version_line {
@@ -820,7 +841,7 @@ Module::Metadata - Gather package and POD information from perl module files
=head1 VERSION
-version 1.000031
+version 1.000033
=head1 SYNOPSIS
@@ -1037,7 +1058,7 @@ There is also a mailing list available for users of this distribution, at
L<http://lists.perl.org/list/cpan-workers.html>.
There is also an irc channel available for users of this distribution, at
-L<irc://irc.perl.org/#toolchain>.
+L<C<#toolchain> on C<irc.perl.org>|irc://irc.perl.org/#toolchain>.
=head1 AUTHOR
@@ -1049,7 +1070,7 @@ assistance from David Golden (xdg) <dagolden@cpan.org>.
=head1 CONTRIBUTORS
-=for stopwords Karen Etheridge David Golden Vincent Pit Matt S Trout Chris Nehren Graham Knop Olivier Mengué Tomas Doran Tatsuhiko Miyagawa tokuhirom Peter Rabbitson Steve Hay Josh Jore Craig A. Berry Mitchell Steinbrunner Edward Zborowski Gareth Harper James Raspass Jerry D. Hedden 'BinGOs' Williams Kent Fredric
+=for stopwords Karen Etheridge David Golden Vincent Pit Matt S Trout Chris Nehren Graham Knop Olivier Mengué Tomas Doran Tatsuhiko Miyagawa tokuhirom Kent Fredric Peter Rabbitson Steve Hay Jerry D. Hedden Craig A. Berry Mitchell Steinbrunner Edward Zborowski Gareth Harper James Raspass 'BinGOs' Williams Josh Jore
=over 4
@@ -1095,6 +1116,10 @@ tokuhirom <tokuhirom@gmail.com>
=item *
+Kent Fredric <kentnl@cpan.org>
+
+=item *
+
Peter Rabbitson <ribasushi@cpan.org>
=item *
@@ -1103,7 +1128,7 @@ Steve Hay <steve.m.hay@googlemail.com>
=item *
-Josh Jore <jjore@cpan.org>
+Jerry D. Hedden <jdhedden@cpan.org>
=item *
@@ -1111,6 +1136,10 @@ Craig A. Berry <cberry@cpan.org>
=item *
+Craig A. Berry <craigberry@mac.com>
+
+=item *
+
David Mitchell <davem@iabyn.com>
=item *
@@ -1131,15 +1160,11 @@ James Raspass <jraspass@gmail.com>
=item *
-Jerry D. Hedden <jdhedden@cpan.org>
-
-=item *
-
Chris 'BinGOs' Williams <chris@bingosnet.co.uk>
=item *
-Kent Fredric <kentnl@cpan.org>
+Josh Jore <jjore@cpan.org>
=back