Skip to content

Commit

Permalink
Parse RT's bugs tsv using column names instead of hardcoded column po…
Browse files Browse the repository at this point in the history
…sitions

Less fragile when RT's tsv changes.
  • Loading branch information
tsibley committed Apr 29, 2013
1 parent f38f9bf commit 587c1cb
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions lib/MetaCPAN/Script/Tickets.pm
Expand Up @@ -128,23 +128,25 @@ sub retrieve_rt_bugs {

sub parse_tsv {
my ( $self, $tsv ) = @_;
$tsv =~ s/^#\s*(dist\s.+)/$1/m; # uncomment the field spec for Parse::CSV
$tsv =~ s/^#.*\n//mg;

my $tsv_parser = Parse::CSV->new(
handle => IO::String->new($tsv),
sep_char => "\t"
sep_char => "\t",
names => 1,
);

my %summary;
while ( my $row = $tsv_parser->fetch ) {
my $i = 1;
$summary{ $row->[0] } = {
$summary{ $row->{dist} } = {
type => 'rt',
source => 'https://rt.cpan.org/Public/Dist/Display.html?Name=' . $row->[0],
active => ( sum @{$row}[ 1 .. 3 ] ),
closed => ( sum @{$row}[ 4 .. 5 ] ),
map { $_ => $row->[ $i++ ] + 0 }
qw(new open stalled resolved rejected),
source => 'https://rt.cpan.org/Public/Dist/Display.html?Name=' . $row->{dist},
active => ( sum @$row{qw(new open stalled)} ),
closed => ( sum @$row{qw(resolved rejected)} ),
map { $_ => $row->{$_} + 0 }
grep { $_ ne "dist" }
keys %$row,
};
}

Expand Down

0 comments on commit 587c1cb

Please sign in to comment.