Skip to content

Instantly share code, notes, and snippets.

@neilb
Created November 25, 2014 21:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save neilb/396bab9baa5866fb66a3 to your computer and use it in GitHub Desktop.
Save neilb/396bab9baa5866fb66a3 to your computer and use it in GitHub Desktop.
Build a table of recently updated CPAN distributions that have a github repo
#!/usr/local/bin/perl
#
# cpan-github-dists
#
# Use the MetaCPAN API to build a list of CPAN distributions that have a github repo
# We show the 2000 most-recently released distributions
#
# See output for this at http://neilb.org/github-dists.html
#
use strict;
use warnings;
use MetaCPAN::Client;
my $TOP = 2000;
my $client = MetaCPAN::Client->new();
my $query = { all => [
{ status => 'latest' },
{ 'resources.repository.url' => '*github*' }
]
};
my $params = { fields => [qw(distribution author date version)] };
my $result_set = $client->release($query, $params);
my %dist;
while (my $release = $result_set->next) {
my $distname = $release->distribution;
next if $distname =~ /^(Acme|Task-BeLike|Dist-Zilla-PluginBundle-Author)/;
if (!exists($dist{$distname}) || $dist{$distname}{date} lt $release->date) {
$dist{ $distname } = { date => $release->date, version => $release->version, author => $release->author };
}
}
generate_header();
generate_body();
generate_footer();
sub generate_body
{
my $count = 0;
foreach my $distname (sort { $dist{$b}{date} cmp $dist{$a}{date} } keys %dist) {
printf "<tr><td><a href='https://metacpan.org/release/%s'>%s</a></td><td><a href='https://metacpan.org/author/%s'>%s</a></td><td>%s</td><td>%s</td></tr>\n",
$distname, $distname,
$dist{$distname}{author}, $dist{$distname}{author},
$dist{$distname}{version}, $dist{$distname}{date};
last if ++$count >= $TOP;
}
}
sub generate_header
{
print <<"END_HEADER";
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CPAN Adoption Candidates</title>
<link rel=stylesheet href="http://neilb.org/adoption/adoption.css" type="text/css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://neilb.org/adoption/jquery.tablesorter.min.js"></script>
</head>
<body>
<h1>CPAN distributions with a github repository</h1>
<table>
<thead>
<tr>
<th align=left>Distribution</th>
<th align=left>Author</th>
<th align=left>Version</th>
<th align=left>Date</th>
</tr>
</thead>
<tbody>
END_HEADER
}
sub generate_footer
{
print <<'END_FOOTER';
</tbody>
</table>
<script>
$().ready( function () {
$('table').tablesorter();
});
</script>
</body>
</html>
END_FOOTER
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment