use strict;
use warnings;
-use Carp qw/croak/;
-
-use ExtUtils::Installed;
+use File::Find ();
+use Module::Metadata;
use Acme::CPANAuthors::Utils;
=head1 VERSION
-Version 0.02
+Version 0.05
=cut
our $VERSION;
BEGIN {
- $VERSION = '0.02';
+ $VERSION = '0.05';
}
=head1 SYNOPSIS
BEGIN { require Acme::CPANAuthors::Register; }
+our $SKIP;
+
sub register {
- return if shift;
+ return if $SKIP;
my %authors;
my $pkgs = Acme::CPANAuthors::Utils::cpan_packages();
- croak 'Couldn\'t retrieve a valid Parse::CPAN::Packages object' unless $pkgs;
+ die 'Couldn\'t retrieve a valid Parse::CPAN::Packages object' unless $pkgs;
my $auths = Acme::CPANAuthors::Utils::cpan_authors();
- croak 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths;
-
- my $installed = ExtUtils::Installed->new();
- croak 'Couldn\'t create a valid ExtUtils::Installed object' unless $installed;
-
- for ($installed->modules) {
- next unless defined and $_ ne 'Perl';
-
+ die 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths;
+
+ my %modules;
+
+ File::Find::find({
+ wanted => sub {
+ return unless /\.pm$/;
+ my $mod = Module::Metadata->new_from_file($_);
+ return unless $mod;
+ @modules{grep $_, $mod->packages_inside} = ();
+ },
+ follow => 0,
+ no_chdir => 1,
+ }, @INC);
+
+ for (keys %modules) {
my $mod = $pkgs->package($_);
next unless $mod;
my $name;
$name = $auth->name if defined $auth;
-
+
$authors{$cpanid} = defined $name ? $name : $cpanid;
}
Acme::CPANAuthors::Register->import(%authors);
}
-our $SKIP;
-
-BEGIN { register($SKIP) }
+BEGIN { register() }
=head1 DEPENDENCIES
-L<Carp>, L<ExtUtils::Installed>, L<Acme::CPANAuthors>.
+L<File::Find>, L<Module::Metadata>, L<Acme::CPANAuthors>.
=head1 SEE ALSO
=head1 COPYRIGHT & LICENSE
-Copyright 2009,2010 Vincent Pit, all rights reserved.
+Copyright 2009,2010,2011,2013 Vincent Pit, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.