line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ORDB::CPANUploads; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
779
|
use 5.008005; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
5
|
1
|
|
|
1
|
|
16
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
2234
|
use DateTime 0.55 (); |
|
1
|
|
|
|
|
168525
|
|
|
1
|
|
|
|
|
37
|
|
7
|
1
|
|
|
1
|
|
10
|
use Params::Util 1.00 (); |
|
1
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
16
|
|
8
|
1
|
|
|
1
|
|
879
|
use ORLite::Mirror 1.20 (); |
|
1
|
|
|
|
|
183287
|
|
|
1
|
|
|
|
|
302
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '1.08'; |
11
|
|
|
|
|
|
|
our @LOCATION = ( |
12
|
|
|
|
|
|
|
locale => 'C', |
13
|
|
|
|
|
|
|
time_zone => 'UTC', |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub import { |
17
|
0
|
|
|
0
|
|
|
my $class = shift; |
18
|
0
|
|
0
|
|
|
|
my $params = Params::Util::_HASH(shift) || {}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Pass through any params from above |
21
|
0
|
|
0
|
|
|
|
$params->{url} ||= 'http://devel.cpantesters.org/uploads/uploads.db.bz2'; |
22
|
0
|
|
0
|
|
|
|
$params->{maxage} ||= 7 * 24 * 60 * 60; # One week |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Prevent double-initialisation |
25
|
0
|
0
|
|
|
|
|
$class->can('orlite') or |
26
|
|
|
|
|
|
|
ORLite::Mirror->import( $params ); |
27
|
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
return 1; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub latest { |
32
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# Find the most recent upload |
35
|
0
|
|
|
|
|
|
my @latest = ORDB::CPANUploads::Uploads->select( |
36
|
|
|
|
|
|
|
'ORDER BY released DESC LIMIT 1', |
37
|
|
|
|
|
|
|
); |
38
|
0
|
0
|
|
|
|
|
unless ( @latest == 1 ) { |
39
|
0
|
|
|
|
|
|
die "Unexpected number of uploads"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# When was the most recent release |
43
|
0
|
|
|
|
|
|
$latest[0]->released; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub latest_datetime { |
47
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
48
|
0
|
|
|
|
|
|
return DateTime->from_epoch( |
49
|
|
|
|
|
|
|
epoch => $class->latest, |
50
|
|
|
|
|
|
|
@LOCATION, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub age { |
55
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
56
|
0
|
|
|
|
|
|
my $latest = $class->latest_datetime; |
57
|
0
|
|
|
|
|
|
my $today = DateTime->today( @LOCATION ); |
58
|
0
|
|
|
|
|
|
my $duration = $today - $latest; |
59
|
0
|
|
|
|
|
|
return $duration->in_units('days'); |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
1; |