X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FAcme%2FCPANAuthors%2FYou%2Fre_using.pm;h=9fbe898e382b21e77200123809a0469ce13f481a;hb=a7271956fb0e83fe6687b53c9e892bc5ae2a3214;hp=36fd9c77d192ad5208af2f45436e02e6531c5e08;hpb=ccce87545fda1846090f652fc4770e2393070ab9;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 36fd9c7..9fbe898 100644 --- a/lib/Acme/CPANAuthors/You/re_using.pm +++ b/lib/Acme/CPANAuthors/You/re_using.pm @@ -3,25 +3,24 @@ package Acme::CPANAuthors::You::re_using; use strict; use warnings; -use Carp qw/croak/; - -use ExtUtils::Installed; +use File::Find (); +use Module::Metadata; use Acme::CPANAuthors::Utils; =head1 NAME -Acme::CPANAuthors::You::re_using - We are the CPAN authors that have written the modules installed for this perl. +Acme::CPANAuthors::You::re_using - We are the CPAN authors that have written the modules installed on your perl! =head1 VERSION -Version 0.01 +Version 0.06 =cut our $VERSION; BEGIN { - $VERSION = '0.01'; + $VERSION = '0.06'; } =head1 SYNOPSIS @@ -33,25 +32,48 @@ BEGIN { =head1 DESCRIPTION -This module builds an L class by looking for all installed modules for the current C and then retrieving theirs authors' name and PAUSE id. +This module builds an L class by listing all the modules that are installed on the current C and then retrieving the name and the PAUSE id of their corresponding authors. + +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 -It may take some time to load since it has to get CPAN indexes at C time. +=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 { +BEGIN { require Acme::CPANAuthors::Register; } + +our $SKIP; + +sub register { + 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()) { + 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; @@ -65,17 +87,18 @@ BEGIN { my $name; $name = $auth->name if defined $auth; - + $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. =head1 SEE ALSO @@ -99,7 +122,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,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.