Skip Menu |

This queue is for tickets about the Parse-BACKPAN-Packages CPAN distribution.

Report information
The Basics
Id: 39381
Status: resolved
Priority: 0/
Queue: Parse-BACKPAN-Packages

People
Owner: Nobody in particular
Requestors: BARBIE [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.33
Fixed in: (no value)



Subject: distributions_by() blows up for missing or new authors
Hi Leon, The attached patch amends distributions_by so that it returns an empty list if no author or a new author is passed as the argument to distributions_by(). Currently I have to wrap this in an eval to stop it blowing up :( Cheers, Barbie.
Subject: backpan-newauthorbug.patch
/Parse-BACKPAN-Packages/Parse-BACKPAN-Packages-0.33/lib/Parse/BACKPAN/Packages.pm Thu Sep 18 10:15:17 2008 /Parse-BACKPAN-Packages/Parse-BACKPAN-Packages-0.33_01/lib/Parse/BACKPAN/Packages.pm Thu Sep 18 10:24:55 2008 @@ -99,8 +99,11 @@ sub distributions_by { my ($self, $author) = @_; + return () unless($author); my $dists_by = $self->dists_by; + return () unless(defined $dists_by); + return () unless(defined $dists_by->{$author}); my @dists = @{ $dists_by->{$author} }; return sort @dists; /Parse-BACKPAN-Packages/Parse-BACKPAN-Packages-0.33/t/simple.t Thu Sep 18 10:15:17 2008 /Parse-BACKPAN-Packages/Parse-BACKPAN-Packages-0.33_01/t/simple.t Thu Sep 18 10:24:31 2008 @@ -1,7 +1,7 @@ #!perl use strict; use warnings; -use Test::More tests => 84; +use Test::More tests => 86; use lib 'lib'; use_ok("Parse::BACKPAN::Packages"); @@ -43,6 +43,12 @@ is($acme_colours[-1]->maturity, "released"); is($acme_colours[-1]->prefix, "authors/id/L/LB/LBROCARD/Acme-Colour-1.04.tar.gz"); is($acme_colours[-1]->version, "1.04"); + +my @noone = $p->distributions_by('NONEXISTENTAUTHOR'); +is(scalar @noone, 0, 'No distributions for new author'); + +my @bogus = $p->distributions_by(); +is(scalar @bogus, 0, 'No distributions for missing author'); my @acmes = $p->distributions_by('LBROCARD'); foreach my $dist (
Thanks for the patch, Parse-BACKPAN-Packages-0.34.tar.gz just hit CPAN.