@@ -5,24 +5,21 @@ contains instructions that will help you work with the source code.
The distribution is managed with Dist::Zilla. This means than many of the
usual files you might expect are not in the repository, but are generated at
-release time (e.g. Makefile.PL).
+release time, as is much of the documentation. Some generated files are
+kept in the repository as a convenience (e.g. Makefile.PL or cpanfile).
Generally, **you do not need Dist::Zilla to contribute patches**. You do need
-Dist::Zilla to create a tarball and/or install from the repository. See below
-for guidance.
+Dist::Zilla to create a tarball. See below for guidance.
### Getting dependencies
-See the included `cpanfile` file for a list of dependencies. If you have
-App::cpanminus 1.6 or later installed, you can use `cpanm` to satisfy
-dependencies like this:
+If you have App::cpanminus 1.6 or later installed, you can use `cpanm` to
+satisfy dependencies like this:
$ cpanm --installdeps .
-Otherwise, you can install Module::CPANfile 1.0002 or later and then satisfy
-dependencies with the regular `cpan` client and `cpanfile-dump`:
-
- $ cpan `cpanfile-dump`
+Otherwise, look for either a `Makefile.PL` or `cpanfile` file for
+a list of dependencies to satisfy.
### Running tests
@@ -44,22 +41,16 @@ If there is a `tidyall.ini` file, you can also install Code::TidyAll and run
### Patching documentation
-Much of the documentation Pod is generated at release time. Depending on the
-distribution, some of my documentation may be written in a Pod dialect called
-WikiDoc. (See Pod::WikiDoc on CPAN.)
+Much of the documentation Pod is generated at release time. Some is
+generated boilerplate; other documentation is built from pseudo-POD
+directives in the source like C<=method> or C<=func>.
-If you would like to submit a documentation edit, please limit yourself to the
-documentation you see.
+If you would like to submit a documentation edit, please limit yourself to
+the documentation you see.
If you see typos or documentation issues in the generated docs, please
email or open a bug ticket instead of patching.
-### Installing from the repository
-
-If you want to install directly from the repository, you need to have
-Dist::Zilla installed (see below). If this is a burden to you, I welcome
-patches against a CPAN tarball instead of the repository.
-
### Installing and using Dist::Zilla
Dist::Zilla is a very powerful authoring tool, optimized for maintaining a
@@ -92,9 +83,5 @@ Once installed, here are some dzil commands you might try:
$ dzil test
$ dzil xtest
-To install from the repository, use:
-
- $ dzil install
-
You can learn more about Dist::Zilla at http://dzil.org/
@@ -1,5 +1,26 @@
Revision history for CPAN-Meta-Requirements
+2.130 2014-11-19 23:25:46-05:00 America/New_York
+
+ [ADDED]
+
+ - from_string_hash can take optional constructor arguments
+
+ [CHANGED]
+
+ - bad_version_hook callback gets module name as well as version string
+
+ - undefined/empty versions given to from_string_hash or
+ add_string_requirement now carp and are coerced to "0" instead of
+ being fatal. This is more consistent with how the other requirement
+ functions work.
+
+2.129 2014-11-13 16:28:45-05:00 America/New_York
+
+ [FIXED]
+
+ - from_string_hash can now accept v-strings as hash values
+
2.128 2014-09-06 00:04:22-04:00 America/New_York
[FIXED]
@@ -1,4 +1,4 @@
-# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.020.
+# This file was automatically generated by Dist::Zilla::Plugin::Manifest v5.025.
CONTRIBUTING.mkdn
Changes
LICENSE
@@ -5,7 +5,7 @@
"Ricardo Signes <rjbs@cpan.org>"
],
"dynamic_config" : 0,
- "generated_by" : "Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.140640",
+ "generated_by" : "Dist::Zilla version 5.025, CPAN::Meta::Converter version 2.142690",
"license" : [
"perl_5"
],
@@ -28,7 +28,8 @@
"prereqs" : {
"configure" : {
"requires" : {
- "ExtUtils::MakeMaker" : "6.17"
+ "ExtUtils::MakeMaker" : "6.17",
+ "perl" : "5.006"
}
},
"develop" : {
@@ -36,7 +37,7 @@
"Dist::Zilla" : "5",
"Dist::Zilla::Plugin::MakeMaker::Highlander" : "0.003",
"Dist::Zilla::Plugin::Prereqs" : "0",
- "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.060",
+ "Dist::Zilla::PluginBundle::DAGOLDEN" : "0.072",
"File::Spec" : "0",
"File::Temp" : "0",
"IO::Handle" : "0",
@@ -68,6 +69,7 @@
"ExtUtils::MakeMaker" : "0",
"File::Spec" : "0",
"Test::More" : "0.88",
+ "perl" : "5.006",
"version" : "0.88"
}
}
@@ -75,7 +77,7 @@
"provides" : {
"CPAN::Meta::Requirements" : {
"file" : "lib/CPAN/Meta/Requirements.pm",
- "version" : "2.128"
+ "version" : "2.130"
}
},
"release_status" : "stable",
@@ -90,9 +92,10 @@
"web" : "https://github.com/dagolden/CPAN-Meta-Requirements"
}
},
- "version" : "2.128",
+ "version" : "2.130",
"x_authority" : "cpan:DAGOLDEN",
"x_contributors" : [
+ "Ed J <mohawk2@users.noreply.github.com>",
"Karen Etheridge <ether@cpan.org>",
"robario <webmaster@robario.com>"
]
@@ -7,11 +7,13 @@ build_requires:
ExtUtils::MakeMaker: '0'
File::Spec: '0'
Test::More: '0.88'
+ perl: '5.006'
version: '0.88'
configure_requires:
ExtUtils::MakeMaker: '6.17'
+ perl: '5.006'
dynamic_config: 0
-generated_by: 'Dist::Zilla version 5.020, CPAN::Meta::Converter version 2.140640'
+generated_by: 'Dist::Zilla version 5.025, CPAN::Meta::Converter version 2.142690'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -28,7 +30,7 @@ no_index:
provides:
CPAN::Meta::Requirements:
file: lib/CPAN/Meta/Requirements.pm
- version: '2.128'
+ version: '2.130'
requires:
B: '0'
Carp: '0'
@@ -41,8 +43,9 @@ resources:
bugtracker: https://github.com/dagolden/CPAN-Meta-Requirements/issues
homepage: https://github.com/dagolden/CPAN-Meta-Requirements
repository: https://github.com/dagolden/CPAN-Meta-Requirements.git
-version: '2.128'
+version: '2.130'
x_authority: cpan:DAGOLDEN
x_contributors:
+ - 'Ed J <mohawk2@users.noreply.github.com>'
- 'Karen Etheridge <ether@cpan.org>'
- 'robario <webmaster@robario.com>'
@@ -1,5 +1,5 @@
-# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.020.
+# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.025.
use strict;
use warnings;
@@ -18,6 +18,7 @@ my %WriteMakefileArgs = (
"DISTNAME" => "CPAN-Meta-Requirements",
"EXE_FILES" => [],
"LICENSE" => "perl",
+ "MIN_PERL_VERSION" => "5.006",
"NAME" => "CPAN::Meta::Requirements",
"PREREQ_PM" => {
"B" => 0,
@@ -33,7 +34,7 @@ my %WriteMakefileArgs = (
"Test::More" => "0.88",
"version" => "0.88"
},
- "VERSION" => "2.128",
+ "VERSION" => "2.130",
"test" => {
"TESTS" => "t/*.t"
}
@@ -43,7 +44,7 @@ my %WriteMakefileArgs = (
my %FallbackPrereqs = (
"B" => 0,
"Carp" => 0,
- "ExtUtils::MakeMaker" => 0,
+ "ExtUtils::MakeMaker" => "6.17",
"File::Spec" => 0,
"Scalar::Util" => 0,
"Test::More" => "0.88",
@@ -2,7 +2,7 @@ NAME
CPAN::Meta::Requirements - a set of version requirements for a CPAN dist
VERSION
- version 2.128
+ version 2.130
SYNOPSIS
use CPAN::Meta::Requirements;
@@ -36,8 +36,8 @@ METHODS
* "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.
+ invalid version string as first argument, and the module name as
+ second argument. It must return a valid version object.
All other keys are ignored.
@@ -186,10 +186,12 @@ METHODS
add_string_requirement
$req->add_string_requirement('Library::Foo' => '>= 1.208, <= 2.206');
+ $req->add_string_requirement('Library::Foo' => v1.208);
This method parses the passed in string and adds the appropriate
- requirement for the given module. It understands version ranges as
- described in the "Version Ranges" in CPAN::Meta::Spec. For example:
+ requirement for the given module. A version can be a Perl "v-string". It
+ understands version ranges as described in the "Version Ranges" in
+ CPAN::Meta::Spec. For example:
1.3
>= 1.3
@@ -204,10 +206,14 @@ METHODS
from_string_hash
my $req = CPAN::Meta::Requirements->from_string_hash( \%hash );
+ my $req = CPAN::Meta::Requirements->from_string_hash( \%hash, \%opts );
This is an alternate constructor for a CPAN::Meta::Requirements object.
It takes a hash of module names and version requirement strings and
- returns a new CPAN::Meta::Requirements object.
+ returns a new CPAN::Meta::Requirements object. As with
+ add_string_requirement, a version can be a Perl "v-string". Optionally,
+ you can supply a hash-reference of options, exactly as with the "new"
+ method.
SUPPORT
Bugs / Feature Requests
@@ -229,6 +235,8 @@ AUTHORS
* Ricardo Signes <rjbs@cpan.org>
CONTRIBUTORS
+ * Ed J <mohawk2@users.noreply.github.com>
+
* Karen Etheridge <ether@cpan.org>
* robario <webmaster@robario.com>
@@ -10,6 +10,7 @@ on 'test' => sub {
requires "ExtUtils::MakeMaker" => "0";
requires "File::Spec" => "0";
requires "Test::More" => "0.88";
+ requires "perl" => "5.006";
requires "version" => "0.88";
};
@@ -19,13 +20,14 @@ on 'test' => sub {
on 'configure' => sub {
requires "ExtUtils::MakeMaker" => "6.17";
+ requires "perl" => "5.006";
};
on 'develop' => sub {
requires "Dist::Zilla" => "5";
requires "Dist::Zilla::Plugin::MakeMaker::Highlander" => "0.003";
requires "Dist::Zilla::Plugin::Prereqs" => "0";
- requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.060";
+ requires "Dist::Zilla::PluginBundle::DAGOLDEN" => "0.072";
requires "File::Spec" => "0";
requires "File::Temp" => "0";
requires "IO::Handle" => "0";
@@ -6,7 +6,7 @@ copyright_holder = David Golden and Ricardo Signes
copyright_year = 2010
[@DAGOLDEN]
-:version = 0.060
+:version = 0.072
stopwords = invocant
[MakeMaker::Highlander]
@@ -1,9 +1,10 @@
use strict;
use warnings;
package CPAN::Meta::Requirements;
-our $VERSION = '2.128'; # VERSION
# ABSTRACT: a set of version requirements for a CPAN dist
+our $VERSION = '2.130';
+
#pod =head1 SYNOPSIS
#pod
#pod use CPAN::Meta::Requirements;
@@ -59,8 +60,9 @@ BEGIN {
#pod
#pod =for :list
#pod * C<bad_version_hook> -- if provided, when a version cannot be parsed into
-#pod a version object, this code reference will be called with the invalid version
-#pod string as an argument. It must return a valid version object.
+#pod a version object, this code reference will be called with the invalid
+#pod version string as first argument, and the module name as second
+#pod argument. It must return a valid version object.
#pod
#pod All other keys are ignored.
#pod
@@ -99,7 +101,7 @@ sub _find_magic_vstring {
}
sub _version_object {
- my ($self, $version) = @_;
+ my ($self, $module, $version) = @_;
my $vobj;
@@ -118,7 +120,7 @@ sub _version_object {
if ( my $err = $@ ) {
my $hook = $self->{bad_version_hook};
- $vobj = eval { $hook->($version) }
+ $vobj = eval { $hook->($version, $module) }
if ref $hook eq 'CODE';
unless (Scalar::Util::blessed($vobj) && $vobj->isa("version")) {
$err =~ s{ at .* line \d+.*$}{};
@@ -199,7 +201,7 @@ BEGIN {
my $code = sub {
my ($self, $name, $version) = @_;
- $version = $self->_version_object( $version );
+ $version = $self->_version_object( $name, $version );
$self->__modify_entry_for($name, $method, $version);
@@ -257,7 +259,7 @@ sub add_requirements {
sub accepts_module {
my ($self, $module, $version) = @_;
- $version = $self->_version_object( $version );
+ $version = $self->_version_object( $module, $version );
return 1 unless my $range = $self->__entry_for($module);
return $range->_accepts($version);
@@ -435,10 +437,12 @@ sub as_string_hash {
#pod =method add_string_requirement
#pod
#pod $req->add_string_requirement('Library::Foo' => '>= 1.208, <= 2.206');
+#pod $req->add_string_requirement('Library::Foo' => v1.208);
#pod
#pod This method parses the passed in string and adds the appropriate requirement
-#pod for the given module. It understands version ranges as described in the
-#pod L<CPAN::Meta::Spec/Version Ranges>. For example:
+#pod for the given module. A version can be a Perl "v-string". It understands
+#pod version ranges as described in the L<CPAN::Meta::Spec/Version Ranges>. For
+#pod example:
#pod
#pod =over 4
#pod
@@ -477,12 +481,19 @@ my %methods_for_op = (
sub add_string_requirement {
my ($self, $module, $req) = @_;
- Carp::confess("No requirement string provided for $module")
- unless defined $req && length $req;
+ unless ( defined $req && length $req ) {
+ $req = 0;
+ $self->_blank_carp($module);
+ }
+
+ my $magic = _find_magic_vstring( $req );
+ if (length $magic) {
+ $self->add_minimum($module => $magic);
+ return;
+ }
my @parts = split qr{\s*,\s*}, $req;
-
for my $part (@parts) {
my ($op, $ver) = $part =~ m{\A\s*(==|>=|>|<=|<|!=)\s*(.*)\z};
@@ -500,23 +511,32 @@ sub add_string_requirement {
#pod =method from_string_hash
#pod
#pod my $req = CPAN::Meta::Requirements->from_string_hash( \%hash );
+#pod my $req = CPAN::Meta::Requirements->from_string_hash( \%hash, \%opts );
#pod
-#pod This is an alternate constructor for a CPAN::Meta::Requirements object. It takes
-#pod a hash of module names and version requirement strings and returns a new
-#pod CPAN::Meta::Requirements object.
+#pod This is an alternate constructor for a CPAN::Meta::Requirements
+#pod object. It takes a hash of module names and version requirement
+#pod strings and returns a new CPAN::Meta::Requirements object. As with
+#pod add_string_requirement, a version can be a Perl "v-string". Optionally,
+#pod you can supply a hash-reference of options, exactly as with the L</new>
+#pod method.
#pod
#pod =cut
+sub _blank_carp {
+ my ($self, $module) = @_;
+ Carp::carp("Undefined requirement for $module treated as '0'");
+}
+
sub from_string_hash {
- my ($class, $hash) = @_;
+ my ($class, $hash, $options) = @_;
- my $self = $class->new;
+ my $self = $class->new($options);
for my $module (keys %$hash) {
my $req = $hash->{$module};
unless ( defined $req && length $req ) {
$req = 0;
- Carp::carp("Undefined requirement for $module treated as '0'");
+ $class->_blank_carp($module);
}
$self->add_string_requirement($module, $req);
}
@@ -735,7 +755,7 @@ CPAN::Meta::Requirements - a set of version requirements for a CPAN dist
=head1 VERSION
-version 2.128
+version 2.130
=head1 SYNOPSIS
@@ -775,7 +795,7 @@ hash reference argument. Currently, only one key is supported:
=item *
-C<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.
+C<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 first argument, and the module name as second argument. It must return a valid version object.
=back
@@ -940,10 +960,12 @@ C<$hashref> would contain:
=head2 add_string_requirement
$req->add_string_requirement('Library::Foo' => '>= 1.208, <= 2.206');
+ $req->add_string_requirement('Library::Foo' => v1.208);
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:
+for the given module. A version can be a Perl "v-string". It understands
+version ranges as described in the L<CPAN::Meta::Spec/Version Ranges>. For
+example:
=over 4
@@ -971,10 +993,14 @@ A version number without an operator is equivalent to specifying a minimum
=head2 from_string_hash
my $req = CPAN::Meta::Requirements->from_string_hash( \%hash );
+ my $req = CPAN::Meta::Requirements->from_string_hash( \%hash, \%opts );
-This is an alternate constructor for a CPAN::Meta::Requirements object. It takes
-a hash of module names and version requirement strings and returns a new
-CPAN::Meta::Requirements object.
+This is an alternate constructor for a CPAN::Meta::Requirements
+object. It takes a hash of module names and version requirement
+strings and returns a new CPAN::Meta::Requirements object. As with
+add_string_requirement, a version can be a Perl "v-string". Optionally,
+you can supply a hash-reference of options, exactly as with the L</new>
+method.
=for :stopwords cpan testmatrix url annocpan anno bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan
@@ -1011,12 +1037,16 @@ Ricardo Signes <rjbs@cpan.org>
=head1 CONTRIBUTORS
-=for stopwords Karen Etheridge robario
+=for stopwords Ed J Karen Etheridge robario
=over 4
=item *
+Ed J <mohawk2@users.noreply.github.com>
+
+=item *
+
Karen Etheridge <ether@cpan.org>
=item *
@@ -1,7 +1,8 @@
do { my $x = {
'configure' => {
'requires' => {
- 'ExtUtils::MakeMaker' => '6.17'
+ 'ExtUtils::MakeMaker' => '6.17',
+ 'perl' => '5.006'
}
},
'develop' => {
@@ -9,7 +10,7 @@ do { my $x = {
'Dist::Zilla' => '5',
'Dist::Zilla::Plugin::MakeMaker::Highlander' => '0.003',
'Dist::Zilla::Plugin::Prereqs' => '0',
- 'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.060',
+ 'Dist::Zilla::PluginBundle::DAGOLDEN' => '0.072',
'File::Spec' => '0',
'File::Temp' => '0',
'IO::Handle' => '0',
@@ -41,6 +42,7 @@ do { my $x = {
'ExtUtils::MakeMaker' => '0',
'File::Spec' => '0',
'Test::More' => '0.88',
+ 'perl' => '5.006',
'version' => '0.88'
}
}
@@ -6,6 +6,13 @@ use version;
use Test::More 0.88;
+my %DATA = (
+ 'Foo::Bar' => [ 10, 10 ],
+ 'Foo::Baz' => [ 'invalid_version', 42 ],
+);
+my %input = map { ($_ => $DATA{$_}->[0]) } keys %DATA;
+my %expected = map { ($_ => $DATA{$_}->[1]) } keys %DATA;
+
sub dies_ok (&@) {
my ($code, $qr, $comment) = @_;
@@ -18,20 +25,19 @@ sub dies_ok (&@) {
}
}
-sub _fixit { return version->new(42) }
+my $hook_text;
+sub _fixit { my ($v, $m) = @_; $hook_text = $m; 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');
+ my ($k, $v);
+ $req->add_minimum($k => $v) while ($k, $v) = each %input;
+ is $hook_text, 'Foo::Baz', 'hook stored module name';
is_deeply(
$req->as_string_hash,
- {
- 'Foo::Bar' => 10,
- 'Foo::Baz' => 42,
- },
+ \%expected,
"hook fixes invalid version",
);
}
@@ -46,9 +46,28 @@ sub dies_ok (&@) {
}
{
+ my $undef_hash = { Undef => undef };
+ my $z_hash = { ZeroLength => '' };
+
+ my $warning;
+ local $SIG{__WARN__} = sub { $warning = join("\n",@_) };
+
+ my $req = CPAN::Meta::Requirements->from_string_hash($undef_hash);
+ like ($warning, qr/Undefined requirement.*treated as '0'/, "undef requirement warns");
+ $req->add_string_requirement(%$z_hash);
+ like ($warning, qr/Undefined requirement.*treated as '0'/, "'' requirement warns");
+
+ is_deeply(
+ $req->as_string_hash,
+ { map { ($_ => 0) } keys(%$undef_hash), keys(%$z_hash) },
+ "undef/'' requirements treated as '0'",
+ );
+}
+
+{
my $string_hash = {
Left => 10,
- Shared => undef,
+ Shared => v50.44.60,
Right => 18,
};
@@ -57,13 +76,23 @@ sub dies_ok (&@) {
my $req = CPAN::Meta::Requirements->from_string_hash($string_hash);
- is(
- $req->as_string_hash->{Shared}, 0,
- "undef requirement treated as '0'",
+ ok(
+ $req->accepts_module(Shared => 'v50.44.60'),
+ "vstring treated as if string",
);
+}
- like ($warning, qr/Undefined requirement.*treated as '0'/, "undef requirement warns");
+{
+ my $req = CPAN::Meta::Requirements->from_string_hash(
+ { Bad => 'invalid', },
+ { bad_version_hook => sub { version->new(42) } },
+ );
+
+ ok(
+ $req->accepts_module(Bad => 42),
+ "options work 2nd arg to f_s_h",
+ );
}
done_testing;
@@ -2,11 +2,11 @@ use 5.006;
use strict;
use warnings;
-# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.046
-
-use Test::More tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
+# this test was generated with Dist::Zilla::Plugin::Test::Compile 2.051
+use Test::More;
+plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0);
my @module_files = (
'CPAN/Meta/Requirements.pm'
@@ -48,6 +48,7 @@ for my $lib (@module_files)
-is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', explain \@warnings if $ENV{AUTHOR_TESTING};
+is(scalar(@warnings), 0, 'no warnings found')
+ or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING};
@@ -18,6 +18,8 @@ Ricardo
Signes
rjbs
and
+Ed
+mohawk2
Karen
Etheridge
ether