line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Recent::Uploads; |
2
|
|
|
|
|
|
|
$CPAN::Recent::Uploads::VERSION = '0.14'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Find the distributions recently uploaded to CPAN |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
200384
|
use strict; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
46
|
|
6
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
50
|
|
7
|
1
|
|
|
1
|
|
9
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
93
|
|
8
|
1
|
|
|
1
|
|
9
|
use YAML::XS (); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
8
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
10
|
1
|
|
|
1
|
|
475
|
use CPAN::Recent::Uploads::Retriever; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
568
|
|
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
|
6360
|
my $epoch = shift; |
26
|
1
|
50
|
33
|
|
|
5
|
$epoch = shift if $epoch and eval { $epoch->isa(__PACKAGE__) }; |
|
1
|
|
|
|
|
12
|
|
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
|
|
|
|
|
5
|
my $period = _period_from_epoch( $epoch ); |
31
|
1
|
|
33
|
|
|
4
|
my $mirror = shift || $MIRROR; |
32
|
1
|
|
|
|
|
10
|
my %data; |
33
|
1
|
|
|
|
|
3
|
OUTER: foreach my $foo ( @times ) { |
34
|
1
|
|
|
|
|
8
|
my $yaml = CPAN::Recent::Uploads::Retriever->retrieve( time => $foo, mirror => $mirror ); |
35
|
1
|
|
|
|
|
5
|
my @yaml; |
36
|
1
|
|
|
|
|
4
|
eval { @yaml = YAML::XS::Load( $yaml ); }; |
|
1
|
|
|
|
|
166
|
|
37
|
1
|
50
|
|
|
|
8
|
croak "Unable to process YAML\n" unless @yaml; |
38
|
1
|
|
|
|
|
2
|
my $record = shift @yaml; |
39
|
1
|
50
|
|
|
|
4
|
die unless $record; |
40
|
1
|
|
|
|
|
2
|
RECENT: foreach my $recent ( reverse @{ $record->{recent} } ) { |
|
1
|
|
|
|
|
4
|
|
41
|
17
|
100
|
|
|
|
61
|
next RECENT unless $recent->{path} =~ /\.(tar\.gz|tgz|tar\.bz2|zip)$/; |
42
|
6
|
50
|
|
|
|
14
|
if ( $recent->{type} eq 'new' ) { |
43
|
6
|
|
|
|
|
23
|
( my $bar = $recent->{path} ) =~ s#^id/##; |
44
|
6
|
50
|
|
|
|
15
|
next RECENT if $recent->{epoch} < $epoch; |
45
|
|
|
|
|
|
|
{ |
46
|
6
|
|
|
|
|
10
|
my @parts = split m!/!, $bar; |
|
6
|
|
|
|
|
16
|
|
47
|
6
|
100
|
|
|
|
23
|
next RECENT if $parts[3] =~ m!Perl6!i; |
48
|
|
|
|
|
|
|
} |
49
|
5
|
|
|
|
|
14
|
$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
|
|
|
|
13
|
last if $foo eq $period; |
57
|
|
|
|
|
|
|
} |
58
|
1
|
50
|
|
|
|
4
|
return \%data unless wantarray; |
59
|
1
|
|
|
|
|
8
|
return sort { $data{$a} <=> $data{$b} } keys %data; |
|
8
|
|
|
|
|
28
|
|
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub _period_from_epoch { |
63
|
1
|
|
50
|
1
|
|
6
|
my $epoch = shift || return; |
64
|
1
|
|
|
|
|
4
|
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__ |