r24471 - in /trunk/libparse-cpan-packages-perl: CHANGES META.yml debian/changelog debian/control debian/copyright 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 16:00:53 UTC 2008


Author: ansgar-guest
Date: Fri Aug 22 16:00:50 2008
New Revision: 24471

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=24471
Log:
* New upstream release.
  + Update copyright years in debian/copyright
* Add myself to Uploaders.

Modified:
    trunk/libparse-cpan-packages-perl/CHANGES
    trunk/libparse-cpan-packages-perl/META.yml
    trunk/libparse-cpan-packages-perl/debian/changelog
    trunk/libparse-cpan-packages-perl/debian/control
    trunk/libparse-cpan-packages-perl/debian/copyright
    trunk/libparse-cpan-packages-perl/lib/Parse/CPAN/Packages.pm
    trunk/libparse-cpan-packages-perl/t/simple.t

Modified: trunk/libparse-cpan-packages-perl/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/CHANGES?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/CHANGES (original)
+++ trunk/libparse-cpan-packages-perl/CHANGES Fri Aug 22 16:00:50 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: trunk/libparse-cpan-packages-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/META.yml?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/META.yml (original)
+++ trunk/libparse-cpan-packages-perl/META.yml Fri Aug 22 16:00:50 2008
@@ -1,6 +1,6 @@
 --- #YAML:1.0
 name:                Parse-CPAN-Packages
-version:             2.28
+version:             2.29
 abstract:            ~
 license:             perl
 author:              

Modified: trunk/libparse-cpan-packages-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/debian/changelog?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/debian/changelog (original)
+++ trunk/libparse-cpan-packages-perl/debian/changelog Fri Aug 22 16:00:50 2008
@@ -1,3 +1,11 @@
+libparse-cpan-packages-perl (2.29-1) unstable; urgency=low
+
+  * New upstream release.
+    + Update copyright years in debian/copyright
+  * Add myself to Uploaders.
+
+ -- Ansgar Burchardt <ansgar at 43-1.org>  Fri, 22 Aug 2008 18:00:36 +0200
+
 libparse-cpan-packages-perl (2.28-1) unstable; urgency=low
 
   [ Frank Lichtenheld ]

Modified: trunk/libparse-cpan-packages-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/debian/control?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/debian/control (original)
+++ trunk/libparse-cpan-packages-perl/debian/control Fri Aug 22 16:00:50 2008
@@ -6,7 +6,8 @@
  Niko Tyni <ntyni at iki.fi>, 
  gregor herrmann <gregoa at debian.org>, 
  Gunnar Wolf <gwolf at debian.org>,
- Jaldhar H. Vyas <jaldhar at debian.org>
+ Jaldhar H. Vyas <jaldhar at debian.org>,
+ Ansgar Burchardt <ansgar at 43-1.org>
 Build-Depends: debhelper (>= 7)
 Build-Depends-Indep: perl (>= 5.6.0-16), libsort-versions-perl (>= 1.5), 
  libcpan-distnameinfo-perl (>= 0.03), libclass-accessor-perl (>= 0.19), 

Modified: trunk/libparse-cpan-packages-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/debian/copyright?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/debian/copyright (original)
+++ trunk/libparse-cpan-packages-perl/debian/copyright Fri Aug 22 16:00:50 2008
@@ -11,7 +11,7 @@
     on dh-make-perl.
 
 Files: *
-Copyright: 2004, Leon Brocard <acme at astray.com>
+Copyright: 2004-2008, Leon Brocard <acme at astray.com>
 License-Alias: Perl
 License: Artistic | GPL-1+
 

Modified: trunk/libparse-cpan-packages-perl/lib/Parse/CPAN/Packages.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/lib/Parse/CPAN/Packages.pm?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/lib/Parse/CPAN/Packages.pm (original)
+++ trunk/libparse-cpan-packages-perl/lib/Parse/CPAN/Packages.pm Fri Aug 22 16:00:50 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: trunk/libparse-cpan-packages-perl/t/simple.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libparse-cpan-packages-perl/t/simple.t?rev=24471&op=diff
==============================================================================
--- trunk/libparse-cpan-packages-perl/t/simple.t (original)
+++ trunk/libparse-cpan-packages-perl/t/simple.t Fri Aug 22 16:00:50 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