]> git.vpit.fr Git - perl/modules/Acme-CPANAuthors-You-re_using.git/blob - lib/Acme/CPANAuthors/You/re_using.pm
9f5a8185f16dfbf0abfe2175203bbd9d7f8b2272
[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.03
19
20 =cut
21
22 our $VERSION;
23 BEGIN {
24  $VERSION = '0.03';
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 search all the directory trees given by your C<@INC> for modules, but also to get and parse CPAN indexes.
39
40 =head1 FUNCTIONS
41
42 =head2 C<register>
43
44 Fetches and registers the names into L<Acme::CPANAuthors::Register>.
45 This function is automatically called when you C<use> this module, unless you have set the package variable C<$Acme::CPANAuthors::You're_using::SKIP> to true beforehand.
46
47 =cut
48
49 BEGIN { require Acme::CPANAuthors::Register; }
50
51 our $SKIP;
52
53 sub register {
54  return if $SKIP;
55
56  my %authors;
57
58  my $pkgs = Acme::CPANAuthors::Utils::cpan_packages();
59  croak 'Couldn\'t retrieve a valid Parse::CPAN::Packages object' unless $pkgs;
60
61  my $auths = Acme::CPANAuthors::Utils::cpan_authors();
62  croak 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths;
63
64  my $installed = ExtUtils::Installed->new();
65  croak 'Couldn\'t create a valid ExtUtils::Installed object' unless $installed;
66
67  for ($installed->modules) {
68   next unless defined and $_ ne 'Perl';
69
70   my $mod = $pkgs->package($_);
71   next unless $mod;
72
73   my $dist = $mod->distribution;
74   next unless $dist;
75
76   my $cpanid = $dist->cpanid;
77   next if not $cpanid or exists $authors{$cpanid};
78
79   my $auth = $auths->author($cpanid);
80
81   my $name;
82   $name = $auth->name if defined $auth;
83  
84   $authors{$cpanid} = defined $name ? $name : $cpanid;
85  }
86
87  Acme::CPANAuthors::Register->import(%authors);
88 }
89
90 BEGIN { register() }
91
92 =head1 DEPENDENCIES
93
94 L<Carp>, L<ExtUtils::Installed>, L<Acme::CPANAuthors>.
95
96 =head1 SEE ALSO
97
98 All others C<Acme::CPANAuthors::*> modules.
99
100 =head1 AUTHOR
101
102 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
103
104 You can contact me by mail or on C<irc.perl.org> (vincent).
105
106 =head1 BUGS
107
108 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.
109
110 =head1 SUPPORT
111
112 You can find documentation for this module with the perldoc command.
113
114     perldoc Acme::CPANAuthors::You::re_using
115
116 =head1 COPYRIGHT & LICENSE
117
118 Copyright 2009,2010 Vincent Pit, all rights reserved.
119
120 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
121
122 =cut
123
124 1;