Skip to content

Instantly share code, notes, and snippets.

@ranguard
Created August 29, 2016 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ranguard/3101715faa9d2f8d72f88f86065eb2f4 to your computer and use it in GitHub Desktop.
Save ranguard/3101715faa9d2f8d72f88f86065eb2f4 to your computer and use it in GitHub Desktop.
Try replicate Tux issues with fastapi
#!/usr/bin/env perl
# USAGE: run_test.pl AUTHOR
use 5.20.0;
use warnings;
use MetaCPAN::Client;
my $opt_v = 2; # Verbosity of debug
my $author = shift;
$author = uc $author;
my $mcpan = MetaCPAN::Client->new(
domain => "fastapi.metacpan.org",
version => "v1"
);
my $mauthor = $mcpan->author($author);
my %modules;
{
my $author_releases = $mauthor->releases;
while ( my $rr = $author_releases->next ) {
my $module = $rr->distribution =~ s{-}{::}gr; # Yeah, not 100% correct
$opt_v > 1 and say " $module";
$modules{$module} = { data => $rr->{data} // {}, };
}
}
# Now loop each one
foreach my $module ( sort keys %modules ) {
$opt_v and say $module;
my $m = $modules{$module};
$m->{skip} and next;
my $dist = $module =~ s/::/-/gr;
$opt_v and say "-module() -> $module";
my $data = eval { $mcpan->module($module)->{data} } || {};
if ( $m->{data} ) {
$data->{$_} = $m->{data}{$_} for keys %{ $m->{data} };
}
$opt_v and say "-favorite() -> $dist";
$data->{fav}
= $mcpan->favorite( { distribution => $dist } )->{total} || "-";
$opt_v and say "-rating() -> $dist";
if ( my $rs = $mcpan->rating( { distribution => $dist } )->scroller ) {
my $n = $rs->total;
if ( my $r = $rs->next ) {
# Loop through all ratings
}
}
$opt_v and say "-distribution() -> $dist";
my $mcpan_distribution = $mcpan->distribution($dist);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment