r29956 - in /branches/upstream/libparse-cpan-packages-perl/current: CHANGES MANIFEST META.yml Makefile.PL README lib/Parse/CPAN/Packages.pm lib/Parse/CPAN/Packages/Distribution.pm lib/Parse/CPAN/Packages/Package.pm t/pod.t t/pod_coverage.t

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Fri Jan 23 17:53:23 UTC 2009


Author: ansgar-guest
Date: Fri Jan 23 17:53:18 2009
New Revision: 29956

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=29956
Log:
[svn-upgrade] Integrating new upstream version, libparse-cpan-packages-perl (2.30)

Added:
    branches/upstream/libparse-cpan-packages-perl/current/t/pod.t
    branches/upstream/libparse-cpan-packages-perl/current/t/pod_coverage.t
Modified:
    branches/upstream/libparse-cpan-packages-perl/current/CHANGES
    branches/upstream/libparse-cpan-packages-perl/current/MANIFEST
    branches/upstream/libparse-cpan-packages-perl/current/META.yml
    branches/upstream/libparse-cpan-packages-perl/current/Makefile.PL
    branches/upstream/libparse-cpan-packages-perl/current/README
    branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages.pm
    branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Distribution.pm
    branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Package.pm

Modified: branches/upstream/libparse-cpan-packages-perl/current/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/CHANGES?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/CHANGES (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/CHANGES Fri Jan 23 17:53:18 2009
@@ -1,4 +1,12 @@
 CHANGES file for Parse::CPAN::Packages
+
+2.30 Fri Jan 23 10:09:05 GMT 2009
+  - switch to using Moose
+  - use Compress::Zlib instead of IO::Zlib for speed
+  - minor code cleanups
+  - add human-readable license
+  - add an abstract to Makefile.PL
+  - add pod tests, more documentation
 
 2.29 Tue Aug 19 18:37:02 BST 2008
   - parse the preamble and add methods to access the fields

Modified: branches/upstream/libparse-cpan-packages-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/MANIFEST?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/MANIFEST (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/MANIFEST Fri Jan 23 17:53:18 2009
@@ -7,5 +7,7 @@
 README
 t/02packages.details.txt
 t/02packages.details.txt.gz
+t/pod.t
+t/pod_coverage.t
 t/simple.t
 META.yml                                 Module meta-data (added by MakeMaker)

Modified: branches/upstream/libparse-cpan-packages-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/META.yml?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/META.yml (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/META.yml Fri Jan 23 17:53:18 2009
@@ -1,16 +1,16 @@
 --- #YAML:1.0
 name:                Parse-CPAN-Packages
-version:             2.29
-abstract:            ~
+version:             2.30
+abstract:            Parse 02packages.details.txt.gz
 license:             perl
 author:              
     - Leon Brocard <acme at astray.com>
 generated_by:        ExtUtils::MakeMaker version 6.44
 distribution_type:   module
 requires:     
-    Class::Accessor::Fast:         0
+    Compress::Zlib:                0
     CPAN::DistnameInfo:            0
-    IO::Zlib:                      0
+    Moose:                         0
     Test::More:                    0
     version:                       0
 meta-spec:

Modified: branches/upstream/libparse-cpan-packages-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/Makefile.PL?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/Makefile.PL (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/Makefile.PL Fri Jan 23 17:53:18 2009
@@ -6,13 +6,14 @@
     NAME         => 'Parse::CPAN::Packages',
     VERSION_FROM => 'lib/Parse/CPAN/Packages.pm',
     AUTHOR       => 'Leon Brocard <acme at astray.com>',
+    ABSTRACT     => 'Parse 02packages.details.txt.gz',
     LICENSE      => 'perl',
     PREREQ_PM    => {
-        'Class::Accessor::Fast' => 0,
-        'CPAN::DistnameInfo'    => 0,
-        'IO::Zlib'              => 0,
-        'Test::More'            => 0,
-        'version'               => 0,
+        'Compress::Zlib'     => 0,
+        'CPAN::DistnameInfo' => 0,
+        'Moose'              => 0,
+        'Test::More'         => 0,
+        'version'            => 0,
     }
 );
 

Modified: branches/upstream/libparse-cpan-packages-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/README?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/README (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/README Fri Jan 23 17:53:18 2009
@@ -85,7 +85,7 @@
           my $p = Parse::CPAN::Distribution->new($gzfilename);
           my $dist = $p->distribution('L/LB/LBROCARD/Acme-Colour-1.00.tar.gz');
 
-    distrbutions()
+    distributions()
         Returns a list of Parse::CPAN::Distribution objects representing all
         the known distributions.
 
@@ -107,6 +107,20 @@
 
     latest_distribution_count()
         Returns the number of distributions stored.
+
+  Preamble Methods
+    These methods return the information from the preamble at the start of
+    the file. They return undef if for any reason no matching preamble line
+    was found.
+
+    file()
+    url()
+    description()
+    columns()
+    intended_for()
+    written_by()
+    line_count()
+    last_updated()
 
   Addtional Methods
     These are additional methods that you may find useful.
@@ -138,8 +152,9 @@
     Leon Brocard <acme at astray.com>
 
 COPYRIGHT
-    Copyright (C) 2004, Leon Brocard
+    Copyright (C) 2004-9, Leon Brocard
 
+LICENSE
     This module is free software; you can redistribute it or modify it under
     the same terms as Perl itself.
 

Modified: branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages.pm?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages.pm (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages.pm Fri Jan 23 17:53:18 2009
@@ -1,38 +1,41 @@
 package Parse::CPAN::Packages;
-use strict;
-use base qw( Class::Accessor::Fast );
-__PACKAGE__->mk_accessors(qw( details data dists latestdists ));
+use Moose;
 use CPAN::DistnameInfo;
 use Compress::Zlib;
-use IO::Zlib;
+use Parse::CPAN::Packages::Distribution;
 use Parse::CPAN::Packages::Package;
 use version;
-use vars qw($VERSION);
-$VERSION = '2.29';
+our $VERSION = '2.30';
+
+has 'details'     => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
+has 'data'        => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
+has 'dists'       => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
+has 'latestdists' => ( is => 'rw', isa => 'HashRef', default => sub { {} } );
+
+__PACKAGE__->meta->make_immutable;
 
 sub new {
-    my $class = shift;
-
-    my $self = { data => {}, dists => {}, latestdists => {}, preamble => {} };
-    bless $self, $class;
+    my ( $class, $filename ) = @_;
+    my $self = $class->SUPER::new();
 
     # read the file then parse it if present
-    $self->parse(shift) if @_;
+    $self->parse($filename) if $filename;
 
     return $self;
 }
 
 # read the file into memory and return it
 sub _slurp_details {
-    my $self = shift;
-    my $filename = (@_) ? shift : "02packages.details.txt.gz";
+    my ( $self, $filename ) = @_;
+    $filename ||= '02packages.details.txt.gz';
 
     if ( $filename =~ /Description:/ ) {
         return $filename;
     } elsif ( $filename =~ /\.gz/ ) {
-        my $fh = IO::Zlib->new( $filename, "rb" )
-            || die "Failed to read $filename: $!";
-        return join '', <$fh>;
+        open( IN, $filename ) || die "Failed to read $filename: $!";
+        my $data = join '', <IN>;
+        close(IN);
+        return Compress::Zlib::memGunzip($data);
     } elsif ( $filename =~ /^\037\213/ ) {
         return Compress::Zlib::memGunzip($filename);
     } else {
@@ -51,8 +54,8 @@
 }
 
 sub parse {
-    my $self    = shift;
-    my $details = $self->_slurp_details(shift);
+    my ( $self, $filename ) = @_;
+    my $details = $self->_slurp_details($filename);
 
     # read the preamble
     my @details = split "\n", $details;
@@ -75,20 +78,21 @@
 }
 
 sub add_quick {
-    my $self = shift;
-    my ( $package_name, $package_version, $prefix ) = @_;
-
-    # create the package object
-    my $m = Parse::CPAN::Packages::Package->new;
-    $m->package($package_name);
-    $m->version($package_version);
+    my ( $self, $package_name, $package_version, $prefix ) = @_;
 
     # create a distribution object (or get an existing one)
     my $dist = $self->distribution_from_prefix($prefix);
 
+    # create the package object
+    my $m = Parse::CPAN::Packages::Package->new(
+        {   package      => $package_name,
+            version      => $package_version,
+            distribution => $dist
+        }
+    );
+
     # make the package have the distribion and the distribution
     # have the package.  Yes, this creates a cirtular reference.  eek!
-    $m->distribution($dist);
     $dist->add_package($m);
 
     # record this distribution and package
@@ -97,29 +101,29 @@
 }
 
 sub distribution_from_prefix {
-    my $self   = shift;
-    my $prefix = shift;
+    my ( $self, $prefix ) = @_;
 
     # see if we have one of these already and return it if we do.
     my $d = $self->distribution($prefix);
     return $d if $d;
 
     # create a new one otherwise
-    $d = Parse::CPAN::Packages::Distribution->new;
     my $i = CPAN::DistnameInfo->new($prefix);
-    $d->prefix($prefix);
-    $d->dist( $i->dist );
-    $d->version( $i->version );
-    $d->maturity( $i->maturity );
-    $d->filename( $i->filename );
-    $d->cpanid( $i->cpanid );
-    $d->distvname( $i->distvname );
+    $d = Parse::CPAN::Packages::Distribution->new(
+        {   prefix    => $prefix,
+            dist      => $i->dist,
+            version   => $i->version,
+            maturity  => $i->maturity,
+            filename  => $i->filename,
+            cpanid    => $i->cpanid,
+            distvname => $i->distvname
+        }
+    );
     return $d;
 }
 
 sub add_package {
-    my $self    = shift;
-    my $package = shift;
+    my ( $self, $package ) = @_;
 
     # store it
     $self->data->{ $package->package } = $package;
@@ -128,8 +132,7 @@
 }
 
 sub package {
-    my $self         = shift;
-    my $package_name = shift;
+    my ( $self, $package_name ) = @_;
     return $self->data->{$package_name};
 }
 
@@ -139,48 +142,49 @@
 }
 
 sub add_distribution {
-    my $self = shift;
-    my $dist = shift;
+    my ( $self, $dist ) = @_;
 
     $self->_store_distribution($dist);
     $self->_ensure_latest_distribution($dist);
 }
 
 sub _store_distribution {
-    my $self = shift;
-    my $dist = shift;
+    my ( $self, $dist ) = @_;
 
     $self->dists->{ $dist->prefix } = $dist;
 }
 
 sub _ensure_latest_distribution {
-    my $self = shift;
-    local $a = shift;
-    local $b = $self->latest_distribution( $a->dist );
-    unless ($b) {
-        $self->_set_latest_distribution($a);
+    my ( $self, $new ) = @_;
+
+    my $latest = $self->latest_distribution( $new->dist );
+    unless ($latest) {
+        $self->_set_latest_distribution($new);
         return;
     }
-    my ( $av, $bv );
-    local $^W = 0;    # stop version.pm warnings
+    my $new_version    = $new->version;
+    my $latest_version = $latest->version;
+    my ( $newv, $latestv );
+
     eval {
-        $av = version->new( $a->version || 0 );
-        $bv = version->new( $b->version || 0 );
+        no warnings;
+        $newv    = version->new( $new_version    || 0 );
+        $latestv = version->new( $latest_version || 0 );
     };
-    if ( $av && $bv ) {
-        if ( $av > $bv ) {
-            $self->_set_latest_distribution($a);
+    if ( $newv && $latestv ) {
+        if ( $newv > $latestv ) {
+            $self->_set_latest_distribution($new);
         }
     } else {
-        if ( $a->dist > $b->dist ) {
-            $self->_set_latest_distribution($a);
+        no warnings;
+        if ( $new_version > $latest_version ) {
+            $self->_set_latest_distribution($new);
         }
     }
 }
 
 sub distribution {
-    my $self = shift;
-    my $dist = shift;
+    my ( $self, $dist ) = @_;
     return $self->dists->{$dist};
 }
 
@@ -190,15 +194,13 @@
 }
 
 sub _set_latest_distribution {
-    my $self = shift;
-    my $dist = shift;
+    my ( $self, $dist ) = @_;
     return unless $dist->dist;
     $self->latestdists->{ $dist->dist } = $dist;
 }
 
 sub latest_distribution {
-    my $self = shift;
-    my $dist = shift;
+    my ( $self, $dist ) = @_;
     return unless $dist;
     return $self->latestdists->{$dist};
 }
@@ -412,9 +414,19 @@
 =item add_distribution($distribution_obj)
 
 Adds a distribution.  Note that you'll probably want to add the
-corrisponding packages for that distribution too (it's not done
+corresponding packages for that distribution too (it's not done
 automatically.)
 
+=item distribution_from_prefix($prefix)
+
+Returns a distribution given a prefix.
+
+=item latest_distributions
+
+Returns all the latest distributions:
+
+  my @distributions = $p->latest_distributions;
+
 =cut
 
 =back
@@ -425,7 +437,9 @@
 
 =head1 COPYRIGHT
 
-Copyright (C) 2004-8, Leon Brocard
+Copyright (C) 2004-9, Leon Brocard
+
+=head1 LICENSE
 
 This module is free software; you can redistribute it or modify it under
 the same terms as Perl itself.

Modified: branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Distribution.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Distribution.pm?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Distribution.pm (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Distribution.pm Fri Jan 23 17:53:18 2009
@@ -1,17 +1,16 @@
 package Parse::CPAN::Packages::Distribution;
-use strict;
-use base qw( Class::Accessor::Fast );
-__PACKAGE__->mk_accessors(
-    qw( prefix dist version maturity filename
-        cpanid distvname packages )
-);
+use Moose;
 
-sub new {
-    my $class = shift;
-    my $self  = $class->SUPER::new;
-    $self->packages( [] );
-    return $self;
-}
+has 'prefix'    => ( is => 'rw', isa => 'Str' );
+has 'dist'      => ( is => 'rw', isa => 'Str|Undef' );
+has 'version'   => ( is => 'rw', isa => 'Str|Undef' );
+has 'maturity'  => ( is => 'rw', isa => 'Str' );
+has 'filename'  => ( is => 'rw', isa => 'Str' );
+has 'cpanid'    => ( is => 'rw', isa => 'Str' );
+has 'distvname' => ( is => 'rw', isa => 'Str|Undef' );
+has 'packages'  => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
+
+__PACKAGE__->meta->make_immutable;
 
 sub contains {
     my $self = shift;
@@ -24,3 +23,23 @@
 }
 
 1;
+
+__END__
+
+=head1 NAME
+
+Parse::CPAN::Packages::Distribution
+
+=head1 DESCRIPTION
+
+Represents a CPAN distribution.
+
+=head1 METHODS
+
+=head2 contains
+
+Returns the packages in the distribution.
+
+=head2 add_package
+
+Adds a package to the distribution.

Modified: branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Package.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Package.pm?rev=29956&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Package.pm (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages/Package.pm Fri Jan 23 17:53:18 2009
@@ -1,16 +1,22 @@
 package Parse::CPAN::Packages::Package;
-use strict;
-use base qw( Class::Accessor::Fast );
-__PACKAGE__->mk_accessors(qw( package version prefix distribution ));
-use Parse::CPAN::Packages::Distribution;
+use Moose;
 
-sub new {
-    my $class = shift;
+has 'package' => ( is => 'rw', isa => 'Str' );
+has 'version' => ( is => 'rw', isa => 'Str' );
+has 'prefix'  => ( is => 'rw', isa => 'Str' );
+has 'distribution' =>
+    ( is => 'rw', isa => 'Parse::CPAN::Packages::Distribution' );
 
-    my $self = {};
-    bless $self, $class;
-
-    return $self;
-}
+__PACKAGE__->meta->make_immutable;
 
 1;
+
+__END__
+
+=head1 NAME
+
+Parse::CPAN::Packages::Package
+
+=head1 DESCRIPTION
+
+Represents a CPAN Package.

Added: branches/upstream/libparse-cpan-packages-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/t/pod.t?rev=29956&op=file
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/t/pod.t (added)
+++ branches/upstream/libparse-cpan-packages-perl/current/t/pod.t Fri Jan 23 17:53:18 2009
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD: $@" if $@;
+all_pod_files_ok();

Added: branches/upstream/libparse-cpan-packages-perl/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/t/pod_coverage.t?rev=29956&op=file
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/t/pod_coverage.t (added)
+++ branches/upstream/libparse-cpan-packages-perl/current/t/pod_coverage.t Fri Jan 23 17:53:18 2009
@@ -1,0 +1,13 @@
+use Test::More;
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage"
+    if $@;
+all_pod_coverage_ok( { also_private => [qr/^[A-Z_]+$/] } );
+
+# Workaround for dumb bug (fixed in 5.8.7) where Test::Builder thinks that
+# certain "die"s that happen inside evals are not actually inside evals,
+# because caller() is broken if you turn on $^P like Module::Refresh does
+#
+# (I mean, if we've gotten to this line, then clearly the test didn't die, no?)
+Test::Builder->new->{Test_Died} = 0;
+




More information about the Pkg-perl-cvs-commits mailing list