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