In perl.git, the branch blead has been updated <http://perl5.git.perl.org/perl.git/commitdiff/52beaae7e855a9b9a072ca4d74a4fe12101aa915?hp=a7026383bc5a2ca5f518f670ee6d74d55cd994aa>
- Log ----------------------------------------------------------------- commit 52beaae7e855a9b9a072ca4d74a4fe12101aa915 Merge: c5e1025 a702638 Author: Abigail <[email protected]> Date: Tue Mar 13 13:22:28 2012 +0100 Merge branch 'blead' of ssh://perl5.git.perl.org/gitroot/perl into blead commit c5e1025967d870bd7b4198c6c309a6977fae2dd8 Author: Abigail <[email protected]> Date: Tue Mar 13 13:20:31 2012 +0100 Exclude perlcritic.rc files. Listed perlcritic.rc in the @IGNORABLE array of Porting/Maintainers.pl, and removed the files from the new cpan/CPAN-Meta and cpan/HTTP-Tiny distros. M Porting/Maintainers.pl D cpan/CPAN-Meta/perlcritic.rc D cpan/HTTP-Tiny/perlcritic.rc commit 60b51e19643d61402426602d01ba4a4848040dbf Author: Abigail <[email protected]> Date: Tue Mar 13 13:20:03 2012 +0100 List the new files that came with the upgrade of CPAN-Meta M MANIFEST commit 4984624cf2e810bfe95a013fd9ae79e26ef3e5fc Author: Abigail <[email protected]> Date: Tue Mar 13 02:32:44 2012 +0100 Upgrade HTTP::Tiny to 0.017. M Porting/Maintainers.pl M cpan/HTTP-Tiny/lib/HTTP/Tiny.pm A cpan/HTTP-Tiny/perlcritic.rc M cpan/HTTP-Tiny/t/00-compile.t commit adcd8125fe0adb4fcdd1607acd5a30f364a43564 Author: Abigail <[email protected]> Date: Tue Mar 13 02:02:18 2012 +0100 Upgrade cpan/CPAN-Meta to 2.120630 M Porting/Maintainers.pl M cpan/CPAN-Meta/Changes M cpan/CPAN-Meta/lib/CPAN/Meta.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm M cpan/CPAN-Meta/lib/CPAN/Meta/History.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm M cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm A cpan/CPAN-Meta/perlcritic.rc A cpan/CPAN-Meta/t/bad_version_hook.t M cpan/CPAN-Meta/t/converter.t A cpan/CPAN-Meta/t/data-bad/version-ranges-2.json A cpan/CPAN-Meta/t/data/version-not-normal.json A cpan/CPAN-Meta/t/data/version-ranges-1_4.yml A cpan/CPAN-Meta/t/data/version-ranges-2.json M cpan/CPAN-Meta/t/from-hash.t A cpan/CPAN-Meta/t/strings.t ----------------------------------------------------------------------- Summary of changes: MANIFEST | 6 + Porting/Maintainers.pl | 8 +- cpan/CPAN-Meta/Changes | 31 ++++++ cpan/CPAN-Meta/lib/CPAN/Meta.pm | 6 +- cpan/CPAN-Meta/lib/CPAN/Meta/Converter.pm | 47 +++++---- cpan/CPAN-Meta/lib/CPAN/Meta/Feature.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/History.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Prereqs.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm | 124 +++++++++++++++++++---- cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm | 4 +- cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm | 4 +- cpan/CPAN-Meta/t/bad_version_hook.t | 49 +++++++++ cpan/CPAN-Meta/t/converter.t | 53 ++++++++++ cpan/CPAN-Meta/t/data-bad/version-ranges-2.json | 29 ++++++ cpan/CPAN-Meta/t/data/version-not-normal.json | 45 ++++++++ cpan/CPAN-Meta/t/data/version-ranges-1_4.yml | 25 +++++ cpan/CPAN-Meta/t/data/version-ranges-2.json | 45 ++++++++ cpan/CPAN-Meta/t/from-hash.t | 2 +- cpan/CPAN-Meta/t/strings.t | 46 +++++++++ cpan/HTTP-Tiny/lib/HTTP/Tiny.pm | 42 +++++--- cpan/HTTP-Tiny/t/00-compile.t | 22 ++++- 21 files changed, 520 insertions(+), 80 deletions(-) create mode 100644 cpan/CPAN-Meta/t/bad_version_hook.t create mode 100644 cpan/CPAN-Meta/t/data-bad/version-ranges-2.json create mode 100644 cpan/CPAN-Meta/t/data/version-not-normal.json create mode 100644 cpan/CPAN-Meta/t/data/version-ranges-1_4.yml create mode 100644 cpan/CPAN-Meta/t/data/version-ranges-2.json create mode 100644 cpan/CPAN-Meta/t/strings.t diff --git a/MANIFEST b/MANIFEST index 449b590..fb33cec 100644 --- a/MANIFEST +++ b/MANIFEST @@ -325,6 +325,7 @@ cpan/CPAN-Meta/lib/CPAN/Meta/Requirements.pm cpan/CPAN-Meta/lib/CPAN/Meta/Spec.pm cpan/CPAN-Meta/lib/CPAN/Meta/Validator.pm cpan/CPAN-Meta/t/accepts.t +cpan/CPAN-Meta/t/bad_version_hook.t cpan/CPAN-Meta/t/basic.t cpan/CPAN-Meta/t/converter-bad.t cpan/CPAN-Meta/t/converter-fail.t @@ -349,6 +350,7 @@ cpan/CPAN-Meta/t/data-bad/META-1_3.yml cpan/CPAN-Meta/t/data-bad/META-1_4.yml cpan/CPAN-Meta/t/data-bad/META-2.json cpan/CPAN-Meta/t/data-bad/restrictive-2.json +cpan/CPAN-Meta/t/data-bad/version-ranges-2.json cpan/CPAN-Meta/t/data-fail/META-1_0.yml cpan/CPAN-Meta/t/data-fail/META-1_1.yml cpan/CPAN-Meta/t/data-fail/META-1_2.yml @@ -366,6 +368,9 @@ cpan/CPAN-Meta/t/data/resources.yml cpan/CPAN-Meta/t/data/restricted-2.json cpan/CPAN-Meta/t/data/restrictive-1_4.yml cpan/CPAN-Meta/t/data/unicode.yml +cpan/CPAN-Meta/t/data/version-not-normal.json +cpan/CPAN-Meta/t/data/version-ranges-1_4.yml +cpan/CPAN-Meta/t/data/version-ranges-2.json cpan/CPAN-Meta/t/finalize.t cpan/CPAN-Meta/t/from-hash.t cpan/CPAN-Meta/t/load-bad.t @@ -377,6 +382,7 @@ cpan/CPAN-Meta/t/prereqs-merge.t cpan/CPAN-Meta/t/prereqs.t cpan/CPAN-Meta/t/repository.t cpan/CPAN-Meta/t/save-load.t +cpan/CPAN-Meta/t/strings.t cpan/CPAN-Meta/t/validator.t cpan/CPAN-Meta-YAML/lib/CPAN/Meta/YAML.pm CPAN-Meta-YAML files cpan/CPAN-Meta-YAML/t/01_compile.t CPAN-Meta-YAML files diff --git a/Porting/Maintainers.pl b/Porting/Maintainers.pl index bea5894..772a950 100755 --- a/Porting/Maintainers.pl +++ b/Porting/Maintainers.pl @@ -104,8 +104,8 @@ use File::Glob qw(:case); CHANGELOG ChangeLog CHANGES Changes COPYING Copying CREDITS dist.ini GOALS HISTORY INSTALL INSTALL.SKIP LICENSE Makefile.PL MANIFEST MANIFEST.SKIP META.yml MYMETA.yml META.json MYMETA.json - NEW NOTES ppport.h README README.PATCHING SIGNATURE THANKS TODO Todo - VERSION WHATSNEW + NEW NOTES perlcritic.rc ppport.h README README.PATCHING SIGNATURE + THANKS TODO Todo VERSION WHATSNEW ); # Each entry in the %Modules hash roughly represents a distribution, @@ -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), @@ -955,7 +955,7 @@ use File::Glob qw(:case); 'HTTP::Tiny' => { 'MAINTAINER' => 'dagolden', - 'DISTRIBUTION' => 'DAGOLDEN/HTTP-Tiny-0.016.tar.gz', + 'DISTRIBUTION' => 'DAGOLDEN/HTTP-Tiny-0.017.tar.gz', 'FILES' => q[cpan/HTTP-Tiny], 'EXCLUDED' => [ 't/200_live.t', diff --git a/cpan/CPAN-Meta/Changes b/cpan/CPAN-Meta/Changes index dd0f934..61d6b27 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 29a221b..f818598 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 37990f6..0348e55 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 cc080f1..cd7689e 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 a47c19b..001686e 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 55b4983..640a299 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 8b922c7..483a844 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 2ff1730..07d3224 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 4c70ee1..1bb5359 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/t/bad_version_hook.t b/cpan/CPAN-Meta/t/bad_version_hook.t new file mode 100644 index 0000000..4b7c8c0 --- /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 ede8d03..a4dc56c 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 0000000..8c13c75 --- /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 <[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 --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 0000000..a275a86 --- /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 <[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 --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 0000000..7fb3c65 --- /dev/null +++ b/cpan/CPAN-Meta/t/data/version-ranges-1_4.yml @@ -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 --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 0000000..6d23170 --- /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 <[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 --git a/cpan/CPAN-Meta/t/from-hash.t b/cpan/CPAN-Meta/t/from-hash.t index 369c45f..a7f6559 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 0000000..300492e --- /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 diff --git a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm index c9a2dca..46dce74 100644 --- a/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm +++ b/cpan/HTTP-Tiny/lib/HTTP/Tiny.pm @@ -3,7 +3,7 @@ package HTTP::Tiny; use strict; use warnings; # ABSTRACT: A small, simple, correct HTTP/1.1 client -our $VERSION = '0.016'; # VERSION +our $VERSION = '0.017'; # VERSION use Carp (); @@ -48,7 +48,7 @@ sub new { for my $sub_name ( qw/get head put post delete/ ) { my $req_method = uc $sub_name; no strict 'refs'; - eval <<"HERE"; + eval <<"HERE"; ## no critic sub $sub_name { my (\$self, \$url, \$args) = \@_; \@_ == 2 || (\@_ == 3 && ref \$args eq 'HASH') @@ -382,7 +382,7 @@ use warnings; use Errno qw[EINTR EPIPE]; use IO::Socket qw[SOCK_STREAM]; -sub BUFSIZE () { 32768 } +sub BUFSIZE () { 32768 } ## no critic my $Printable = sub { local $_ = shift; @@ -840,7 +840,7 @@ HTTP::Tiny - A small, simple, correct HTTP/1.1 client =head1 VERSION -version 0.016 +version 0.017 =head1 SYNOPSIS @@ -881,43 +881,47 @@ This constructor returns a new HTTP::Tiny object. Valid attributes include: =item * -agent +C<agent> A user-agent string (defaults to 'HTTP::Tiny/$VERSION') =item * -default_headers +C<default_headers> A hashref of default headers to apply to requests =item * -max_redirect +C<max_redirect> Maximum number of redirects allowed (defaults to 5) =item * -max_size +C<max_size> Maximum response size (only when not using a data callback). If defined, -responses larger than this will die with an error message +responses larger than this will return an exception. =item * -proxy +C<proxy> URL of a proxy server to use (default is C<$ENV{http_proxy}> if set) =item * -timeout +C<timeout> Request timeout in seconds (default is 60) =back +Exceptions from C<max_size>, C<timeout> or other errors will result in a +pseudo-HTTP status code of 599 and a reason of "Internal Exception". The +content field in the response will contain the text of the exception. + =head2 get|head|put|post|delete $response = $http->get($url); @@ -928,6 +932,8 @@ These methods are shorthand for calling C<request()> for the given method. The URL must have unsafe characters escaped and international domain names encoded. See C<request()> for valid options and a description of the response. +The C<success> field of the response will be true if the status code is 2XX. + =head2 post_form $response = $http->post_form($url, $form_data); @@ -942,6 +948,8 @@ The URL must have unsafe characters escaped and international domain names encoded. See C<request()> for valid options and a description of the response. Any C<content-type> header or content in the options hashref will be ignored. +The C<success> field of the response will be true if the status code is 2XX. + =head2 mirror $response = $http->mirror($url, $file, \%options) @@ -953,11 +961,11 @@ Executes a C<GET> request for the URL and saves the response body to the file name provided. The URL must have unsafe characters escaped and international domain names encoded. If the file already exists, the request will includes an C<If-Modified-Since> header with the modification timestamp of the file. You -may specificy a different C<If-Modified-Since> header yourself in the C<< +may specify a different C<If-Modified-Since> header yourself in the C<< $options->{headers} >> hash. The C<success> field of the response will be true if the status code is 2XX -or 304 (unmodified). +or if the status code is 304 (unmodified). If the file was modified and the server response includes a properly formatted C<Last-Modified> header, the file modification time will @@ -1168,9 +1176,9 @@ L<LWP::UserAgent> =head2 Bugs / Feature Requests -Please report any bugs or feature requests by email to C<bug-http-tiny at rt.cpan.org>, or through -the web interface at L<http://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Tiny>. You will be automatically notified of any -progress on the request by the system. +Please report any bugs or feature requests through the issue tracker +at L<http://rt.cpan.org/Public/Dist/Display.html?Name=HTTP-Tiny>. +You will be notified automatically of any progress on your issue. =head2 Source Code @@ -1197,7 +1205,7 @@ David Golden <[email protected]> =head1 COPYRIGHT AND LICENSE -This software is copyright (c) 2011 by Christian Hansen. +This software is copyright (c) 2012 by Christian Hansen. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. diff --git a/cpan/HTTP-Tiny/t/00-compile.t b/cpan/HTTP-Tiny/t/00-compile.t index 6ce3690..6987686 100644 --- a/cpan/HTTP-Tiny/t/00-compile.t +++ b/cpan/HTTP-Tiny/t/00-compile.t @@ -24,19 +24,33 @@ find( 'lib', ); -my @scripts; -if ( -d 'bin' ) { +sub _find_scripts { + my $dir = shift @_; + + my @found_scripts = (); find( sub { return unless -f; my $found = $File::Find::name; # nothing to skip - push @scripts, $found; + open my $FH, '<', $_ or do { + note( "Unable to open $found in ( $! ), skipping" ); + return; + }; + my $shebang = <$FH>; + return unless $shebang =~ /^#!.*?\bperl\b\s*$/; + push @found_scripts, $found; }, - 'bin', + $dir, ); + + return @found_scripts; } +my @scripts; +do { push @scripts, _find_scripts($_) if -d $_ } + for qw{ bin script scripts }; + my $plan = scalar(@modules) + scalar(@scripts); $plan ? (plan tests => $plan) : (plan skip_all => "no tests to run"); -- Perl5 Master Repository
