-
Notifications
You must be signed in to change notification settings - Fork 33
/
rev_deps.pl
79 lines (64 loc) · 1.84 KB
/
rev_deps.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
use strict;
use warnings;
use HTTP::Tiny;
use JSON;
use Data::Dumper;
use Time::Piece; #of course
use MetaCPAN::Client;
#search cpan for any module that mentions "Time::Piece"
my $i = 1;
my @total_dists = ();
my @skipped = ();
my $too_old = localtime->strptime( "2011-01-01", "%Y-%m-%d" );
my $meta = MetaCPAN::Client->new();
while (
my $response = HTTP::Tiny->new->get(
"https://grep.metacpan.org/api/search?p=$i&q=Time%3A%3APiece&qls=on")
)
{
++$i;
die "Failed!\n" unless $response->{success};
my $j;
if ( length $response->{content} ) {
$j = from_json( $response->{content} );
}
unless ( @{ $j->{results} } > 1 ) {
warn "no results from:\n" . Dumper $j;
last;
}
print "Got " . scalar @{ $j->{results} } . "\n";
foreach my $raw_dist ( @{ $j->{results} } ) {
my $dist_date;
my $release;
eval {
$dist_date = localtime->strptime( $meta->release( $raw_dist->{distro} )->date(),
"%Y-%m-%dT%H:%M:%S" );
};
if($@){
push( @skipped, "$raw_dist->{distro} -" . (split(/\n/, $@))[0] );
next;
}
#skip bundled stuff
if ( $raw_dist->{distro} =~ /task|belike/i ) {
push( @skipped, $raw_dist->{distro} );
next;
}
#or too old
if ( $dist_date < $too_old ) {
push( @skipped, "$raw_dist->{distro} - $dist_date" );
next;
}
$raw_dist->{distro} =~ s/-/::/g;
push( @total_dists, $raw_dist->{distro} );
}
print "total_dists size is now: " . scalar @total_dists . "\n";
print "Fetching page #$i\n";
}
print "\n\nSkipped dists:\n\n";
foreach my $dist (@skipped) {
print "$dist\n";
}
print "\n\nDep dists:\n\n";
foreach my $dist (@total_dists) {
print "$dist\n";
}