r70524 - in /branches/upstream/libcpan-changes-perl/current: Changes META.yml lib/CPAN/Changes.pm lib/Test/CPAN/Changes.pm t/self.t

gregoa at users.alioth.debian.org gregoa at users.alioth.debian.org
Sat Mar 5 20:13:14 UTC 2011


Author: gregoa
Date: Sat Mar  5 20:13:02 2011
New Revision: 70524

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=70524
Log:
[svn-upgrade] new version libcpan-changes-perl (0.07)

Modified:
    branches/upstream/libcpan-changes-perl/current/Changes
    branches/upstream/libcpan-changes-perl/current/META.yml
    branches/upstream/libcpan-changes-perl/current/lib/CPAN/Changes.pm
    branches/upstream/libcpan-changes-perl/current/lib/Test/CPAN/Changes.pm
    branches/upstream/libcpan-changes-perl/current/t/self.t

Modified: branches/upstream/libcpan-changes-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-changes-perl/current/Changes?rev=70524&op=diff
==============================================================================
--- branches/upstream/libcpan-changes-perl/current/Changes (original)
+++ branches/upstream/libcpan-changes-perl/current/Changes Sat Mar  5 20:13:02 2011
@@ -1,4 +1,8 @@
 Revision history for perl module CPAN::Changes
+
+0.07 2011-03-03
+
+  - Wrap version parsing in eval()
 
 0.06 2011-02-15
 

Modified: branches/upstream/libcpan-changes-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-changes-perl/current/META.yml?rev=70524&op=diff
==============================================================================
--- branches/upstream/libcpan-changes-perl/current/META.yml (original)
+++ branches/upstream/libcpan-changes-perl/current/META.yml Sat Mar  5 20:13:02 2011
@@ -26,4 +26,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://github.com/bricas/cpan-changes
-version: 0.06
+version: 0.07

Modified: branches/upstream/libcpan-changes-perl/current/lib/CPAN/Changes.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-changes-perl/current/lib/CPAN/Changes.pm?rev=70524&op=diff
==============================================================================
--- branches/upstream/libcpan-changes-perl/current/lib/CPAN/Changes.pm (original)
+++ branches/upstream/libcpan-changes-perl/current/lib/CPAN/Changes.pm Sat Mar  5 20:13:02 2011
@@ -8,7 +8,7 @@
 use Scalar::Util ();
 use version      ();
 
-our $VERSION = '0.06';
+our $VERSION = '0.07';
 
 sub new {
     my $class = shift;
@@ -23,9 +23,7 @@
     my ( $class, $file, @args ) = @_;
 
     open( my $fh, '<', $file ) or die $!;
-    my $changes = $class->load_string(
-        do { local $/; <$fh>; }, @args
-    );
+    my $changes = $class->load_string( do { local $/; <$fh>; }, @args );
     close( $fh );
 
     return $changes;
@@ -41,17 +39,20 @@
     $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/gs;
     my @lines = split( "\n", $string );
 
-    my $version_line_re = $changes->{next_token} 
-                        ? qr/^(?:[v0-9]|$changes->{next_token})/
-                        : qr/^[v0-9]/;
+    my $version_line_re
+        = $changes->{ next_token }
+        ? qr/^(?:[v0-9]|$changes->{next_token})/
+        : qr/^[v0-9]/;
 
     $preamble .= shift @lines while @lines && $lines[ 0 ] !~ $version_line_re;
 
     for my $l ( @lines ) {
+
         # 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;
             push @releases,
                 CPAN::Changes::Release->new(
                 version => $v,
@@ -123,17 +124,18 @@
         $self->add_release( @_ );
     }
 
-    my $sort_function = sub { 
-           ( $a->date || '' ) cmp ( $b->date || '' )
-        or version->parse( $a->version ) <=> version->parse( $b->version )
+    my $sort_function = sub {
+        ( $a->date || '' ) cmp( $b->date || '' )
+            or ( eval { version->parse( $a->version ) } || 0 )
+            <=> ( eval { version->parse( $b->version ) } || 0 );
     };
 
-    my $next_token = $self->{next_token};
+    my $next_token = $self->{ next_token };
 
     my $token_sort_function = sub {
-            $a->version =~ $next_token - $b->version =~ $next_token
-        or  $sort_function->()
-    };  
+        $a->version =~ $next_token - $b->version =~ $next_token
+            or $sort_function->();
+    };
 
     my $sort = $next_token ? $token_sort_function : $sort_function;
 

Modified: branches/upstream/libcpan-changes-perl/current/lib/Test/CPAN/Changes.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-changes-perl/current/lib/Test/CPAN/Changes.pm?rev=70524&op=diff
==============================================================================
--- branches/upstream/libcpan-changes-perl/current/lib/Test/CPAN/Changes.pm (original)
+++ branches/upstream/libcpan-changes-perl/current/lib/Test/CPAN/Changes.pm Sat Mar  5 20:13:02 2011
@@ -7,8 +7,8 @@
 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
+my $date_re    = '^\d{4}-\d{2}-\d{2}';    # "Looks like" a W3CDTF
+my $version_re = '^[._\-[:alnum:]]+$';    # "Looks like" a version
 
 sub import {
     my $self = shift;
@@ -43,20 +43,20 @@
 
     my @releases = $changes->releases;
 
-    if( !@releases ) {
+    if ( !@releases ) {
         $Test->ok( 0, "$file does not contain any releases" );
         return;
     }
 
     $Test->ok( 1, "$file contains at least one release" );
 
-    for( @releases ) {
-        if( $_->date !~ m{$date_re} ) {
+    for ( @releases ) {
+        if ( $_->date !~ m{$date_re} ) {
             $Test->ok( 0, "$file contains an invalid release date" );
             $Test->diag( '  ERR: ' . $_->date );
             return;
         }
-        if( $_->version !~ m{$version_re} ) {
+        if ( $_->version !~ m{$version_re} ) {
             $Test->ok( 0, "$file contains an invalid version number" );
             $Test->diag( '  ERR: ' . $_->version );
             return;

Modified: branches/upstream/libcpan-changes-perl/current/t/self.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libcpan-changes-perl/current/t/self.t?rev=70524&op=diff
==============================================================================
--- branches/upstream/libcpan-changes-perl/current/t/self.t (original)
+++ branches/upstream/libcpan-changes-perl/current/t/self.t Sat Mar  5 20:13:02 2011
@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 9;
+use Test::More tests => 10;
 
 use_ok( 'CPAN::Changes' );
 




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