Hello community, here is the log from the commit of package perl-CPAN-Meta for openSUSE:Factory checked in at 2012-03-06 13:40:42 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-CPAN-Meta (Old) and /work/SRC/openSUSE:Factory/.perl-CPAN-Meta.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-CPAN-Meta", Maintainer is "" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-CPAN-Meta/perl-CPAN-Meta.changes 2012-02-23 15:33:40.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-CPAN-Meta.new/perl-CPAN-Meta.changes 2012-03-06 13:40:44.000000000 +0100 @@ -1,0 +2,25 @@ +Tue Mar 6 07:26:18 UTC 2012 - [email protected] + +- updated to 2.120630 + [BUGFIX] + + - CPAN::Meta::Requirements now ensures that dotted-decimal versions are + represented in normalized form when stringified. This fixes a + regression in META conversion in 2.120620. + [Reported by Kent Fredric; fixed by David Golden] + + [ADDED] + + - CPAN::Meta::Requirements::add_string_requirements allows building + a requirements specification piecemeal [Cory G. Watson] + + [BUGFIX] + + - Version range handling fixed [RT#75424] + + - CPAN::Meta::Converter handles bad version strings more gracefully, + truncating alphanumerics and otherwise falling back to "0". This + is likely better than dropping a prerequisite or dying. + [RT#75427] + +------------------------------------------------------------------- Old: ---- CPAN-Meta-2.120530.tar.gz New: ---- CPAN-Meta-2.120630.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-CPAN-Meta.spec ++++++ --- /var/tmp/diff_new_pack.cSvUI6/_old 2012-03-06 13:40:45.000000000 +0100 +++ /var/tmp/diff_new_pack.cSvUI6/_new 2012-03-06 13:40:45.000000000 +0100 @@ -17,7 +17,7 @@ Name: perl-CPAN-Meta -Version: 2.120530 +Version: 2.120630 Release: 0 %define cpan_name CPAN-Meta Summary: the distribution metadata for a CPAN dist @@ -35,17 +35,18 @@ BuildRequires: perl(JSON::PP) >= 2.27103 BuildRequires: perl(Parse::CPAN::Meta) >= 1.4400 BuildRequires: perl(Test::More) >= 0.88 -BuildRequires: perl(version) >= 0.82 +BuildRequires: perl(version) >= 0.88 #BuildRequires: perl(CPAN::Meta) #BuildRequires: perl(CPAN::Meta::Converter) #BuildRequires: perl(CPAN::Meta::Feature) #BuildRequires: perl(CPAN::Meta::Prereqs) #BuildRequires: perl(CPAN::Meta::Requirements) #BuildRequires: perl(CPAN::Meta::Validator) +#BuildRequires: perl(Test::Requires) Requires: perl(CPAN::Meta::YAML) >= 0.002 Requires: perl(JSON::PP) >= 2.27103 Requires: perl(Parse::CPAN::Meta) >= 1.4400 -Requires: perl(version) >= 0.82 +Requires: perl(version) >= 0.88 %{perl_requires} %description ++++++ CPAN-Meta-2.120530.tar.gz -> CPAN-Meta-2.120630.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/Changes new/CPAN-Meta-2.120630/Changes --- old/CPAN-Meta-2.120530/Changes 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/Changes 2012-03-03 20:48:44.000000000 +0100 @@ -1,5 +1,30 @@ Revision history for CPAN-Meta +2.120630 2012-03-03 14:48:35 EST5EDT + + [BUGFIX] + + - CPAN::Meta::Requirements now ensures that dotted-decimal versions are + represented in normalized form when stringified. This fixes a + regression in META conversion in 2.120620. + [Reported by Kent Fredric; fixed by David Golden] + +2.120620 2012-03-02 12:28:59 EST5EDT + + [ADDED] + + - CPAN::Meta::Requirements::add_string_requirements allows building + a requirements specification piecemeal [Cory G. Watson] + + [BUGFIX] + + - Version range handling fixed [rt.cpan.org #75424] + + - CPAN::Meta::Converter handles bad version strings more gracefully, + truncating alphanumerics and otherwise falling back to "0". This + is likely better than dropping a prerequisite or dying. + [rt.cpan.org #75427] + 2.120530 2012-02-22 16:15:31 EST5EDT [OTHER] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/MANIFEST new/CPAN-Meta-2.120630/MANIFEST --- old/CPAN-Meta-2.120530/MANIFEST 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/MANIFEST 2012-03-03 20:48:44.000000000 +0100 @@ -24,6 +24,7 @@ perlcritic.rc t/00-compile.t t/accepts.t +t/bad_version_hook.t t/basic.t t/converter-bad.t t/converter-fail.t @@ -48,6 +49,7 @@ t/data-bad/META-1_4.yml t/data-bad/META-2.json t/data-bad/restrictive-2.json +t/data-bad/version-ranges-2.json t/data-fail/META-1_0.yml t/data-fail/META-1_1.yml t/data-fail/META-1_2.yml @@ -65,6 +67,9 @@ t/data/restricted-2.json t/data/restrictive-1_4.yml t/data/unicode.yml +t/data/version-not-normal.json +t/data/version-ranges-1_4.yml +t/data/version-ranges-2.json t/finalize.t t/from-hash.t t/load-bad.t @@ -76,6 +81,7 @@ t/prereqs.t t/repository.t t/save-load.t +t/strings.t t/validator.t xt/author/critic.t xt/author/pod-spell.t diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/META.json new/CPAN-Meta-2.120630/META.json --- old/CPAN-Meta-2.120530/META.json 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/META.json 2012-03-03 20:48:44.000000000 +0100 @@ -34,13 +34,14 @@ "Scalar::Util" : "0", "perl" : "5.006", "strict" : "0", - "version" : "0.82", + "version" : "0.88", "warnings" : "0" } }, "test" : { "requires" : { "Data::Dumper" : "0", + "File::Basename" : "0", "File::Find" : "0", "File::Spec" : "0", "File::Temp" : "0.20", @@ -54,35 +55,35 @@ "provides" : { "CPAN::Meta" : { "file" : "lib/CPAN/Meta.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::Converter" : { "file" : "lib/CPAN/Meta/Converter.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::Feature" : { "file" : "lib/CPAN/Meta/Feature.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::History" : { "file" : "lib/CPAN/Meta/History.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::Prereqs" : { "file" : "lib/CPAN/Meta/Prereqs.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::Requirements" : { "file" : "lib/CPAN/Meta/Requirements.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::Spec" : { "file" : "lib/CPAN/Meta/Spec.pm", - "version" : "2.120530" + "version" : "2.120630" }, "CPAN::Meta::Validator" : { "file" : "lib/CPAN/Meta/Validator.pm", - "version" : "2.120530" + "version" : "2.120630" } }, "release_status" : "stable", @@ -98,6 +99,6 @@ "web" : "http://github.com/dagolden/cpan-meta" } }, - "version" : "2.120530" + "version" : "2.120630" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/META.yml new/CPAN-Meta-2.120630/META.yml --- old/CPAN-Meta-2.120530/META.yml 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/META.yml 2012-03-03 20:48:44.000000000 +0100 @@ -5,6 +5,7 @@ - 'Ricardo Signes <[email protected]>' build_requires: Data::Dumper: 0 + File::Basename: 0 File::Find: 0 File::Spec: 0 File::Temp: 0.20 @@ -27,28 +28,28 @@ provides: CPAN::Meta: file: lib/CPAN/Meta.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::Converter: file: lib/CPAN/Meta/Converter.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::Feature: file: lib/CPAN/Meta/Feature.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::History: file: lib/CPAN/Meta/History.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::Prereqs: file: lib/CPAN/Meta/Prereqs.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::Requirements: file: lib/CPAN/Meta/Requirements.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::Spec: file: lib/CPAN/Meta/Spec.pm - version: 2.120530 + version: 2.120630 CPAN::Meta::Validator: file: lib/CPAN/Meta/Validator.pm - version: 2.120530 + version: 2.120630 requires: CPAN::Meta::YAML: 0.002 Carp: 0 @@ -57,10 +58,10 @@ Scalar::Util: 0 perl: 5.006 strict: 0 - version: 0.82 + version: 0.88 warnings: 0 resources: bugtracker: http://rt.cpan.org/Public/Dist/Display.html?Name=CPAN-Meta homepage: https://github.com/dagolden/cpan-meta repository: git://github.com/dagolden/cpan-meta.git -version: 2.120530 +version: 2.120630 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/Makefile.PL new/CPAN-Meta-2.120630/Makefile.PL --- old/CPAN-Meta-2.120530/Makefile.PL 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/Makefile.PL 2012-03-03 20:48:44.000000000 +0100 @@ -13,6 +13,7 @@ "AUTHOR" => "David Golden <dagolden\@cpan.org>, Ricardo Signes <rjbs\@cpan.org>", "BUILD_REQUIRES" => { "Data::Dumper" => 0, + "File::Basename" => 0, "File::Find" => 0, "File::Spec" => 0, "File::Temp" => "0.20", @@ -35,10 +36,10 @@ "Parse::CPAN::Meta" => "1.4400", "Scalar::Util" => 0, "strict" => 0, - "version" => "0.82", + "version" => "0.88", "warnings" => 0 }, - "VERSION" => "2.120530", + "VERSION" => "2.120630", "test" => { "TESTS" => "t/*.t" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/README new/CPAN-Meta-2.120630/README --- old/CPAN-Meta-2.120530/README 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/README 2012-03-03 20:48:44.000000000 +0100 @@ -2,7 +2,7 @@ CPAN::Meta - the distribution metadata for a CPAN dist VERSION - version 2.120530 + version 2.120630 SYNOPSIS my $meta = CPAN::Meta->load_file('META.json'); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/Converter.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/Converter.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/Converter.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/Converter.pm 2012-03-03 20:48:44.000000000 +0100 @@ -2,11 +2,12 @@ use strict; use warnings; package CPAN::Meta::Converter; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION use CPAN::Meta::Validator; -use version 0.82 (); +use CPAN::Meta::Requirements; +use version 0.88 (); use Parse::CPAN::Meta 1.4400 (); sub _dclone { @@ -327,29 +328,36 @@ } } +sub _bad_version_hook { + my ($v) = @_; + $v =~ s{[a-z]+$}{}; # strip trailing alphabetics + my $vobj = eval { version->parse($v) }; + return defined($vobj) ? $vobj : version->parse(0); # or give up +} + sub _version_map { my ($element) = @_; return unless defined $element; if ( ref $element eq 'HASH' ) { - my $new_map = {}; - for my $k ( keys %$element ) { + # XXX turn this into CPAN::Meta::Requirements with bad version hook + # and then turn it back into a hash + my $new_map = CPAN::Meta::Requirements->new( + { bad_version_hook => sub { version->new(0) } } # punt + ); + while ( my ($k,$v) = each %$element ) { next unless _is_module_name($k); - my $value = $element->{$k}; - if ( ! ( defined $value && length $value ) ) { - $new_map->{$k} = 0; - } - elsif ( $value eq 'undef' || $value eq '<undef>' ) { - $new_map->{$k} = 0; - } - elsif ( _is_module_name( $value ) ) { # some weird, old META have this - $new_map->{$k} = 0; - $new_map->{$value} = 0; + if ( !defined($v) || !length($v) || $v eq 'undef' || $v eq '<undef>' ) { + $v = 0; } - else { - $new_map->{$k} = _clean_version($value); + # some weird, old META have bad yml with module => module + # so check if value is like a module name and not like a version + if ( _is_module_name($v) && ! version::is_lax($v) ) { + $new_map->add_minimum($k => 0); + $new_map->add_minimum($v => 0); } + $new_map->add_string_requirement($k => $v); } - return $new_map; + return $new_map->as_string_hash; } elsif ( ref $element eq 'ARRAY' ) { my $hashref = { map { $_ => 0 } @$element }; @@ -432,7 +440,6 @@ my $test_h = _extract_prereqs($_[2]->{prereqs}, qw(test requires)) || {}; my $build_h = _extract_prereqs($_[2]->{prereqs}, qw(build requires)) || {}; - require CPAN::Meta::Requirements; my $test_req = CPAN::Meta::Requirements->from_string_hash($test_h); my $build_req = CPAN::Meta::Requirements->from_string_hash($build_h); @@ -442,7 +449,7 @@ sub _extract_prereqs { my ($prereqs, $phase, $type) = @_; return unless ref $prereqs eq 'HASH'; - return $prereqs->{$phase}{$type}; + return scalar _version_map($prereqs->{$phase}{$type}); } sub _downgrade_optional_features { @@ -1263,7 +1270,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/Feature.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/Feature.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/Feature.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/Feature.pm 2012-03-03 20:48:44.000000000 +0100 @@ -2,7 +2,7 @@ use strict; use warnings; package CPAN::Meta::Feature; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION use CPAN::Meta::Prereqs; @@ -42,7 +42,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 DESCRIPTION diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/History.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/History.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/History.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/History.pm 2012-03-03 20:48:44.000000000 +0100 @@ -3,7 +3,7 @@ use strict; use warnings; package CPAN::Meta::History; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION 1; @@ -20,7 +20,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 DESCRIPTION diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/Prereqs.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/Prereqs.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/Prereqs.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/Prereqs.pm 2012-03-03 20:48:44.000000000 +0100 @@ -2,7 +2,7 @@ use strict; use warnings; package CPAN::Meta::Prereqs; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION use Carp qw(confess); @@ -149,7 +149,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 DESCRIPTION diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/Requirements.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/Requirements.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/Requirements.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/Requirements.pm 2012-03-03 20:48:44.000000000 +0100 @@ -1,7 +1,7 @@ use strict; use warnings; package CPAN::Meta::Requirements; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION # ABSTRACT: a set of version requirements for a CPAN dist @@ -10,19 +10,50 @@ use version 0.77 (); # the ->parse method +my @valid_options = qw( bad_version_hook ); + sub new { - my ($class) = @_; - return bless {} => $class; + my ($class, $options) = @_; + $options ||= {}; + Carp::croak "Argument to $class\->new() must be a hash reference" + unless ref $options eq 'HASH'; + my %self = map {; $_ => $options->{$_}} @valid_options; + + return bless \%self => $class; } sub _version_object { my ($self, $version) = @_; - $version = (! defined $version) ? version->parse(0) + my $vobj; + + eval { + $vobj = (! defined $version) ? version->parse(0) : (! Scalar::Util::blessed($version)) ? version->parse($version) : $version; + }; + + if ( my $err = $@ ) { + my $hook = $self->{bad_version_hook}; + $vobj = eval { $hook->($version) } + if ref $hook eq 'CODE'; + unless (Scalar::Util::blessed($vobj) && $vobj->isa("version")) { + $err =~ s{ at .* line \d+.*$}{}; + die "Can't convert '$version': $err"; + } + } - return $version; + # ensure no leading '.' + if ( $vobj =~ m{\A\.} ) { + $vobj = version->parse("0$vobj"); + } + + # ensure normal v-string form + if ( $vobj->is_qv ) { + $vobj = version->parse($vobj->normal); + } + + return $vobj; } @@ -153,25 +184,32 @@ '<' => [ qw(add_maximum add_exclusion) ], ); +sub add_string_requirement { + my ($self, $module, $req) = @_; + + my @parts = split qr{\s*,\s*}, $req; + for my $part (@parts) { + my ($op, $ver) = $part =~ m{\A\s*(==|>=|>|<=|<|!=)\s*(.*)\z}; + + if (! defined $op) { + $self->add_minimum($module => $part); + } else { + Carp::confess("illegal requirement string: $req") + unless my $methods = $methods_for_op{ $op }; + + $self->$_($module => $ver) for @$methods; + } + } +} + + sub from_string_hash { my ($class, $hash) = @_; my $self = $class->new; for my $module (keys %$hash) { - my @parts = split qr{\s*,\s*}, $hash->{ $module }; - for my $part (@parts) { - my ($op, $ver) = split /\s+/, $part, 2; - - if (! defined $ver) { - $self->add_minimum($module => $op); - } else { - Carp::confess("illegal requirement string: $hash->{ $module }") - unless my $methods = $methods_for_op{ $op }; - - $self->$_($module => $ver) for @$methods; - } - } + $self->add_string_requirement($module, $hash->{ $module }); } return $self; @@ -384,7 +422,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 SYNOPSIS @@ -416,8 +454,21 @@ my $req = CPAN::Meta::Requirements->new; -This returns a new CPAN::Meta::Requirements object. It ignores any arguments -given. +This returns a new CPAN::Meta::Requirements object. It takes an optional +hash reference argument. The following keys are supported: + +=over 4 + +=item * + +<bad_version_hook> -- if provided, when a version cannot be parsed into + +a version object, this code reference will be called with the invalid version +string as an argument. It must return a valid version object. + +=back + +All other keys are ignored. =head2 add_minimum @@ -565,6 +616,37 @@ 'Xyzzy' => '== 6.01', } +=head2 add_string_requirement + + $req->add_string_requirement('Library::Foo' => '>= 1.208, <= 2.206'); + +This method parses the passed in string and adds the appropriate requirement +for the given module. It understands version ranges as described in the +L<CPAN::Meta::Spec/Version Ranges>. For example: + +=over 4 + +=item 1.3 + +=item >= 1.3 + +=item <= 1.3 + +=item == 1.3 + +=item ! 1.3 + +=item > 1.3 + +=item < 1.3 + +=item >= 1.3, ! 1.5, <= 2.0 + +A version number without an operator is equivalent to specifying a minimum +(C<E<gt>=>). Extra whitespace is allowed. + +=back + =head2 from_string_hash my $req = CPAN::Meta::Requirements->from_string_hash( \%hash ); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/Spec.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/Spec.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/Spec.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/Spec.pm 2012-03-03 20:48:44.000000000 +0100 @@ -3,7 +3,7 @@ use strict; use warnings; package CPAN::Meta::Spec; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION 1; @@ -20,7 +20,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta/Validator.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta/Validator.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta/Validator.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta/Validator.pm 2012-03-03 20:48:44.000000000 +0100 @@ -2,7 +2,7 @@ use strict; use warnings; package CPAN::Meta::Validator; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION #--------------------------------------------------------------------------# @@ -838,7 +838,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 SYNOPSIS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/lib/CPAN/Meta.pm new/CPAN-Meta-2.120630/lib/CPAN/Meta.pm --- old/CPAN-Meta-2.120530/lib/CPAN/Meta.pm 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/lib/CPAN/Meta.pm 2012-03-03 20:48:44.000000000 +0100 @@ -2,7 +2,7 @@ use strict; use warnings; package CPAN::Meta; -our $VERSION = '2.120530'; # VERSION +our $VERSION = '2.120630'; # VERSION use Carp qw(carp croak); @@ -346,7 +346,7 @@ =head1 VERSION -version 2.120530 +version 2.120630 =head1 SYNOPSIS @@ -668,7 +668,7 @@ =back -=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders +=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan =head1 SUPPORT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/bad_version_hook.t new/CPAN-Meta-2.120630/t/bad_version_hook.t --- old/CPAN-Meta-2.120530/t/bad_version_hook.t 1970-01-01 01:00:00.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/bad_version_hook.t 2012-03-03 20:48:44.000000000 +0100 @@ -0,0 +1,49 @@ +use strict; +use warnings; + +use CPAN::Meta::Requirements; +use version; + +use Test::More 0.88; + +sub dies_ok (&@) { + my ($code, $qr, $comment) = @_; + + my $lived = eval { $code->(); 1 }; + + if ($lived) { + fail("$comment: did not die"); + } else { + like($@, $qr, $comment); + } +} + +sub _fixit { return version->new(42) } + +{ + my $req = CPAN::Meta::Requirements->new( {bad_version_hook => \&_fixit} ); + + $req->add_minimum('Foo::Bar' => 10); + $req->add_minimum('Foo::Baz' => 'invalid_version'); + + is_deeply( + $req->as_string_hash, + { + 'Foo::Bar' => 10, + 'Foo::Baz' => 42, + }, + "hook fixes invalid version", + ); +} + +{ + my $req = CPAN::Meta::Requirements->new( {bad_version_hook => sub { 0 }} ); + + dies_ok { $req->add_minimum('Foo::Baz' => 'invalid_version') } + qr/Invalid version/, + "dies if hook doesn't return version object"; + +} + + +done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/converter.t new/CPAN-Meta-2.120630/t/converter.t --- old/CPAN-Meta-2.120530/t/converter.t 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/converter.t 2012-03-03 20:48:44.000000000 +0100 @@ -7,6 +7,7 @@ use CPAN::Meta::Validator; use CPAN::Meta::Converter; use File::Spec; +use File::Basename qw/basename/; use IO::Dir; use Parse::CPAN::Meta 1.4400; use version; @@ -187,4 +188,56 @@ like( $authors[0], qr/WilliƄms/, "Unicode characters preserved in authors" ); } +# specific test for version ranges +{ + my @prereq_keys = qw( + prereqs requires build_requires configure_requires + recommends conflicts + ); + for my $case ( qw/ 2 1_4 / ) { + my $suffix = $case eq 2 ? "$case.json" : "$case.yml"; + my $version = $case; + $version =~ tr[_][.]; + my $path = File::Spec->catfile('t','data','version-ranges-' . $suffix); + my $original = Parse::CPAN::Meta->load_file( $path ); + ok( $original, "loaded " . basename $path ); + my $cmc = CPAN::Meta::Converter->new( $original ); + my $converted = $cmc->convert( version => $version ); + for my $h ( $original, $converted ) { + delete $h->{generated_by}; + delete $h->{'meta-spec'}{url}; + for my $k ( @prereq_keys ) { + _normalize_reqs($h->{$k}) if exists $h->{$k}; + } + } + is_deeply( $converted, $original, "version ranges preserved in conversion" ); + } +} + +# specific test for version numbers +{ + my $path = File::Spec->catfile('t','data','version-not-normal.json'); + my $original = Parse::CPAN::Meta->load_file( $path ); + ok( $original, "loaded " . basename $path ); + my $cmc = CPAN::Meta::Converter->new( $original ); + my $converted = $cmc->convert( version => 2 ); + is( $converted->{prereqs}{runtime}{requires}{'File::Find'}, "v0.1.0", "normalize v0.1"); + is( $converted->{prereqs}{runtime}{requires}{'File::Path'}, "v1.0.0", "normalize v1.0.0"); +} + +# CMR standardizes stuff in a way that makes it hard to test original vs final +# so we remove spaces and >= to make them compare the same +sub _normalize_reqs { + my $hr = shift; + for my $k ( keys %$hr ) { + if (ref $hr->{$k} eq 'HASH') { + _normalize_reqs($hr->{$k}); + } + elsif ( ! ref $hr->{$k} ) { + $hr->{$k} =~ s{\s+}{}g; + $hr->{$k} =~ s{>=\s*}{}g; + } + } +} + done_testing; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/data/version-not-normal.json new/CPAN-Meta-2.120630/t/data/version-not-normal.json --- old/CPAN-Meta-2.120530/t/data/version-not-normal.json 1970-01-01 01:00:00.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/data/version-not-normal.json 2012-03-03 20:48:44.000000000 +0100 @@ -0,0 +1,45 @@ +{ + "generated_by" : "Module::Build version 0.36", + "meta-spec" : { + "version" : "2", + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" + }, + "abstract" : "stuff", + "version" : "0.36", + "name" : "Module-Build", + "dynamic_config" : 1, + "author" : [ + "Ken Williams <[email protected]>", + "Module-Build List <[email protected]>" + ], + "release_status" : "stable", + "license" : [ + "perl_5" + ], + "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", + "prereqs" : { + "runtime" : { + "requires" : { + "File::Copy" : "== 2.21", + "IO::File" : "> 1.12", + "Data::Dumper" : ">= 1", + "File::Spec" : "< 5", + "File::Find" : "v0.1", + "File::Path" : "1.0.0", + "Module::Metadata" : ">= v1.0.2, <= v1.0.10" + } + }, + "build" : { + "requires" : { + "Build::Requires": "1.1", + "Test::More" : "0" + } + }, + "test" : { + "requires" : { + "Test::More" : "0.88", + "Test::Requires" : "1.2" + } + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/data/version-ranges-1_4.yml new/CPAN-Meta-2.120630/t/data/version-ranges-1_4.yml --- old/CPAN-Meta-2.120530/t/data/version-ranges-1_4.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/data/version-ranges-1_4.yml 2012-03-03 20:48:44.000000000 +0100 @@ -0,0 +1,25 @@ +--- +abstract: stuff +author: + - 'Ken Williams <[email protected]>' + - 'Module-Build List <[email protected]>' +description: 'Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah' +dynamic_config: 1 +generated_by: 'Module::Build version 0.36' +license: perl +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.4.html + version: 1.4 +name: Module-Build +build_requires: + Build::Requires: 1.1 + Test::More: 0 +requires: + Data::Dumper: '>= 1' + File::Copy: '== 2.21' + File::Find: '>1, != 1.19' + File::Path: 0 + File::Spec: '< 5' + IO::File: '> 1.12' + Module::Metadata: '>= v1.0.2, <= v1.0.10' +version: 0.36 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/data/version-ranges-2.json new/CPAN-Meta-2.120630/t/data/version-ranges-2.json --- old/CPAN-Meta-2.120530/t/data/version-ranges-2.json 1970-01-01 01:00:00.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/data/version-ranges-2.json 2012-03-03 20:48:44.000000000 +0100 @@ -0,0 +1,45 @@ +{ + "generated_by" : "Module::Build version 0.36", + "meta-spec" : { + "version" : "2", + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" + }, + "abstract" : "stuff", + "version" : "0.36", + "name" : "Module-Build", + "dynamic_config" : 1, + "author" : [ + "Ken Williams <[email protected]>", + "Module-Build List <[email protected]>" + ], + "release_status" : "stable", + "license" : [ + "perl_5" + ], + "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", + "prereqs" : { + "runtime" : { + "requires" : { + "File::Copy" : "== 2.21", + "IO::File" : "> 1.12", + "Data::Dumper" : ">= 1", + "File::Spec" : "< 5", + "File::Find" : ">1, != 1.19", + "File::Path" : "0", + "Module::Metadata" : ">= v1.0.2, <= v1.0.10" + } + }, + "build" : { + "requires" : { + "Build::Requires": "1.1", + "Test::More" : "0" + } + }, + "test" : { + "requires" : { + "Test::More" : "0.88", + "Test::Requires" : "1.2" + } + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/data-bad/version-ranges-2.json new/CPAN-Meta-2.120630/t/data-bad/version-ranges-2.json --- old/CPAN-Meta-2.120530/t/data-bad/version-ranges-2.json 1970-01-01 01:00:00.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/data-bad/version-ranges-2.json 2012-03-03 20:48:44.000000000 +0100 @@ -0,0 +1,29 @@ +{ + "generated_by" : "Module::Build version 0.36", + "meta-spec" : { + "version" : "2", + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec" + }, + "abstract" : "stuff", + "version" : "0.36", + "name" : "Module-Build", + "dynamic_config" : 1, + "author" : [ + "Ken Williams <[email protected]>", + "Module-Build List <[email protected]>" + ], + "release_status" : "stable", + "license" : [ + "perl_5" + ], + "description" : "Module::Build is a system for building, testing, and installing Perl modules. It is meant to be an alternative to ExtUtils::MakeMaker... blah blah blah", + "prereqs" : { + "runtime" : { + "requires" : { + "IO::File" : "1.23beta", + "Data::Dumper" : "<= v1.2.a.3", + "File::Spec" : "== mu" + } + } + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/from-hash.t new/CPAN-Meta-2.120630/t/from-hash.t --- old/CPAN-Meta-2.120530/t/from-hash.t 2012-02-22 22:15:40.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/from-hash.t 2012-03-03 20:48:44.000000000 +0100 @@ -41,7 +41,7 @@ }; dies_ok { CPAN::Meta::Requirements->from_string_hash($string_hash) } - qr/illegal/, + qr/Can't convert/, "we die when we can't understand a version spec"; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/CPAN-Meta-2.120530/t/strings.t new/CPAN-Meta-2.120630/t/strings.t --- old/CPAN-Meta-2.120530/t/strings.t 1970-01-01 01:00:00.000000000 +0100 +++ new/CPAN-Meta-2.120630/t/strings.t 2012-03-03 20:48:44.000000000 +0100 @@ -0,0 +1,46 @@ +use strict; +use warnings; +use Test::More 0.88; + +use CPAN::Meta::Requirements; + +my $req = CPAN::Meta::Requirements->new; + +# Test == +$req->add_string_requirement('Foo::Bar', '== 1.3'); +ok($req->accepts_module('Foo::Bar' => '1.3'), 'exact version (==)'); +ok(!$req->accepts_module('Foo::Bar' => '1.2'), 'lower version (==)'); +ok(!$req->accepts_module('Foo::Bar' => '1.4'), 'higher version (==)'); + +# Test != +$req->add_string_requirement('Foo::Baz', '!= 1.3'); +ok(!$req->accepts_module('Foo::Baz' => '1.3'), 'exact version (!=)'); +ok($req->accepts_module('Foo::Baz' => '1.2'), 'lower version (!=)'); +ok($req->accepts_module('Foo::Baz' => '1.4'), 'higher version (!=)'); + +# Test >= +$req->add_string_requirement('Foo::Gorch', '>= 1.3'); +ok($req->accepts_module('Foo::Gorch' => '1.3'), 'exact version (>=)'); +ok(!$req->accepts_module('Foo::Gorch' => '1.2'), 'lower version (>=)'); +ok($req->accepts_module('Foo::Gorch' => '1.4'), 'higher version (>=)'); + +# Test <= +$req->add_string_requirement('Foo::Graz', '<= 1.3'); +ok($req->accepts_module('Foo::Graz' => '1.3'), 'exact version (<=)'); +ok($req->accepts_module('Foo::Graz' => '1.2'), 'lower version (<=)'); +ok(!$req->accepts_module('Foo::Graz' => '1.4'), 'higher version (<=)'); + +# Test "" +$req->add_string_requirement('Foo::Blurb', '>= 1.3'); +ok($req->accepts_module('Foo::Blurb' => '1.3'), 'exact version (>=)'); +ok(!$req->accepts_module('Foo::Blurb' => '1.2'), 'lower version (>=)'); +ok($req->accepts_module('Foo::Blurb' => '1.4'), 'higher version (>=)'); + +# Test multiple requirements +$req->add_string_requirement('A::Tribe::Called', '>= 1.3, <= 2.0, != 1.6'); +ok($req->accepts_module('A::Tribe::Called' => '1.5'), 'middle version (>=, <=, !)'); +ok(!$req->accepts_module('A::Tribe::Called' => '1.2'), 'lower version (>=, <=, !)'); +ok(!$req->accepts_module('A::Tribe::Called' => '2.1'), 'higher version (>=, <=, !)'); +ok(!$req->accepts_module('A::Tribe::Called' => '1.6'), 'excluded version (>=, <=, !)'); + +done_testing; \ No newline at end of file -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
