File Coverage

blib/lib/Acme/CPANAuthors/You/re_using.pm
Criterion Covered Total %
statement 42 42 100.0
branch 14 20 70.0
condition 2 3 66.6
subroutine 10 10 100.0
pod 1 1 100.0
total 69 76 90.7


line stmt bran cond sub pod time code
1             package Acme::CPANAuthors::You::re_using;
2              
3 2     2   32885 use strict;
  2         5  
  2         74  
4 2     2   10 use warnings;
  2         4  
  2         60  
5              
6 2     2   13 use File::Find ();
  2         9  
  2         38  
7 2     2   3050 use Module::Metadata;
  2         56771  
  2         164  
8              
9 2     2   1641 use Acme::CPANAuthors::Utils;
  2         1724  
  2         137  
10              
11             =head1 NAME
12              
13             Acme::CPANAuthors::You::re_using - We are the CPAN authors that have written the modules installed on your perl!
14              
15             =head1 VERSION
16              
17             Version 0.06
18              
19             =cut
20              
21             our $VERSION;
22             BEGIN {
23 2     2   55 $VERSION = '0.06';
24             }
25              
26             =head1 SYNOPSIS
27              
28             use Acme::CPANAuthors;
29              
30             my $authors = Acme::CPANAuthors->new("You're_using");
31             print $authors->name($_) . " ($_)\n" for $authors->id;
32              
33             =head1 DESCRIPTION
34              
35             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.
36              
37             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.
38              
39             =head1 FUNCTIONS
40              
41             =head2 C
42              
43             Fetches and registers the names into L.
44             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.
45              
46             =cut
47              
48 2     2   1965 BEGIN { require Acme::CPANAuthors::Register; }
49              
50             our $SKIP;
51              
52             sub register {
53 2 100   2 1 46 return if $SKIP;
54              
55 1         2 my %authors;
56              
57 1         11 my $pkgs = Acme::CPANAuthors::Utils::cpan_packages();
58 1 50       17247328 die 'Couldn\'t retrieve a valid Parse::CPAN::Packages object' unless $pkgs;
59              
60 1         5 my $auths = Acme::CPANAuthors::Utils::cpan_authors();
61 1 50       949872 die 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths;
62              
63 1         4 my %modules;
64              
65             File::Find::find({
66             wanted => sub {
67 4769 100   4769   1391175 return unless /\.pm$/;
68 1522         9948 my $mod = Module::Metadata->new_from_file($_);
69 1522 50       9959411 return unless $mod;
70 1522         6901 @modules{grep $_, $mod->packages_inside} = ();
71             },
72 1         139 follow => 0,
73             no_chdir => 1,
74             }, @INC);
75              
76 1         634 for (keys %modules) {
77 1364         3031 my $mod = $pkgs->package($_);
78 1364 100       7461 next unless $mod;
79              
80 1329         7817 my $dist = $mod->distribution;
81 1329 50       5691 next unless $dist;
82              
83 1329         2664 my $cpanid = $dist->cpanid;
84 1329 100 66     9167 next if not $cpanid or exists $authors{$cpanid};
85              
86 130         373 my $auth = $auths->author($cpanid);
87              
88 130         670 my $name;
89 130 50       389 $name = $auth->name if defined $auth;
90              
91 130 50       783 $authors{$cpanid} = defined $name ? $name : $cpanid;
92             }
93              
94 1         314 Acme::CPANAuthors::Register->import(%authors);
95             }
96              
97 2     2   1325 BEGIN { register() }
98              
99             =head1 DEPENDENCIES
100              
101             L, L, L.
102              
103             =head1 SEE ALSO
104              
105             All others C modules.
106              
107             =head1 AUTHOR
108              
109             Vincent Pit, C<< >>, L.
110              
111             You can contact me by mail or on C (vincent).
112              
113             =head1 BUGS
114              
115             Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
116              
117             =head1 SUPPORT
118              
119             You can find documentation for this module with the perldoc command.
120              
121             perldoc Acme::CPANAuthors::You::re_using
122              
123             =head1 COPYRIGHT & LICENSE
124              
125             Copyright 2009,2010,2011,2013 Vincent Pit, all rights reserved.
126              
127             This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
128              
129             =cut
130              
131             1;