diff options
-rwxr-xr-x | Porting/Maintainers.pl | 2 | ||||
-rw-r--r-- | cpan/CPAN-Meta/Changes | 31 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta.pm | 6 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm | 47 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm | 4 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/History.pm | 4 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm | 4 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm | 124 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm | 4 | ||||
-rw-r--r-- | cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm | 4 | ||||
-rw-r--r-- | cpan/CPAN-Meta/perlcritic.rc | 23 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/bad_version_hook.t | 49 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/converter.t | 53 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/data-bad/version-ranges-2.json | 29 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/data/version-not-normal.json | 45 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/data/version-ranges-1_4.yml | 25 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/data/version-ranges-2.json | 45 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/from-hash.t | 2 | ||||
-rw-r--r-- | cpan/CPAN-Meta/t/strings.t | 46 |
19 files changed, 491 insertions, 56 deletions
diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index bea5894605..4641176834 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -482,7 +482,7 @@ use File::Glob qw(:case); 'CPAN::Meta' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-2.120351.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/CPAN-Meta-2.120630.tar.gz', 'FILES' => q[cpan/CPAN-Meta], 'EXCLUDED' => [ qw(t/00-compile.t), diff --git a/cpan/CPAN-Meta/Changes b/cpan/CPAN-Meta/Changes index dd0f934d3e..61d6b27d67 100644 --- a/cpan/CPAN-Meta/Changes +++ b/cpan/CPAN-Meta/Changes @@ -1,5 +1,36 @@ 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] + + - Dialed back perl prereq to 5.006 + 2.120351 2012-02-03 23:01:45 America/New_York [OTHER] diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta.pm b/cpan/CPAN-Meta/lib/CPAN/Meta.pm index 29a221b6a1..f8185983a4 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta.pm @@ -2,7 +2,7 @@ use 5.006; use strict; use warnings; package CPAN::Meta; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION use Carp qw(carp croak); @@ -346,7 +346,7 @@ CPAN::Meta - the distribution metadata for a CPAN dist =head1 VERSION -version 2.120351 +version 2.120630 =head1 SYNOPSIS @@ -668,7 +668,7 @@ L<CPAN::Meta::Validator> =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 --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm index 37990f6ea1..0348e55504 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm @@ -2,11 +2,12 @@ use 5.006; use strict; use warnings; package CPAN::Meta::Converter; -our $VERSION = '2.120351'; # 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 _clean_version { } } +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 @@ sub _get_build_requires { 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 _get_build_requires { 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 @@ CPAN::Meta::Converter - Convert CPAN distribution metadata structures =head1 VERSION -version 2.120351 +version 2.120630 =head1 SYNOPSIS diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm index cc080f16c9..cd7689e9a6 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm @@ -2,7 +2,7 @@ use 5.006; use strict; use warnings; package CPAN::Meta::Feature; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION use CPAN::Meta::Prereqs; @@ -42,7 +42,7 @@ CPAN::Meta::Feature - an optional feature provided by a CPAN distribution =head1 VERSION -version 2.120351 +version 2.120630 =head1 DESCRIPTION diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/History.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/History.pm index a47c19bd69..001686e1b7 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/History.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/History.pm @@ -3,7 +3,7 @@ use 5.006; use strict; use warnings; package CPAN::Meta::History; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION 1; @@ -20,7 +20,7 @@ CPAN::Meta::History - history of CPAN Meta Spec changes =head1 VERSION -version 2.120351 +version 2.120630 =head1 DESCRIPTION diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm index 55b49832d0..640a299a01 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm @@ -2,7 +2,7 @@ use 5.006; use strict; use warnings; package CPAN::Meta::Prereqs; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION use Carp qw(confess); @@ -149,7 +149,7 @@ CPAN::Meta::Prereqs - a set of distribution prerequisites by phase and type =head1 VERSION -version 2.120351 +version 2.120630 =head1 DESCRIPTION diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm index 8b922c79c4..483a8448a5 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm @@ -1,7 +1,7 @@ use strict; use warnings; package CPAN::Meta::Requirements; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION # ABSTRACT: a set of version requirements for a CPAN dist @@ -10,19 +10,50 @@ use Scalar::Util (); 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"; + } + } + + # 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 $version; + return $vobj; } @@ -153,25 +184,32 @@ my %methods_for_op = ( '<' => [ 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 @@ CPAN::Meta::Requirements - a set of version requirements for a CPAN dist =head1 VERSION -version 2.120351 +version 2.120630 =head1 SYNOPSIS @@ -416,8 +454,21 @@ exceptions. 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 @@ C<$hashref> would contain: '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 --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm index 2ff17305c2..07d3224641 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm @@ -3,7 +3,7 @@ use 5.006; use strict; use warnings; package CPAN::Meta::Spec; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION 1; @@ -20,7 +20,7 @@ CPAN::Meta::Spec - specification for CPAN distribution metadata =head1 VERSION -version 2.120351 +version 2.120630 =head1 SYNOPSIS diff --git a/cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm b/cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm index 4c70ee1f79..1bb5359227 100644 --- a/cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm +++ b/cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm @@ -2,7 +2,7 @@ use 5.006; use strict; use warnings; package CPAN::Meta::Validator; -our $VERSION = '2.120351'; # VERSION +our $VERSION = '2.120630'; # VERSION #--------------------------------------------------------------------------# @@ -838,7 +838,7 @@ CPAN::Meta::Validator - validate CPAN distribution metadata structures =head1 VERSION -version 2.120351 +version 2.120630 =head1 SYNOPSIS diff --git a/cpan/CPAN-Meta/perlcritic.rc b/cpan/CPAN-Meta/perlcritic.rc new file mode 100644 index 0000000000..c8f9a90473 --- /dev/null +++ b/cpan/CPAN-Meta/perlcritic.rc @@ -0,0 +1,23 @@ +severity = 5 +verbose = 8 + +[Variables::ProhibitPunctuationVars] +allow = $@ $! + +[TestingAndDebugging::ProhibitNoStrict] +allow = refs + +# Turn these off +[-BuiltinFunctions::ProhibitStringyEval] +[-ControlStructures::ProhibitPostfixControls] +[-ControlStructures::ProhibitUnlessBlocks] +[-Documentation::RequirePodSections] +[-InputOutput::ProhibitInteractiveTest] +[-Miscellanea::RequireRcsKeywords] +[-References::ProhibitDoubleSigils] +[-RegularExpressions::RequireExtendedFormatting] +[-InputOutput::ProhibitTwoArgOpen] + +# Turn this on +[Lax::ProhibitStringyEval::ExceptForRequire] + diff --git a/cpan/CPAN-Meta/t/bad_version_hook.t b/cpan/CPAN-Meta/t/bad_version_hook.t new file mode 100644 index 0000000000..4b7c8c0d78 --- /dev/null +++ b/cpan/CPAN-Meta/t/bad_version_hook.t @@ -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 --git a/cpan/CPAN-Meta/t/converter.t b/cpan/CPAN-Meta/t/converter.t index ede8d03111..a4dc56c091 100644 --- a/cpan/CPAN-Meta/t/converter.t +++ b/cpan/CPAN-Meta/t/converter.t @@ -7,6 +7,7 @@ use CPAN::Meta; 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 @@ for my $f ( reverse sort @files ) { 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 --git a/cpan/CPAN-Meta/t/data-bad/version-ranges-2.json b/cpan/CPAN-Meta/t/data-bad/version-ranges-2.json new file mode 100644 index 0000000000..8c13c75274 --- /dev/null +++ b/cpan/CPAN-Meta/t/data-bad/version-ranges-2.json @@ -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 <kwilliams@cpan.org>", + "Module-Build List <module-build@perl.org>" + ], + "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 --git a/cpan/CPAN-Meta/t/data/version-not-normal.json b/cpan/CPAN-Meta/t/data/version-not-normal.json new file mode 100644 index 0000000000..a275a86faa --- /dev/null +++ b/cpan/CPAN-Meta/t/data/version-not-normal.json @@ -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 <kwilliams@cpan.org>", + "Module-Build List <module-build@perl.org>" + ], + "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 --git a/cpan/CPAN-Meta/t/data/version-ranges-1_4.yml b/cpan/CPAN-Meta/t/data/version-ranges-1_4.yml new file mode 100644 index 0000000000..7fb3c65061 --- /dev/null +++ b/cpan/CPAN-Meta/t/data/version-ranges-1_4.yml @@ -0,0 +1,25 @@ +--- +abstract: stuff +author: + - 'Ken Williams <kwilliams@cpan.org>' + - 'Module-Build List <module-build@perl.org>' +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 --git a/cpan/CPAN-Meta/t/data/version-ranges-2.json b/cpan/CPAN-Meta/t/data/version-ranges-2.json new file mode 100644 index 0000000000..6d231700ca --- /dev/null +++ b/cpan/CPAN-Meta/t/data/version-ranges-2.json @@ -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 <kwilliams@cpan.org>", + "Module-Build List <module-build@perl.org>" + ], + "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 --git a/cpan/CPAN-Meta/t/from-hash.t b/cpan/CPAN-Meta/t/from-hash.t index 369c45f694..a7f65590b7 100644 --- a/cpan/CPAN-Meta/t/from-hash.t +++ b/cpan/CPAN-Meta/t/from-hash.t @@ -41,7 +41,7 @@ sub dies_ok (&@) { }; 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 --git a/cpan/CPAN-Meta/t/strings.t b/cpan/CPAN-Meta/t/strings.t new file mode 100644 index 0000000000..300492eb13 --- /dev/null +++ b/cpan/CPAN-Meta/t/strings.t @@ -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 |