r24468 - in /branches/upstream/libparse-cpan-packages-perl/current: CHANGES META.yml lib/Parse/CPAN/Packages.pm t/simple.t
ansgar-guest at users.alioth.debian.org
ansgar-guest at users.alioth.debian.org
Fri Aug 22 15:50:37 UTC 2008
Author: ansgar-guest
Date: Fri Aug 22 15:50:29 2008
New Revision: 24468
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24468
Log:
[svn-upgrade] Integrating new upstream version, libparse-cpan-packages-perl (2.29)
Modified:
branches/upstream/libparse-cpan-packages-perl/current/CHANGES
branches/upstream/libparse-cpan-packages-perl/current/META.yml
branches/upstream/libparse-cpan-packages-perl/current/lib/Parse/CPAN/Packages.pm
branches/upstream/libparse-cpan-packages-perl/current/t/simple.t
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=24468&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/CHANGES (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/CHANGES Fri Aug 22 15:50:29 2008
@@ -1,4 +1,8 @@
CHANGES file for Parse::CPAN::Packages
+
+2.29 Tue Aug 19 18:37:02 BST 2008
+ - parse the preamble and add methods to access the fields
+ (patch by Mark Fowler)
2.28 Tue Aug 12 08:02:22 BST 2008
- stop version.pm warnings
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=24468&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/META.yml (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/META.yml Fri Aug 22 15:50:29 2008
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Parse-CPAN-Packages
-version: 2.28
+version: 2.29
abstract: ~
license: perl
author:
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=24468&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 Aug 22 15:50:29 2008
@@ -8,12 +8,12 @@
use Parse::CPAN::Packages::Package;
use version;
use vars qw($VERSION);
-$VERSION = '2.28';
+$VERSION = '2.29';
sub new {
my $class = shift;
- my $self = { data => {}, dists => {}, latestdists => {} };
+ my $self = { data => {}, dists => {}, latestdists => {}, preamble => {} };
bless $self, $class;
# read the file then parse it if present
@@ -42,15 +42,31 @@
}
}
+foreach my $subname (
+ qw(file url description columns intended_for written_by line_count last_updated)
+ )
+{
+ no strict 'refs';
+ *{$subname} = sub { return shift->{preamble}{$subname} };
+}
+
sub parse {
my $self = shift;
my $details = $self->_slurp_details(shift);
- # remove the preamble
- $details = ( split "\n\n", $details )[1];
+ # read the preamble
+ my @details = split "\n", $details;
+ while (@details) {
+ local $_ = shift @details;
+ last if /^\s*$/;
+ next unless /^([^:]+):\s*(.*)/;
+ my ( $key, $value ) = ( lc($1), $2 );
+ $key =~ tr/-/_/;
+ $self->{preamble}{$key} = $value;
+ }
# run though each line of the file
- foreach my $line ( split "\n", $details ) {
+ foreach my $line (@details) {
# make a package object from the line
my ( $package_name, $package_version, $prefix ) = split ' ', $line;
@@ -310,7 +326,7 @@
my $p = Parse::CPAN::Distribution->new($gzfilename);
my $dist = $p->distribution('L/LB/LBROCARD/Acme-Colour-1.00.tar.gz');
-=item distrbutions()
+=item distributions()
Returns a list of B<Parse::CPAN::Distribution> objects representing
all the known distributions.
@@ -337,6 +353,32 @@
=item latest_distribution_count()
Returns the number of distributions stored.
+
+=back
+
+=head2 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.
+
+=over
+
+=item file()
+
+=item url()
+
+=item description()
+
+=item columns()
+
+=item intended_for()
+
+=item written_by()
+
+=item line_count()
+
+=item last_updated()
=back
@@ -383,7 +425,7 @@
=head1 COPYRIGHT
-Copyright (C) 2004, Leon Brocard
+Copyright (C) 2004-8, Leon Brocard
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/t/simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libparse-cpan-packages-perl/current/t/simple.t?rev=24468&op=diff
==============================================================================
--- branches/upstream/libparse-cpan-packages-perl/current/t/simple.t (original)
+++ branches/upstream/libparse-cpan-packages-perl/current/t/simple.t Fri Aug 22 15:50:29 2008
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w
use strict;
use lib 'lib';
-use Test::More tests => 30;
+use Test::More tests => 38;
use_ok("Parse::CPAN::Packages");
my $p = Parse::CPAN::Packages->new("t/02packages.details.txt");
@@ -13,6 +13,19 @@
[ qw(Acme::Colour Acme::Colour::Old Acme::ComeFrom Acme::Comment Acme::CramCode Acme::Currency accessors accessors::chained accessors::classic )
]
);
+
+is( $p->file, '02packages.details.txt', 'file' );
+is( $p->url, 'http://www.perl.com/CPAN/modules/02packages.details.txt',
+ 'url' );
+is( $p->description, 'Package names found in directory $CPAN/authors/id/',
+ 'description' );
+is( $p->columns, 'package name, version, path', 'columns' );
+is( $p->intended_for, 'Automated fetch routines, namespace documentation.',
+ 'intended for' );
+is( $p->written_by, 'Id: mldistwatch 479 2004-01-04 13:29:05Z k ',
+ 'written by' );
+is( $p->line_count, 23609, 'line count' );
+is( $p->last_updated, 'Fri, 13 Feb 2004 13:50:21 GMT', 'last updated' );
my $m = $p->package("Acme::Colour");
is( $m->package, "Acme::Colour" );
More information about the Pkg-perl-cvs-commits
mailing list