Created
August 29, 2016 21:16
-
-
Save ranguard/3101715faa9d2f8d72f88f86065eb2f4 to your computer and use it in GitHub Desktop.
Try replicate Tux issues with fastapi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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