| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Acme::CPANAuthors::Utils; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
27
|
use strict; |
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
205
|
|
|
4
|
7
|
|
|
7
|
|
26
|
use warnings; |
|
|
7
|
|
|
|
|
10
|
|
|
|
7
|
|
|
|
|
119
|
|
|
5
|
7
|
|
|
7
|
|
22
|
use Carp; |
|
|
7
|
|
|
|
|
7
|
|
|
|
7
|
|
|
|
|
309
|
|
|
6
|
7
|
|
|
7
|
|
33
|
use base qw( Exporter ); |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
1114
|
|
|
7
|
7
|
|
|
7
|
|
34
|
use File::Spec; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
3074
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '0.24'; # see RT #43388 |
|
10
|
|
|
|
|
|
|
our @EXPORT_OK = qw( cpan_authors cpan_packages ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $CPANFiles = {}; |
|
13
|
|
|
|
|
|
|
|
|
14
|
0
|
|
|
0
|
1
|
|
sub clear_cached_cpan_files () { $CPANFiles = {}; } |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub cpan_authors () { |
|
17
|
0
|
0
|
|
0
|
1
|
|
unless ( $CPANFiles->{authors} ) { |
|
18
|
0
|
|
|
|
|
|
require Acme::CPANAuthors::Utils::Authors; |
|
19
|
0
|
|
|
|
|
|
$CPANFiles->{authors} = |
|
20
|
|
|
|
|
|
|
Acme::CPANAuthors::Utils::Authors->new( _cpan_authors_file() ); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
0
|
|
|
|
|
|
return $CPANFiles->{authors}; |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub cpan_packages () { |
|
26
|
0
|
0
|
|
0
|
1
|
|
unless ( $CPANFiles->{packages} ) { |
|
27
|
0
|
|
|
|
|
|
require Acme::CPANAuthors::Utils::Packages; |
|
28
|
0
|
|
|
|
|
|
$CPANFiles->{packages} = |
|
29
|
|
|
|
|
|
|
Acme::CPANAuthors::Utils::Packages->new( _cpan_packages_file() ); |
|
30
|
|
|
|
|
|
|
} |
|
31
|
0
|
|
|
|
|
|
return $CPANFiles->{packages}; |
|
32
|
|
|
|
|
|
|
} |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub _cpan_authors_file () { |
|
35
|
0
|
|
|
0
|
|
|
_cpan_file( authors => '01mailrc.txt.gz' ); |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _cpan_packages_file () { |
|
39
|
0
|
|
|
0
|
|
|
_cpan_file( modules => '02packages.details.txt.gz' ); |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _cpan_file { |
|
43
|
0
|
|
|
0
|
|
|
my ($dir, $basename) = @_; |
|
44
|
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my $file; |
|
46
|
0
|
0
|
|
|
|
|
if ($ENV{ACME_CPANAUTHORS_HOME}) { |
|
47
|
0
|
|
|
|
|
|
$file = _catfile($ENV{ACME_CPANAUTHORS_HOME}, $dir, $basename); |
|
48
|
0
|
0
|
0
|
|
|
|
return $file if $file && -r $file; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
0
|
|
|
|
|
|
require File::Path; |
|
51
|
0
|
|
|
|
|
|
for my $parent (File::Spec->tmpdir, '.') { |
|
52
|
0
|
|
|
|
|
|
my $tmpdir = File::Spec->catdir($parent, '.acmecpanauthors', $dir); |
|
53
|
0
|
|
|
|
|
|
eval { File::Path::mkpath($tmpdir) }; |
|
|
0
|
|
|
|
|
|
|
|
54
|
0
|
0
|
0
|
|
|
|
next unless -d $tmpdir && -r _; |
|
55
|
0
|
|
|
|
|
|
$file = _catfile($tmpdir, $basename); |
|
56
|
0
|
|
|
|
|
|
my $how_old = -M $file; |
|
57
|
0
|
0
|
0
|
|
|
|
if (!-r $file or !$how_old or $how_old > 1) { |
|
|
|
|
0
|
|
|
|
|
|
58
|
0
|
|
|
|
|
|
require HTTP::Tiny; |
|
59
|
0
|
|
|
|
|
|
my $ua = HTTP::Tiny->new(env_proxy => 1); |
|
60
|
0
|
|
|
|
|
|
my $res = $ua->mirror('http://www.cpan.org/'.$dir.'/'.$basename, $file); |
|
61
|
0
|
0
|
|
|
|
|
next unless $res->{success}; |
|
62
|
|
|
|
|
|
|
} |
|
63
|
0
|
0
|
|
|
|
|
return $file if -r $file; |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
croak "$basename not found"; |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
0
|
|
|
sub _catfile { File::Spec->canonpath( File::Spec->catfile( @_ ) ); } |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |