Created
August 30, 2010 22:29
-
-
Save dolmen/558153 to your computer and use it in GitHub Desktop.
Kwalitee rank for an Acme::CPANAuthors list (from CPANTS)
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/perl | |
# Author: Olivier Mengué | |
# 2010-08-21 | |
use utf8; | |
use strict; | |
use warnings; | |
use Acme::CPANAuthors; | |
use ORDB::CPANTS 0.05; | |
use List::Util qw(reduce); | |
my $cat = $ARGV[0]; | |
my $authors = Acme::CPANAuthors->new($cat); | |
sub get_kwalitee_rank_online | |
{ | |
my $pauseid = shift; | |
my $k = $authors->kwalitee($_); | |
($k->{info}{Rank}, 0+keys %{$k->{distributions}}, 0) | |
} | |
sub get_kwalitee_rank_cache | |
{ | |
my $pauseid = shift; | |
my ($a) = ORDB::CPANTS::Author->select('where pauseid = ?', $pauseid); | |
($a->rank, $a->num_dists, $a->average_kwalitee) | |
} | |
my @ids = $authors->id; | |
#our ($a, $b); | |
my $max_id_len = reduce { my $l = length $b; $l > $a ? $l : $a } 0, @ids; | |
my @table = | |
# [ Rank, Dists, AvgKwalitee, ID, Name ] | |
sort { $a->[0] <=> $b->[0] || $b->[1] <=> $a->[1] || $a->[2] cmp $b->[3] } | |
map { | |
my ($rank, $dists, $kwal) = get_kwalitee_rank_cache($_); | |
$dists ? ([ $rank, $dists, $kwal, $_, $authors->name($_) ]) : () | |
} | |
@ids; | |
printf "Rang Dists Kwal \%${max_id_len}s Nom\n", "ID"; | |
foreach (@table) { | |
printf "%4d %5d %6.2f \%${max_id_len}s %s\n", @{$_}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment