r121 - in packages: . libparse-cpan-packages-perl libparse-cpan-packages-perl/branches libparse-cpan-packages-perl/branches/upstream libparse-cpan-packages-perl/branches/upstream/current libparse-cpan-packages-perl/branches/upstream/current/lib libparse-cpan-packages-perl/branches/upstream/current/lib/Parse libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages libparse-cpan-packages-perl/branches/upstream/current/t
Allard Hoeve
hoeve-guest@haydn.debian.org
Thu, 10 Jun 2004 08:09:56 -0600
Author: hoeve-guest
Date: 2004-06-10 08:09:49 -0600 (Thu, 10 Jun 2004)
New Revision: 121
Added:
packages/libparse-cpan-packages-perl/
packages/libparse-cpan-packages-perl/branches/
packages/libparse-cpan-packages-perl/branches/upstream/
packages/libparse-cpan-packages-perl/branches/upstream/current/
packages/libparse-cpan-packages-perl/branches/upstream/current/Build.PL
packages/libparse-cpan-packages-perl/branches/upstream/current/CHANGES
packages/libparse-cpan-packages-perl/branches/upstream/current/MANIFEST
packages/libparse-cpan-packages-perl/branches/upstream/current/META.yml
packages/libparse-cpan-packages-perl/branches/upstream/current/Makefile.PL
packages/libparse-cpan-packages-perl/branches/upstream/current/README
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages.pm
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Distribution.pm
packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Package.pm
packages/libparse-cpan-packages-perl/branches/upstream/current/t/
packages/libparse-cpan-packages-perl/branches/upstream/current/t/02packages.details.txt
packages/libparse-cpan-packages-perl/branches/upstream/current/t/simple.t
packages/libparse-cpan-packages-perl/tags/
Log:
[svn-inject] Installing original source of libparse-cpan-packages-perl
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/Build.PL
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/Build.PL 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/Build.PL 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,15 @@
+use Module::Build;
+use strict;
+
+my $build = Module::Build->new(
+ create_makefile_pl => 'traditional',
+ license => 'perl',
+ module_name => 'Parse::CPAN::Packages',
+ requires => {
+ 'Class::Accessor::Fast' => 0,
+ 'CPAN::DistnameInfo' => 0,
+ 'Test::More' => 0,
+ 'Sort::Versions' => 0,
+},
+);
+$build->create_build_script;
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/CHANGES
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/CHANGES 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/CHANGES 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,19 @@
+CHANGES file for Parse::CPAN::Packages
+
+2.20 Sat Mar 6 20:21:57 GMT 2004
+ - list Sort::Versions as a prereq
+ - try and make test more portable (added 'sort')
+ - use Class::Accessor::Fast instead of Class::Accessor::Chained
+
+2.19 Wed Mar 3 22:21:18 GMT 2004
+ - new methods to get the latest distribution and distributions
+ - possibility to pass the contents of 02packages in addition to the
+ filename
+
+2.17 Wed Feb 25 10:29:07 GMT 2004
+ - fix a documentation glitch in the main module
+ - make a ->distributions hash available
+ - A distribution now contains packages
+
+2.12 Fri Feb 13 18:42:57 GMT 2004
+ - first release (suggested by Richard Clamp)
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/MANIFEST
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/MANIFEST 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/MANIFEST 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,11 @@
+Build.PL
+CHANGES
+lib/Parse/CPAN/Packages.pm
+lib/Parse/CPAN/Packages/Distribution.pm
+lib/Parse/CPAN/Packages/Package.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+README
+t/02packages.details.txt
+t/simple.t
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/META.yml
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/META.yml 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/META.yml 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,23 @@
+--- #YAML:1.0
+name: Parse-CPAN-Packages
+version: 2.20
+author:
+ - Leon Brocard <acme@astray.com>
+abstract: Parse 02packages.details.txt.gz
+license: perl
+requires:
+ CPAN::DistnameInfo: 0
+ Class::Accessor::Fast: 0
+ Sort::Versions: 0
+ Test::More: 0
+provides:
+ Parse::CPAN::Packages:
+ file: lib/Parse/CPAN/Packages.pm
+ version: 2.20
+ Parse::CPAN::Packages::Distribution:
+ file: lib/Parse/CPAN/Packages/Distribution.pm
+ version: 2.12
+ Parse::CPAN::Packages::Package:
+ file: lib/Parse/CPAN/Packages/Package.pm
+ version: 2.12
+generated_by: Module::Build version 0.24
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/Makefile.PL
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/Makefile.PL 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/Makefile.PL 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,16 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+ 'PL_FILES' => {},
+ 'INSTALLDIRS' => 'site',
+ 'NAME' => 'Parse::CPAN::Packages',
+ 'VERSION_FROM' => 'lib/Parse/CPAN/Packages.pm',
+ 'PREREQ_PM' => {
+ 'Test::More' => 0,
+ 'Sort::Versions' => 0,
+ 'CPAN::DistnameInfo' => 0,
+ 'Class::Accessor::Fast' => 0
+ }
+ )
+;
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/README
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/README 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/README 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,65 @@
+NAME
+ Parse::CPAN::Packages - Parse 02packages.details.txt.gz
+
+SYNOPSIS
+ use Parse::CPAN::Packages;
+
+ # must have downloaded and un-gzip-ed
+ my $p = Parse::CPAN::Packages->new("02packages.details.txt");
+ # either a filename as above or pass in the contents of the file
+ my $p = Parse::CPAN::Packages->new($packages_details_contents);
+
+ my $m = $p->package("Acme::Colour");
+ # $m is a Parse::CPAN::Packages::Package object
+ print $m->package, "\n"; # Acme::Colour
+ print $m->version, "\n"; # 1.00
+
+ my $d = $p->distribution;
+ # $d is a Parse::CPAN::Packages::Distribution object
+ print $d->prefix, "\n"; # L/LB/LBROCARD/Acme-Colour-1.00.tar.gz
+ print $d->dist, "\n"; # Acme-Colour
+ print $d->version, "\n"; # 1.00
+ print $d->maturity, "\n"; # released
+ print $d->filename, "\n"; # Acme-Colour-1.00.tar.gz
+ print $d->cpanid, "\n"; # LBROCARD
+ print $d->distvname, "\n"; # Acme-Colour-1.00
+
+ # all the package objects
+ my @packages = $p->packages;
+
+ # all the distribution objects
+ my @distributions = $p->distributions;
+
+ # the latest distribution
+ $d = $p->latest_distribution("Acme-Colour");
+ is($d->prefix, "L/LB/LBROCARD/Acme-Colour-1.00.tar.gz");
+ is($d->version, "1.00");
+
+ # all the latest distributions
+ my @distributions = $p->latest_distributions;
+
+DESCRIPTION
+ The Comprehensive Perl Archive Network (CPAN) is a very useful
+ collection of Perl code. It has several indices of the files that it
+ hosts, including a file named "02packages.details.txt.gz" in the
+ "modules" directory. This file contains lots of useful information and
+ this module provides a simple interface to the data contained within.
+
+ Note that this module does not concern itself with downloading or
+ unpacking this file. You should do this yourself.
+
+ The constructor takes the path to the 02packages.details.txt file. It
+ defaults to loading the file from the current directory.
+
+ In a future release Parse::CPAN::Packages::Package and
+ Parse::CPAN::Packages::Distribution might have more information.
+
+AUTHOR
+ Leon Brocard <acme@astray.com>
+
+COPYRIGHT
+ Copyright (C) 2004, Leon Brocard
+
+ This module is free software; you can redistribute it or modify it under
+ the same terms as Perl itself.
+
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Distribution.pm
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Distribution.pm 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Distribution.pm 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,21 @@
+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 vars qw($VERSION);
+$VERSION = '2.12';
+
+sub new {
+ my $class = shift;
+ my $self = $class->SUPER::new;
+ $self->packages([]);
+ return $self;
+}
+
+sub contains {
+ my $self = shift;
+ return @{ $self->packages };
+}
+
+1;
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Package.pm
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Package.pm 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages/Package.pm 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,18 @@
+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 vars qw($VERSION);
+$VERSION = '2.12';
+
+sub new {
+ my $class = shift;
+
+ my $self = {};
+ bless $self, $class;
+
+ return $self;
+}
+
+1;
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages.pm
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages.pm 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/lib/Parse/CPAN/Packages.pm 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,182 @@
+package Parse::CPAN::Packages;
+use strict;
+use base qw( Class::Accessor::Fast );
+__PACKAGE__->mk_accessors(qw( details data dists latestdists ));
+use CPAN::DistnameInfo;
+use Parse::CPAN::Packages::Package;
+use Sort::Versions;
+use vars qw($VERSION);
+$VERSION = '2.20';
+
+sub new {
+ my $class = shift;
+ my $filename = shift;
+
+ my $self = { dists => {}, latestdists => {} };
+ bless $self, $class;
+
+ $filename = '02packages.details.txt' if not defined $filename;
+
+ if ($filename =~ /Description:/) {
+ $self->details($filename);
+ } else {
+ open(IN, $filename) || die "Failed to read $filename: $!";
+ $self->details(join '', <IN>);
+ close(IN);
+ }
+
+ $self->parse;
+ return $self;
+}
+
+sub parse {
+ my $self = shift;
+ my $details = $self->details;
+ $details = (split "\n\n", $details)[1];
+
+ my $data;
+ my $latestdists;
+
+ foreach my $line (split "\n", $details) {
+ my($package, $packageversion, $prefix) = split ' ', $line;
+ my $m = Parse::CPAN::Packages::Package->new;
+ $m->package($package);
+ $m->version($packageversion);
+
+ my $dist = $self->dists->{ $prefix } ||= do {
+ my $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;
+ };
+
+ $m->distribution($dist);
+ push @{ $dist->packages }, $m;
+
+ push @{$latestdists->{$dist->dist}}, $dist if $dist->dist;
+
+ $data->{$package} = $m;
+ }
+ close(IN);
+
+ foreach my $dist (keys %$latestdists) {
+ my @dists = @{$latestdists->{$dist}};
+ my $highest_version = (sort { versioncmp($a->version || 0, $b->version || 0) } @dists)[-1];
+ $self->latestdists->{$dist} = $highest_version;
+ }
+
+ $self->data($data);
+}
+
+sub package {
+ my $self = shift;
+ my $package = shift;
+ return $self->data->{$package};
+}
+
+sub packages {
+ my $self = shift;
+ return values %{$self->data};
+}
+
+sub distribution {
+ my $self = shift;
+ my $dist = shift;
+ return $self->dists->{$dist};
+}
+
+sub distributions {
+ my $self = shift;
+ return values %{$self->dists};
+}
+
+sub latest_distribution {
+ my $self = shift;
+ my $dist = shift;
+ return $self->latestdists->{$dist};
+}
+
+sub latest_distributions {
+ my $self = shift;
+ return values %{$self->latestdists};
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Parse::CPAN::Packages - Parse 02packages.details.txt.gz
+
+=head1 SYNOPSIS
+
+ use Parse::CPAN::Packages;
+
+ # must have downloaded and un-gzip-ed
+ my $p = Parse::CPAN::Packages->new("02packages.details.txt");
+ # either a filename as above or pass in the contents of the file
+ my $p = Parse::CPAN::Packages->new($packages_details_contents);
+
+ my $m = $p->package("Acme::Colour");
+ # $m is a Parse::CPAN::Packages::Package object
+ print $m->package, "\n"; # Acme::Colour
+ print $m->version, "\n"; # 1.00
+
+ my $d = $p->distribution;
+ # $d is a Parse::CPAN::Packages::Distribution object
+ print $d->prefix, "\n"; # L/LB/LBROCARD/Acme-Colour-1.00.tar.gz
+ print $d->dist, "\n"; # Acme-Colour
+ print $d->version, "\n"; # 1.00
+ print $d->maturity, "\n"; # released
+ print $d->filename, "\n"; # Acme-Colour-1.00.tar.gz
+ print $d->cpanid, "\n"; # LBROCARD
+ print $d->distvname, "\n"; # Acme-Colour-1.00
+
+ # all the package objects
+ my @packages = $p->packages;
+
+ # all the distribution objects
+ my @distributions = $p->distributions;
+
+ # the latest distribution
+ $d = $p->latest_distribution("Acme-Colour");
+ is($d->prefix, "L/LB/LBROCARD/Acme-Colour-1.00.tar.gz");
+ is($d->version, "1.00");
+
+ # all the latest distributions
+ my @distributions = $p->latest_distributions;
+
+=head1 DESCRIPTION
+
+The Comprehensive Perl Archive Network (CPAN) is a very useful
+collection of Perl code. It has several indices of the files that it
+hosts, including a file named "02packages.details.txt.gz" in the
+"modules" directory. This file contains lots of useful information and
+this module provides a simple interface to the data contained within.
+
+Note that this module does not concern itself with downloading or
+unpacking this file. You should do this yourself.
+
+The constructor takes the path to the 02packages.details.txt file. It
+defaults to loading the file from the current directory.
+
+In a future release L<Parse::CPAN::Packages::Package> and
+L<Parse::CPAN::Packages::Distribution> might have more information.
+
+=head1 AUTHOR
+
+Leon Brocard <acme@astray.com>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2004, Leon Brocard
+
+This module is free software; you can redistribute it or modify it under
+the same terms as Perl itself.
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/t/02packages.details.txt
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/t/02packages.details.txt 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/t/02packages.details.txt 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,18 @@
+File: 02packages.details.txt
+URL: http://www.perl.com/CPAN/modules/02packages.details.txt
+Description: Package names found in directory $CPAN/authors/id/
+Columns: package name, version, path
+Intended-For: Automated fetch routines, namespace documentation.
+Written-By: Id: mldistwatch 479 2004-01-04 13:29:05Z k
+Line-Count: 23609
+Last-Updated: Fri, 13 Feb 2004 13:50:21 GMT
+
+Acme::Colour 1.00 L/LB/LBROCARD/Acme-Colour-1.00.tar.gz
+Acme::Colour::Old 1.00 L/LB/LBROCARD/Acme-Colour-0.95.tar.gz
+Acme::ComeFrom 0.07 A/AU/AUTRIJUS/Acme-ComeFrom-0.07.tar.gz
+Acme::Comment 1.02 K/KA/KANE/Acme-Comment-1.02.tar.gz
+Acme::CramCode 0.01 X/XE/XERN/Acme-CramCode-0.01.tar.gz
+Acme::Currency 0.01 S/SM/SMUELLER/Acme-Currency-0.01.tar.gz
+accessors 0.02 S/SP/SPURKIS/accessors-0.02.tar.gz
+accessors::chained undef S/SP/SPURKIS/accessors-0.02.tar.gz
+accessors::classic undef S/SP/SPURKIS/accessors-0.02.tar.gz
Added: packages/libparse-cpan-packages-perl/branches/upstream/current/t/simple.t
===================================================================
--- packages/libparse-cpan-packages-perl/branches/upstream/current/t/simple.t 2004-06-10 14:08:50 UTC (rev 120)
+++ packages/libparse-cpan-packages-perl/branches/upstream/current/t/simple.t 2004-06-10 14:09:49 UTC (rev 121)
@@ -0,0 +1,68 @@
+#!/usr/bin/perl -w
+use strict;
+use lib 'lib';
+use Test::More tests => 23;
+use_ok("Parse::CPAN::Packages");
+
+my $p = Parse::CPAN::Packages->new("t/02packages.details.txt");
+isa_ok($p, "Parse::CPAN::Packages");
+
+my @packages = sort map { $_->package } $p->packages;
+is_deeply(\@packages,
+ [qw(Acme::Colour Acme::Colour::Old Acme::ComeFrom Acme::Comment Acme::CramCode Acme::Currency accessors accessors::chained accessors::classic )]);
+
+my $m = $p->package("Acme::Colour");
+is($m->package, "Acme::Colour");
+is($m->version, "1.00");
+
+my $d = $m->distribution;
+is($d->prefix, "L/LB/LBROCARD/Acme-Colour-1.00.tar.gz");
+is($d->dist, "Acme-Colour");
+is($d->version, "1.00");
+is($d->maturity, "released");
+is($d->filename, "Acme-Colour-1.00.tar.gz");
+is($d->cpanid, "LBROCARD");
+is($d->distvname, "Acme-Colour-1.00");
+
+is( $p->package("accessors::chained")->distribution->dist, "accessors",
+ "accessors::chained lives in accessors" );
+
+is( $p->package("accessors::classic")->distribution->dist, "accessors",
+ "as does accessors::classic" );
+
+is( $p->package("accessors::chained")->distribution,
+ $p->package("accessors::classic")->distribution,
+ "and they're using the same distribution object" );
+
+my $dist = $p->distribution('S/SP/SPURKIS/accessors-0.02.tar.gz');
+is( $dist->dist, 'accessors' );
+is( $dist, $p->package("accessors::chained")->distribution,
+ "by path match by name" );
+
+is_deeply( [ map { $_->package } $dist->contains ],
+ [ qw( accessors accessors::chained accessors::classic ) ],
+ "dist contains packages" );
+
+$d = $p->latest_distribution("Acme-Colour");
+is($d->prefix, "L/LB/LBROCARD/Acme-Colour-1.00.tar.gz");
+is($d->version, "1.00");
+
+is_deeply([sort map { $_->prefix } $p->latest_distributions], [
+ 'A/AU/AUTRIJUS/Acme-ComeFrom-0.07.tar.gz',
+ 'K/KA/KANE/Acme-Comment-1.02.tar.gz',
+ 'L/LB/LBROCARD/Acme-Colour-1.00.tar.gz',
+ 'S/SM/SMUELLER/Acme-Currency-0.01.tar.gz',
+ 'S/SP/SPURKIS/accessors-0.02.tar.gz',
+ 'X/XE/XERN/Acme-CramCode-0.01.tar.gz',
+]);
+
+open(IN, "t/02packages.details.txt");
+my $details = join '', <IN>;
+close(IN);
+
+$p = Parse::CPAN::Packages->new($details);
+isa_ok($p, "Parse::CPAN::Packages");
+
+@packages = sort map { $_->package } $p->packages;
+is_deeply(\@packages,
+ [qw(Acme::Colour Acme::Colour::Old Acme::ComeFrom Acme::Comment Acme::CramCode Acme::Currency accessors accessors::chained accessors::classic )]);