X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FAcme%2FCPANAuthors%2FYou%2Fre_using.pm;h=8c8a746578eeb3ef3e234b819ff469618c899858;hb=12c26b568cf70d8f9f8285efe03d7caf264161d2;hp=09db1de0a732b0b808c25896ddf16ffbdeee4ee3;hpb=8fe77c5fa1b5d38d2b2eeafc1bdc9d6137de6158;p=perl%2Fmodules%2FAcme-CPANAuthors-You-re_using.git diff --git a/lib/Acme/CPANAuthors/You/re_using.pm b/lib/Acme/CPANAuthors/You/re_using.pm index 09db1de..8c8a746 100644 --- a/lib/Acme/CPANAuthors/You/re_using.pm +++ b/lib/Acme/CPANAuthors/You/re_using.pm @@ -5,7 +5,8 @@ use warnings; use Carp qw/croak/; -use ExtUtils::Installed; +use File::Find (); +use Module::Metadata; use Acme::CPANAuthors::Utils; @@ -15,13 +16,13 @@ Acme::CPANAuthors::You::re_using - We are the CPAN authors that have written the =head1 VERSION -Version 0.01 +Version 0.03 =cut our $VERSION; BEGIN { - $VERSION = '0.01'; + $VERSION = '0.03'; } =head1 SYNOPSIS @@ -37,11 +38,20 @@ This module builds an L class by listing all the modules that It may take some time to load since it has to search all the directory trees given by your C<@INC> for modules, but also to get and parse CPAN indexes. +=head1 FUNCTIONS + +=head2 C + +Fetches and registers the names into L. +This function is automatically called when you C this module, unless you have set the package variable C<$Acme::CPANAuthors::You're_using::SKIP> to true beforehand. + =cut +BEGIN { require Acme::CPANAuthors::Register; } + our $SKIP; -BEGIN { +sub register { return if $SKIP; my %authors; @@ -52,12 +62,20 @@ BEGIN { my $auths = Acme::CPANAuthors::Utils::cpan_authors(); croak 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths; - my $installed = ExtUtils::Installed->new(extra_libs => \@INC); - croak 'Couldn\'t create a valid ExtUtils::Installed object' unless $installed; + my %modules; - for ($installed->modules) { - next unless defined and $_ ne 'Perl'; + 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; @@ -75,13 +93,14 @@ BEGIN { $authors{$cpanid} = defined $name ? $name : $cpanid; } - require Acme::CPANAuthors::Register; Acme::CPANAuthors::Register->import(%authors); } +BEGIN { register() } + =head1 DEPENDENCIES -L, L, L. +L, L, L, L. =head1 SEE ALSO @@ -105,7 +124,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2009 Vincent Pit, all rights reserved. +Copyright 2009,2010,2011 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.