r73226 - in /trunk/libcpan-changes-perl: ./ debian/ lib/CPAN/ lib/CPAN/Changes/ lib/Test/CPAN/ t/ t/corpus/

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sat Apr 23 16:17:13 UTC 2011


Author: gregoa
Date: Sat Apr 23 16:16:56 2011
New Revision: 73226

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=73226
Log:
New upstream release.

Added:
    trunk/libcpan-changes-perl/t/corpus/dist-zilla_format.changes
      - copied unchanged from r73225, branches/upstream/libcpan-changes-perl/current/t/corpus/dist-zilla_format.changes
    trunk/libcpan-changes-perl/t/corpus/timestamp.changes
      - copied unchanged from r73225, branches/upstream/libcpan-changes-perl/current/t/corpus/timestamp.changes
    trunk/libcpan-changes-perl/t/delete_empty_groups.t
      - copied unchanged from r73225, branches/upstream/libcpan-changes-perl/current/t/delete_empty_groups.t
    trunk/libcpan-changes-perl/t/read_dist-zilla.t
      - copied unchanged from r73225, branches/upstream/libcpan-changes-perl/current/t/read_dist-zilla.t
    trunk/libcpan-changes-perl/t/read_timestamp.t
      - copied unchanged from r73225, branches/upstream/libcpan-changes-perl/current/t/read_timestamp.t
    trunk/libcpan-changes-perl/t/sort_groups.t
      - copied unchanged from r73225, branches/upstream/libcpan-changes-perl/current/t/sort_groups.t
Modified:
    trunk/libcpan-changes-perl/Changes
    trunk/libcpan-changes-perl/MANIFEST
    trunk/libcpan-changes-perl/META.yml
    trunk/libcpan-changes-perl/Makefile.PL
    trunk/libcpan-changes-perl/README
    trunk/libcpan-changes-perl/debian/changelog
    trunk/libcpan-changes-perl/lib/CPAN/Changes.pm
    trunk/libcpan-changes-perl/lib/CPAN/Changes/Release.pm
    trunk/libcpan-changes-perl/lib/Test/CPAN/Changes.pm
    trunk/libcpan-changes-perl/t/self.t

Modified: trunk/libcpan-changes-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/Changes?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/Changes (original)
+++ trunk/libcpan-changes-perl/Changes Sat Apr 23 16:16:56 2011
@@ -1,4 +1,53 @@
 Revision history for perl module CPAN::Changes
+
+0.17 2011-04-21
+
+  - Eliminate extra whitespace when release data is not defined (RT #67441)
+
+  - Require version.pm 0.79, which introduced the $LAX regexp (RT #67613)
+
+  - Add the option to sort groups (Yanick Champoux)
+
+0.16 2011-04-12
+
+  - Expose W3CDTF regex variable
+
+  - Allow whitespace in some dates
+
+  - Extract out valid W3CDTF portions from dates
+
+  - Requires perl 5.10
+
+0.15 2011-04-11
+
+  - Handle more date/time formats during parsing
+
+0.14 2011-04-11
+
+  - Add delete_empty_groups() to Changes.pm and Release.pm (Yanick Champoux) 
+
+0.13 2011-04-04
+
+  - Use version.pm's LAX regex for finding versions.
+
+0.12 2011-04-04
+
+  - Sort releases() by version first for greater consistency
+
+0.11 2011-03-31
+
+  - Parse the default Dist-Zilla date format (e.g. 2010-12-28 00:15:12 
+    Europe/London)
+
+0.10 2011-03-29
+
+  - Be more strict about date validation in Test::CPAN::Changes
+
+0.09 2011-03-29
+
+  - Be more lenient when parsing dates. Timestamps (e.g. 
+    Tue Mar 29 08:32:16 2011) are now parsed and converted to W3CDTF. (Fixes 
+    RT #66862)
 
 0.08 2011-03-14
 

Modified: trunk/libcpan-changes-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/MANIFEST?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/MANIFEST (original)
+++ trunk/libcpan-changes-perl/MANIFEST Sat Apr 23 16:16:56 2011
@@ -19,6 +19,7 @@
 t/corpus/basic.changes
 t/corpus/different-indentation.changes
 t/corpus/dist-zilla.changes
+t/corpus/dist-zilla_format.changes
 t/corpus/group-brackets.changes
 t/corpus/group.changes
 t/corpus/line-continuation.changes
@@ -26,9 +27,12 @@
 t/corpus/no-leading-space-for-change.changes
 t/corpus/preamble.changes
 t/corpus/space-before-date.changes
+t/corpus/timestamp.changes
+t/delete_empty_groups.t
 t/dist-zilla-changes.t
 t/read_basic.t
 t/read_different-indentation.t
+t/read_dist-zilla.t
 t/read_group-brackets.t
 t/read_group.t
 t/read_line-continuation.t
@@ -36,7 +40,9 @@
 t/read_no-leading-space-for-change.t
 t/read_preamble.t
 t/read_space-before-date.t
+t/read_timestamp.t
 t/self.t
 t/serialize.t
+t/sort_groups.t
 xt/release/pod.t
 xt/release/pod_coverage.t

Modified: trunk/libcpan-changes-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/META.yml?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/META.yml (original)
+++ trunk/libcpan-changes-perl/META.yml Sat Apr 23 16:16:56 2011
@@ -21,9 +21,9 @@
     - xt
 requires:
   Text::Wrap: 0
-  perl: 5.8.0
-  version: 0
+  perl: 5.10.0
+  version: 0.79
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://github.com/bricas/cpan-changes
-version: 0.08
+version: 0.17

Modified: trunk/libcpan-changes-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/Makefile.PL?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/Makefile.PL (original)
+++ trunk/libcpan-changes-perl/Makefile.PL Sat Apr 23 16:16:56 2011
@@ -4,13 +4,13 @@
     system( 'pod2text lib/CPAN/Changes.pm > README' );
 }
 
-perl_version '5.008';
+perl_version '5.010';
 
 name 'CPAN-Changes';
 all_from 'lib/CPAN/Changes.pm';
 
 requires 'Text::Wrap';
-requires 'version';
+requires 'version' => '0.79';
 
 test_requires 'Test::More';
 extra_tests;

Modified: trunk/libcpan-changes-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/README?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/README (original)
+++ trunk/libcpan-changes-perl/README Sat Apr 23 16:16:56 2011
@@ -77,9 +77,15 @@
     Returns the release object for the specified version. Should there be no
     matching release object, undef is returned.
 
-  serialize( )
+  serialize( group_sort => \&sorting_function )
     Returns all of the data as a string, suitable for saving as a Changes
     file.
+
+    If *group_sort* is provided, change groups are sorted according to the
+    given function. If not, groups are sorted alphabetically.
+
+  delete_empty_groups( )
+    Deletes change groups without changes in all releases.
 
 DEALING WITH "NEXT VERSION" PLACEHOLDERS
     In the working copy of a distribution, it's not uncommon to have a "next

Modified: trunk/libcpan-changes-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/debian/changelog?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/debian/changelog (original)
+++ trunk/libcpan-changes-perl/debian/changelog Sat Apr 23 16:16:56 2011
@@ -1,3 +1,9 @@
+libcpan-changes-perl (0.17-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- gregor herrmann <gregoa at debian.org>  Sat, 23 Apr 2011 18:15:46 +0200
+
 libcpan-changes-perl (0.08-1) unstable; urgency=low
 
   * New upstream release

Modified: trunk/libcpan-changes-perl/lib/CPAN/Changes.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/lib/CPAN/Changes.pm?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/lib/CPAN/Changes.pm (original)
+++ trunk/libcpan-changes-perl/lib/CPAN/Changes.pm Sat Apr 23 16:16:56 2011
@@ -8,13 +8,32 @@
 use Scalar::Util ();
 use version      ();
 
-our $VERSION = '0.08';
+our $VERSION = '0.17';
+
+# From DateTime::Format::W3CDTF
+our $W3CDTF_REGEX = qr{(\d\d\d\d) # Year
+                 (?:-(\d\d) # -Month
+                 (?:-(\d\d) # -Day
+                 (?:T
+                   (\d\d):(\d\d) # Hour:Minute
+                   (?:
+                     :(\d\d)     # :Second
+                     (\.\d+)?    # .Fractional_Second
+                   )?
+                   ( Z          # UTC
+                   | [+-]\d\d:\d\d    # Hour:Minute TZ offset
+                     (?::\d\d)?       # :Second TZ offset
+                 )?)?)?)?}x;
+
+my @m = qw( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec );
+my %months = map { $m[ $_ ] => $_ + 1 } 0 .. 11;
 
 sub new {
     my $class = shift;
     return bless {
         preamble => '',
         releases => {},
+        months   => \%months,
         @_,
     }, $class;
 }
@@ -41,8 +60,8 @@
 
     my $version_line_re
         = $changes->{ next_token }
-        ? qr/^(?:[v0-9]|$changes->{next_token})/
-        : qr/^[v0-9]/;
+        ? qr/^(?:$version::LAX|$changes->{next_token})/
+        : qr/^$version::LAX/;
 
     $preamble .= shift @lines while @lines && $lines[ 0 ] !~ $version_line_re;
 
@@ -50,9 +69,55 @@
 
         # Version & Date
         if ( $l =~ $version_line_re ) {
-
-            # currently ignores data after the date; could be useful later
-            my ( $v, $d ) = split m{\s+}, $l;
+            my ( $v, $d ) = split m{\s+}, $l, 2;
+
+            # munge date formats, ignore junk
+            if ( $d ) {
+
+                # handle localtime-like timestamps
+                if ( $d
+                    =~ m{\D{3}\s+(\D{3})\s+(\d{1,2})\s+([\d:]+)?\D*(\d{4})} )
+                {
+                    if ( $3 ) {
+
+                        # unfortunately ignores TZ data
+                        $d = sprintf(
+                            '%d-%02d-%02dT%sZ',
+                            $4, $changes->{ months }->{ $1 },
+                            $2, $3
+                        );
+                    }
+                    else {
+                        $d = sprintf( '%d-%02d-%02d',
+                            $4, $changes->{ months }->{ $1 }, $2 );
+                    }
+                }
+
+                # RFC 2822
+                elsif ( $d
+                    =~ m{\D{3}, (\d{1,2}) (\D{3}) (\d{4}) (\d\d:\d\d:\d\d) ([+-])(\d{2})(\d{2})}
+                    )
+                {
+                    $d = sprintf(
+                        '%d-%02d-%02dT%s%s%02d:%02d',
+                        $3, $changes->{ months }->{ $2 },
+                        $1, $4, $5, $6, $7
+                    );
+                }
+
+                # handle dist-zilla style, again ingoring TZ data
+                elsif ( $d
+                    =~ m{(\d{4}-\d\d-\d\d)\s+(\d\d:\d\d(?::\d\d)?)(\s+\D+)?} )
+                {
+                    $d = sprintf( '%sT%sZ', $1, $2 );
+                }
+
+                # start with W3CDTF, ignore rest
+                elsif ( $d =~ m{^($W3CDTF_REGEX)}p ) {
+                    $d = ${^MATCH};
+                }
+            }
+
             push @releases,
                 CPAN::Changes::Release->new(
                 version => $v,
@@ -84,7 +149,7 @@
         $l =~ s{^$indent}{};
 
         # Inconsistent indentation between releases
-        if( $l =~ m{^\s} && !@{ $releases[ -1 ]->changes( $ingroup ) } ) {
+        if ( $l =~ m{^\s} && !@{ $releases[ -1 ]->changes( $ingroup ) } ) {
             $l =~ m{^(\s+)};
             $indent = $1;
             $l =~ s{^\s+}{};
@@ -132,9 +197,9 @@
     }
 
     my $sort_function = sub {
-        ( $a->date || '' ) cmp( $b->date || '' )
-            or ( eval { version->parse( $a->version ) } || 0 )
-            <=> ( eval { version->parse( $b->version ) } || 0 );
+        ( eval { version->parse( $a->version ) } || 0 )
+            <=> ( eval { version->parse( $b->version ) } || 0 )
+            or ( $a->date || '' ) cmp( $b->date || '' );
     };
 
     my $next_token = $self->{ next_token };
@@ -172,13 +237,24 @@
     return $self->{ releases }->{ $version };
 }
 
+sub delete_empty_groups {
+    my $self = shift;
+
+    $_->delete_empty_groups for $self->releases;
+}
+
 sub serialize {
     my $self = shift;
+    my %args = @_;
+
+    my %release_args;
+    $release_args{ group_sort } = $args{ group_sort } if $args{ group_sort };
 
     my $output;
 
     $output = $self->preamble . "\n\n" if $self->preamble;
-    $output .= join( "\n", $_->serialize ) for reverse $self->releases;
+    $output .= join "\n", $_->serialize( %release_args )
+        for reverse $self->releases;
 
     return $output;
 }
@@ -284,10 +360,18 @@
 Returns the release object for the specified version. Should there be no 
 matching release object, undef is returned.
 
-=head2 serialize( )
+=head2 serialize( group_sort => \&sorting_function )
 
 Returns all of the data as a string, suitable for saving as a Changes 
 file.
+
+If I<group_sort> is provided, change groups are
+sorted according to the given function. If not,
+groups are sorted alphabetically.
+
+=head2 delete_empty_groups( )
+
+Deletes change groups without changes in all releases.
 
 =head1 DEALING WITH "NEXT VERSION" PLACEHOLDERS
 

Modified: trunk/libcpan-changes-perl/lib/CPAN/Changes/Release.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/lib/CPAN/Changes/Release.pm?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/lib/CPAN/Changes/Release.pm (original)
+++ trunk/libcpan-changes-perl/lib/CPAN/Changes/Release.pm Sat Apr 23 16:16:56 2011
@@ -76,7 +76,11 @@
 
 sub groups {
     my $self = shift;
-    return sort keys %{ $self->{ changes } };
+    my %args = @_;
+
+    $args{ sort } ||= sub { sort @_ };
+
+    return $args{ sort }->( keys %{ $self->{ changes } } );
 }
 
 sub add_group {
@@ -93,13 +97,22 @@
     delete $self->{ changes }->{ $_ } for @groups;
 }
 
+sub delete_empty_groups {
+    my $self = shift;
+
+    $self->delete_group( grep { !@{ $self->changes( $_ ) } } $self->groups );
+}
+
 sub serialize {
     my $self = shift;
-
-    my $output = sprintf "%s %s\n", $self->version, $self->date;
-
-    $output
-        .= join( "\n", map { $self->_serialize_group( $_ ) } $self->groups );
+    my %args = @_;
+
+    my $output = join( ' ', grep { defined } ( $self->version, $self->date ) )
+        . "\n";
+
+    $output .= join "\n",
+        map { $self->_serialize_group( $_ ) }
+        $self->groups( sort => $args{ group_sort } );
     $output .= "\n";
 
     return $output;
@@ -185,10 +198,14 @@
 
 Clears all changes from the release.
 
-=head2 groups( )
+=head2 groups( sort => \&sorting_function )
 
 Returns a list of current groups in this release.
 
+If I<sort> is provided, groups are
+sorted according to the given function. If not,
+they are sorted alphabetically.
+
 =head2 add_group( @groups )
 
 Creates an empty group under the names provided.
@@ -197,11 +214,19 @@
 
 Deletes the groups of changes specified.
 
-=head2 serialize( )
+=head2 delete_empty_groups( )
+
+Deletes all groups that don't contain any changes.
+
+=head2 serialize( group_sort => \&sorting_function )
 
 Returns the release data as a string, suitable for inclusion in a Changes 
 file.
 
+If I<group_sort> is provided, change groups are
+sorted according to the given function. If not,
+groups are sorted alphabetically.
+
 =head1 SEE ALSO
 
 =over 4

Modified: trunk/libcpan-changes-perl/lib/Test/CPAN/Changes.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/lib/Test/CPAN/Changes.pm?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/lib/Test/CPAN/Changes.pm (original)
+++ trunk/libcpan-changes-perl/lib/Test/CPAN/Changes.pm Sat Apr 23 16:16:56 2011
@@ -7,7 +7,6 @@
 use Test::Builder;
 
 my $Test       = Test::Builder->new;
-my $date_re    = '^\d{4}-\d{2}-\d{2}';    # "Looks like" a W3CDTF
 my $version_re = '^[._\-[:alnum:]]+$';    # "Looks like" a version
 
 sub import {
@@ -51,7 +50,7 @@
     $Test->ok( 1, "$file contains at least one release" );
 
     for ( @releases ) {
-        if ( $_->date !~ m{$date_re} ) {
+        if ( $_->date !~ m{^${CPAN::Changes::W3CDTF_REGEX}\s*$} ) {
             $Test->ok( 0, "$file contains an invalid release date" );
             $Test->diag( '  ERR: ' . $_->date );
             return;

Modified: trunk/libcpan-changes-perl/t/self.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcpan-changes-perl/t/self.t?rev=73226&op=diff
==============================================================================
--- trunk/libcpan-changes-perl/t/self.t (original)
+++ trunk/libcpan-changes-perl/t/self.t Sat Apr 23 16:16:56 2011
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 11;
+use Test::More tests => 20;
 
 use_ok( 'CPAN::Changes' );
 




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