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