line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Recent::Uploads; |
2
|
|
|
|
|
|
|
$CPAN::Recent::Uploads::VERSION = '0.12'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Find the distributions recently uploaded to CPAN |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
33990
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
38
|
|
6
|
1
|
|
|
1
|
|
7
|
use warnings; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
89
|
|
8
|
1
|
|
|
1
|
|
7
|
use YAML::XS (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
21
|
|
9
|
1
|
|
|
1
|
|
17
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
10
|
1
|
|
|
1
|
|
600
|
use CPAN::Recent::Uploads::Retriever; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
627
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $MIRROR = 'http://www.cpan.org/'; |
13
|
|
|
|
|
|
|
my @times = qw(1h 6h 1d 1W 1M 1Q 1Y); |
14
|
|
|
|
|
|
|
my %periods = ( |
15
|
|
|
|
|
|
|
'1h' => (60*60), |
16
|
|
|
|
|
|
|
'6h' => (60*60*6), |
17
|
|
|
|
|
|
|
'1d' => (60*60*24), |
18
|
|
|
|
|
|
|
'1W' => (60*60*24*7), |
19
|
|
|
|
|
|
|
'1M' => (60*60*24*30), |
20
|
|
|
|
|
|
|
'1Q' => (60*60*24*90), |
21
|
|
|
|
|
|
|
'1Y' => (60*60*24*365.25), |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub recent { |
25
|
1
|
|
|
1
|
1
|
11356
|
my $epoch = shift; |
26
|
1
|
50
|
33
|
|
|
10
|
$epoch = shift if $epoch and eval { $epoch->isa(__PACKAGE__) }; |
|
1
|
|
|
|
|
20
|
|
27
|
|
|
|
|
|
|
$epoch = ( time() - ( 7 * 24 * 60 * 60 ) ) |
28
|
|
|
|
|
|
|
unless $epoch and $epoch =~ /^\d+$/ and |
29
|
1
|
50
|
33
|
|
|
30
|
$epoch <= time() and $epoch >= ( time() - $periods{'1Y'} ); |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
30
|
1
|
|
|
|
|
7
|
my $period = _period_from_epoch( $epoch ); |
31
|
1
|
|
33
|
|
|
8
|
my $mirror = shift || $MIRROR; |
32
|
1
|
|
|
|
|
16
|
my %data; |
33
|
1
|
|
|
|
|
4
|
OUTER: foreach my $foo ( @times ) { |
34
|
1
|
|
|
|
|
14
|
my $yaml = CPAN::Recent::Uploads::Retriever->retrieve( time => $foo, mirror => $mirror ); |
35
|
1
|
|
|
|
|
54
|
my @yaml; |
36
|
1
|
|
|
|
|
3
|
eval { @yaml = YAML::XS::Load( $yaml ); }; |
|
1
|
|
|
|
|
260
|
|
37
|
1
|
50
|
|
|
|
11
|
croak "Unable to process YAML\n" unless @yaml; |
38
|
1
|
|
|
|
|
4
|
my $record = shift @yaml; |
39
|
1
|
50
|
|
|
|
11
|
die unless $record; |
40
|
1
|
|
|
|
|
3
|
RECENT: foreach my $recent ( reverse @{ $record->{recent} } ) { |
|
1
|
|
|
|
|
5
|
|
41
|
17
|
100
|
|
|
|
74
|
next RECENT unless $recent->{path} =~ /\.(tar\.gz|tgz|tar\.bz2|zip)$/; |
42
|
6
|
50
|
|
|
|
18
|
if ( $recent->{type} eq 'new' ) { |
43
|
6
|
|
|
|
|
25
|
( my $bar = $recent->{path} ) =~ s#^id/##; |
44
|
6
|
50
|
|
|
|
23
|
next RECENT if $recent->{epoch} < $epoch; |
45
|
|
|
|
|
|
|
{ |
46
|
6
|
|
|
|
|
12
|
my @parts = split m!/!, $bar; |
|
6
|
|
|
|
|
25
|
|
47
|
6
|
100
|
|
|
|
27
|
next RECENT if $parts[3] =~ m!Perl6!i; |
48
|
|
|
|
|
|
|
} |
49
|
5
|
|
|
|
|
20
|
$data{ $bar } = $recent->{epoch}; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
else { |
52
|
0
|
|
|
|
|
0
|
( my $bar = $recent->{path} ) =~ s#^id/##; |
53
|
0
|
0
|
|
|
|
0
|
delete $data{ $bar } if exists $data{ $foo }; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
} |
56
|
1
|
50
|
|
|
|
14
|
last if $foo eq $period; |
57
|
|
|
|
|
|
|
} |
58
|
1
|
50
|
|
|
|
5
|
return \%data unless wantarray; |
59
|
1
|
|
|
|
|
9
|
return sort { $data{$a} <=> $data{$b} } keys %data; |
|
8
|
|
|
|
|
26
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _period_from_epoch { |
63
|
1
|
|
50
|
1
|
|
8
|
my $epoch = shift || return; |
64
|
1
|
|
|
|
|
6
|
foreach my $period ( @times ) { |
65
|
1
|
50
|
|
|
|
12
|
return $period if ( time() - $periods{$period} ) < $epoch; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
|
return; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
q[Whats uploaded, Doc?]; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |