Skip Menu |
 

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

Report information
The Basics
Id: 33262
Status: resolved
Priority: 0/
Queue: Parse-CPAN-Packages

People
Owner: Nobody in particular
Requestors: leon [...] astray.com
Cc:
AdminCc:

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



Subject: Squish warnings
From David Cantrell <david@cantrell.org.uk>
Subject: squish_warnings.diff
--- Parse-CPAN-Packages-2.26-orig/lib/Parse/CPAN/Packages.pm 2006-06-14 07:34:14.000000000 +0100 +++ Parse-CPAN-Packages-2.26-drc/lib/Parse/CPAN/Packages.pm 2007-11-22 17:27:43.000000000 +0000 @@ -8,6 +8,7 @@ use Parse::CPAN::Packages::Package; use version; use vars qw($VERSION); +open(DEVNULL, '>>/dev/null'); $VERSION = '2.26'; sub new { @@ -17,7 +18,7 @@ bless $self, $class; # read the file then parse it if present - $self->parse(shift) if @_; + $self->parse(@_) if @_; return $self; } @@ -44,11 +45,21 @@ sub parse { my $self = shift; - my $details = $self->_slurp_details(shift); + my $details = shift; + my $params = shift || {}; + + if(ref($details) eq 'HASH') { ($details, $params) = ($params, $details) }; + $details = $self->_slurp_details($details); # remove the preamble $details = ( split "\n\n", $details )[1]; + # squish warnings about bad version numbers + $params->{squish_warnings} && ( + open(local *STDERR, ">&DEVNULL") || + die("Couldn't redirect STDERR to squish warnings\n") + ); + # run though each line of the file foreach my $line ( split "\n", $details ) { @@ -284,6 +295,15 @@ my $data = get("http://www.cpan.org/modules/02packages.details.txt.gz"); my $p = Parse::CPAN::Packages->new($data); +You may optionally also pass in a hashref of parameters. The only one +supported at present is 'squish_warnings' which will hide any warnings +generated while reading the packages database: + + my $p = Parse::CPAN::Packages->new( + { squish_warnings => 1 }, + '02packages.details.txt.gz' + ); + =item package($packagename) Returns a C<Parse::CPAN::Packages::Package> that represents the @@ -345,7 +365,7 @@ =over -=item parse($filename) +=item parse($filename, [$params]) Parses the filename. Works in a similar fashion to the the constructor (i.e. you can pass it a filename for a
Download (untitled) / with headers
text/plain 101b
Thanks, I was finally able to replicate this. Warnings are squished on the 2.28, which just hit CPAN.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.