| 1 | package Acme::CPANAuthors::You::re_using; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use File::Find (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use Module::Metadata; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 3 | ▶ | use Acme::CPANAuthors::Utils; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 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.08 | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | =cut | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 3 | our $VERSION; | |||||||||||||||||||||||||||
| 22 | 3 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | 3 | $VERSION = '0.08'; | |||||||||||||||||||||||||||
| 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<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. | ||||||||||||||||||||||||||||
| 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<register> | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | Fetches and registers the names into L<Acme::CPANAuthors::Register>. | ||||||||||||||||||||||||||||
| 44 | 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. | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | =cut | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 3 | ▶ | BEGIN { require Acme::CPANAuthors::Register; } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 3 | our $SKIP; | |||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 3 | ▶ | sub register { | ||||||||||||||||||||||||||
|
Subroutine
register: called CC=11 SCAR=24.2
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 3 | ▶ | return if $SKIP; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | my %authors; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 2 | my $pkgs = Acme::CPANAuthors::Utils::cpan_packages(); | |||||||||||||||||||||||||||
| 58 | 2 | ▶ | die 'Couldn\'t retrieve a valid Parse::CPAN::Packages object' unless $pkgs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 2 | my $auths = Acme::CPANAuthors::Utils::cpan_authors(); | |||||||||||||||||||||||||||
| 61 | 2 | ▶ | die 'Couldn\'t retrieve a valid Parse::CPAN::Authors object' unless $auths; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 2 | my %modules; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | File::Find::find({ | ||||||||||||||||||||||||||||
| 66 | 43514 | ▶ | wanted => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 67 | 43514 | ▶ | return unless /\.pm$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 68 | 4200 | my $mod = do { | |||||||||||||||||||||||||||
| 69 | 4200 | local $@; | |||||||||||||||||||||||||||
| 70 | 4200 | eval { Module::Metadata->new_from_file($_) } | |||||||||||||||||||||||||||
| 71 | }; | ||||||||||||||||||||||||||||
| 72 | 4200 | ▶ | return unless $mod; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 73 | 4199 | @modules{grep $_, $mod->packages_inside} = (); | |||||||||||||||||||||||||||
| 74 | }, | ||||||||||||||||||||||||||||
| 75 | 2 | follow => 0, | |||||||||||||||||||||||||||
| 76 | no_chdir => 1, | ||||||||||||||||||||||||||||
| 77 | }, @INC); | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | 2 | for (keys %modules) { | |||||||||||||||||||||||||||
| 80 | 4186 | my $mod = $pkgs->package($_); | |||||||||||||||||||||||||||
| 81 | 4186 | ▶ | next unless $mod; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | 3994 | my $dist = $mod->distribution; | |||||||||||||||||||||||||||
| 84 | 3994 | ▶ | next unless $dist; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 3994 | my $cpanid = $dist->cpanid; | |||||||||||||||||||||||||||
| 87 | 3994 | ▶ | next if not $cpanid or exists $authors{$cpanid}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $cpanid or exists $authors{$cpanid}
MC/DC50%1/2
not $cpanid or exists $authors{$cpanid}
not $cpanid
exists $authors{$cpanid}
Truth table66%2/3
not(A) or B
A= not $cpanidB= exists $authors{$cpanid}
| |||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 208 | my $auth = $auths->author($cpanid); | |||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 208 | my $name; | |||||||||||||||||||||||||||
| 92 | 208 | ▶ | $name = $auth->name if defined $auth; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 208 | ▶ | $authors{$cpanid} = defined $name ? $name : $cpanid; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | 2 | Acme::CPANAuthors::Register->import(%authors); | |||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 3 | ▶ | BEGIN { register() } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | =head1 DEPENDENCIES | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | L<File::Find> (core since perl 5) | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | L<Acme::CPANAuthors> 0.16. | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | L<Module::Metadata> 1.000_017. | ||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||
| 110 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||
| 112 | All others C<Acme::CPANAuthors::*> modules. | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>. | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | You can contact me by mail or on C<irc.perl.org> (vincent). | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | =head1 BUGS | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 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. | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | =head1 SUPPORT | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | You can find documentation for this module with the perldoc command. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | perldoc Acme::CPANAuthors::You::re_using | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | Copyright 2009,2010,2011,2013,2015 Vincent Pit, all rights reserved. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | =cut | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | 3 | 1; | |||||||||||||||||||||||||||