diff --git a/.mailmap b/.mailmap index 95f571a..bebbc2c 100644 --- a/.mailmap +++ b/.mailmap @@ -1,2 +1,3 @@ Doug Bell Doug Bell +Kent Fredric diff --git a/Makefile.PL b/Makefile.PL index dd0c928..5d3ea9f 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -10,7 +10,9 @@ my %WriteMakefileArgs = ( "ABSTRACT" => "Lightweight Dependency Injection Container", "AUTHOR" => "Doug Bell , Al Newkirk ", "CONFIGURE_REQUIRES" => { - "ExtUtils::MakeMaker" => 0 + "CPAN::Meta::Requirements" => "2.120620", + "ExtUtils::MakeMaker" => 0, + "Module::Metadata" => 0 }, "DISTNAME" => "Beam-Wire", "EXE_FILES" => [], @@ -66,6 +68,10 @@ my %FallbackPrereqs = ( "YAML" => 0 ); +# inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.019 +# Breaks LoadFile(path(...)) +has_module('YAML::XS','== 0.61') and requires('YAML::XS','0.62'); + unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) { delete $WriteMakefileArgs{TEST_REQUIRES}; @@ -77,3 +83,36 @@ delete $WriteMakefileArgs{CONFIGURE_REQUIRES} unless eval { ExtUtils::MakeMaker->VERSION(6.52) }; WriteMakefile(%WriteMakefileArgs); + +# inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.019 +sub _add_prereq { + my ($mm_key, $module, $version_or_range) = @_; + warn "$module already exists in $mm_key -- need to do a sane metamerge!" + if exists $WriteMakefileArgs{$mm_key}{$module} + and $WriteMakefileArgs{$mm_key}{$module} ne ($version_or_range || 0); + warn "$module already exists in FallbackPrereqs -- need to do a sane metamerge!" + if exists $FallbackPrereqs{$module} and $FallbackPrereqs{$module} ne ($version_or_range || 0); + $WriteMakefileArgs{$mm_key}{$module} = $FallbackPrereqs{$module} = $version_or_range || 0; + return; +} + +sub has_module { + my ($module, $version_or_range) = @_; + require Module::Metadata; + my $mmd = Module::Metadata->new_from_module($module); + return undef if not $mmd; + return $mmd->version($module) if not defined $version_or_range; + + require CPAN::Meta::Requirements; + my $req = CPAN::Meta::Requirements->new; + $req->add_string_requirement($module => $version_or_range); + return 1 if $req->accepts_module($module => $mmd->version($module)); + return 0; +} + +sub requires { goto &runtime_requires } + +sub runtime_requires { + my ($module, $version_or_range) = @_; + _add_prereq(PREREQ_PM => $module, $version_or_range); +} diff --git a/README.mkdn b/README.mkdn index 278927f..cafcd4d 100644 --- a/README.mkdn +++ b/README.mkdn @@ -579,6 +579,7 @@ The configuration is invalid: - Bruce Armstrong - Bruce Armstrong +- Kent Fredric <kentnl@cpan.org> # COPYRIGHT AND LICENSE diff --git a/cpanfile b/cpanfile index cbd62f7..833fe76 100644 --- a/cpanfile +++ b/cpanfile @@ -26,5 +26,7 @@ on 'test' => sub { }; on 'configure' => sub { + requires "CPAN::Meta::Requirements" => "2.120620"; requires "ExtUtils::MakeMaker" => "0"; + requires "Module::Metadata" => "0"; }; diff --git a/dist.ini b/dist.ini index 91e044e..0f65f17 100644 --- a/dist.ini +++ b/dist.ini @@ -19,6 +19,8 @@ repository.url = https://github.com/preaction/Beam-Wire.git bugtracker.web = https://github.com/preaction/Beam-Wire/issues repository.type = git +[MetaJSON] + ; --- Module management [@Filter] -bundle = @Basic @@ -113,3 +115,8 @@ Test::Deep = 0 Test::Differences = 0.64 ; Fix buggy Text::Diff version Test::Exception = 0 Test::Lib = 0 + +[DynamicPrereqs] +-delimiter = | +-raw = |# Breaks LoadFile(path(...)) +-raw = |has_module('YAML::XS','== 0.61') and requires('YAML::XS','0.62');