Last active
August 29, 2015 13:56
-
-
Save neilb/9083411 to your computer and use it in GitHub Desktop.
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/local/bin/perl | |
# | |
# cpan-user-release-history - take a PAUSE id and generate an ascii graph of their # releases by year | |
# | |
use strict; | |
use warnings; | |
use CPAN::ReleaseHistory 0.02; | |
my $MAX_BAR_SIZE = 50; | |
my $iterator = CPAN::ReleaseHistory->new()->release_iterator(); | |
my %by_year; | |
die "usage: $0 <PAUSE-ID>\n" unless @ARGV == 1; | |
my $user = uc($ARGV[0]); | |
while (my $release = $iterator->next_release) { | |
next unless defined($release->distinfo) | |
&& defined($release->distinfo->cpanid) | |
&& $release->distinfo->cpanid eq $user; | |
my $year = (gmtime($release->timestamp))[5] + 1900; | |
$by_year{$year}++; | |
} | |
my $max = (sort { $b <=> $a } values %by_year)[0]; | |
my $scale = $max < $MAX_BAR_SIZE ? 1 : $max / $MAX_BAR_SIZE; | |
my ($first_year, $last_year) = (sort keys %by_year)[0,-1]; | |
foreach my $year ($first_year .. $last_year) { | |
printf " %d (%3d) %s\n", $year, $by_year{$year}//0, '#' x (($by_year{$year}//0) / $scale); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I went the ad-hoc way, and used the cpan-once-a-week-data repository and the following command-line (I'm user 1306):
I hope all those scripts you write end up in the distribution (possibly with a main script as the entry point).