]> git.vpit.fr Git - perl/modules/Acme-CPANAuthors-You-re_using.git/blob - lib/Acme/CPANAuthors/You/re_using.pm
df1e8911dc0a18109a7fc483fb363b6d68de2d30
[perl/modules/Acme-CPANAuthors-You-re_using.git] / lib / Acme / CPANAuthors / You / re_using.pm
1 package Acme::CPANAuthors::You::re_using;
2
3 use strict;
4 use warnings;
5
6 use Carp qw/croak/;
7
8 use ExtUtils::Installed;
9
10 use Acme::CPANAuthors::Utils;
11
12 =head1 NAME
13
14 Acme::CPANAuthors::You::re_using - We are the CPAN authors that have written the modules installed on your perl!
15
16 =head1 VERSION
17
18 Version 0.01
19
20 =cut
21
22 our $VERSION;
23 BEGIN {
24  $VERSION = '0.01';
25 }
26
27 =head1 SYNOPSIS
28
29     use Acme::CPANAuthors;
30
31     my $authors = Acme::CPANAuthors->new("You're_using");
32     print $authors->name($_) . " ($_)\n" for $authors->id;
33
34 =head1 DESCRIPTION
35
36 This module builds an L<Acme::CPANAuthors> class by listing all the modules that are installed on the current C<perl> and then retrieving the name and the PAUSE id of their corresponding authors.
37
38 It may take some time to load since it has to get CPAN indexes at C<BEGIN> time.
39
40 =cut
41
42 BEGIN {
43  my %authors;
44
45  my $pkgs = Acme::CPANAuthors::Utils::cpan_packages();
46  croak 'Couldn\'t retrieve a valid Parse::CPAN::Packages object' unless $pkgs;
47
48  my $auths = Acme::CPANAuthors::Utils::cpan_authors();
49  croak 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths;
50
51  my $installed = ExtUtils::Installed->new(extra_libs => \@INC);
52  croak 'Couldn\'t create a valid ExtUtils::Installed object' unless $installed;
53
54  for ($installed->modules) {
55   my $mod = $pkgs->package($_);
56   next unless $mod;
57
58   my $dist = $mod->distribution;
59   next unless $dist;
60
61   my $cpanid = $dist->cpanid;
62   next if not $cpanid or exists $authors{$cpanid};
63
64   my $auth = $auths->author($cpanid);
65
66   my $name;
67   $name = $auth->name if defined $auth;
68  
69   $authors{$cpanid} = defined $name ? $name : $cpanid;
70  }
71
72  require Acme::CPANAuthors::Register;
73  Acme::CPANAuthors::Register->import(%authors);
74 }
75
76 =head1 DEPENDENCIES
77
78 L<Carp>, L<ExtUtils::Installed>, L<Acme::CPANAuthors>.
79
80 =head1 SEE ALSO
81
82 All others C<Acme::CPANAuthors::*> modules.
83
84 =head1 AUTHOR
85
86 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
87
88 You can contact me by mail or on C<irc.perl.org> (vincent).
89
90 =head1 BUGS
91
92 Please report any bugs or feature requests to C<bug-acme-cpanauthors-you-re_using at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Acme-CPANAuthors-You-re_using>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
93
94 =head1 SUPPORT
95
96 You can find documentation for this module with the perldoc command.
97
98     perldoc Acme::CPANAuthors::You::re_using
99
100 =head1 COPYRIGHT & LICENSE
101
102 Copyright 2009 Vincent Pit, all rights reserved.
103
104 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
105
106 =cut
107
108 1;