Skip Menu |

This queue is for tickets about the Module-Depends CPAN distribution.

Report information
The Basics
Id: 64017
Status: new
Priority: 0/
Queue: Module-Depends

People
Owner: Nobody in particular
Requestors: gregoa [...] cpan.org
Cc: dam [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Support for META.json and META.yml in JSON format
(Debian bugs: http://bugs.debian.org/541164 and http://bugs.debian.org/541159 ) Find attached two patches that support META.yml in JSON format and META.json. Cheers, gregor, Debian Perl Group
Subject: yaml_xs.patch
Description: use YAML::XS in order to support JSON META.ymls plus META.json (see next patch) Origin: vendor Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541159 Forwarded: no Author: Ryan Niebur <ryan@debian.org> Reviewed-by: gregor herrmann <gregoa@debian.org> Last-Update: 2010-11-17 --- a/lib/Module/Depends.pm +++ b/lib/Module/Depends.pm @@ -1,6 +1,6 @@ use strict; package Module::Depends; -use Parse::CPAN::Meta; +use YAML::XS qw/LoadFile/; use Cwd qw( getcwd ); use base qw( Class::Accessor::Chained ); __PACKAGE__->mk_accessors(qw( dist_dir debug libs requires build_requires error )); @@ -12,7 +12,6 @@ =head1 SYNOPSIS - use YAML; use Module::Depends; my $deps = Module::Depends->new->dist_dir( '.' )->find_modules; print "Our dependencies:\n", Dump $deps->requires;
Subject: meta_json.patch
Description: add support for parsing META.json Origin: vendor Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=541164 Forwarded: no Author: Ryan Niebur <ryan@debian.org> Reviewed-by: gregor herrmann <gregoa@debian.org> Last-Update: 2010-11-17 --- a/lib/Module/Depends.pm +++ b/lib/Module/Depends.pm @@ -73,9 +73,9 @@ sub _find_modules { my $self = shift; - my ($file) = grep { -e $_ } qw( MYMETA.yml META.yml ); + my ($file) = grep { -e $_ } qw( MYMETA.json MYMETA.yml META.json META.yml ); if ($file) { - my $meta = ( Parse::CPAN::Meta::LoadFile( $file ) )[0]; + my $meta = LoadFile( $file ); $self->requires( $meta->{requires} ); $self->build_requires( $meta->{build_requires} ); } --- a/t/depends.t +++ b/t/depends.t @@ -1,7 +1,7 @@ #!perl use strict; use warnings; -use Test::More tests => 19; +use Test::More tests => 20; my $class = 'Module::Depends::Intrusive'; require_ok("Module::Depends"); require_ok($class); @@ -68,6 +68,10 @@ is_deeply( $distant->requires, $our_requires, "got our own requires, non-intrusively, from a distance" ); +my $json = Module::Depends->new->dist_dir('t/with-json')->find_modules; +is_deeply( $json->requires, $our_requires, + "got our own requires, non-intrusively, from a distance" ); + my $inline_mm = $class->new->dist_dir('t/inline-makemaker')->find_modules; is_deeply( $inline_mm->requires, --- /dev/null +++ b/t/with-json/META.json @@ -0,0 +1,9 @@ +{ + "abstract" : "some test", + "requires" : { + "Class::Accessor::Chained" : "0", + "File::chdir" : "0", + "File::Spec" : "0", + "YAML" : "0", + }, +}
Here's a hopefully better patch for both #64017 and #64016.
Subject: cpan_meta.patch
Description: support META.json additionally to META.yml; add support for test_requires and configure_requires; use CPAN::META Origin: vendor Bug: https://rt.cpan.org/Ticket/Display.html?id=64017 https://rt.cpan.org/Ticket/Display.html?id=64016 Bug-Debian: http://bugs.debian.org/541159 http://bugs.debian.org/541164 http://bugs.debian.org/541165 Author: Ryan Niebur <ryan@debian.org> gregor herrmann <gregoa@debian.org> Reviewed-by: gregor herrmann <gregoa@debian.org> Last-Update: 2011-05-25 --- a/t/depends.t +++ b/t/depends.t @@ -1,7 +1,7 @@ #!perl use strict; use warnings; -use Test::More tests => 19; +use Test::More tests => 21; my $class = 'Module::Depends::Intrusive'; require_ok("Module::Depends"); require_ok($class); @@ -68,6 +68,16 @@ is_deeply( $distant->requires, $our_requires, "got our own requires, non-intrusively, from a distance" ); +is_deeply( + $distant->configure_requires, + { 'Test::Fatal' => 0 }, + "got our own configure_requires, non-intrusively, from a distance" +); + +my $json = Module::Depends->new->dist_dir('t/with-json')->find_modules; +is_deeply( $json->requires, $our_requires, + "got our own requires, non-intrusively, from a distance" ); + my $inline_mm = $class->new->dist_dir('t/inline-makemaker')->find_modules; is_deeply( $inline_mm->requires, --- a/t/with-yaml/META.yml +++ b/t/with-yaml/META.yml @@ -11,6 +11,8 @@ YAML: 0 build_requires: Test::More: 0 +configure_requires: + Test::Fatal: 0 provides: Module::Depends: file: lib/Module/Depends.pm --- a/lib/Module/Depends/Intrusive.pm +++ b/lib/Module/Depends/Intrusive.pm @@ -32,6 +32,8 @@ my %args = @_; $self->requires( $args{requires} || {} ); $self->build_requires( $args{build_requires} || {} ); + $self->test_requires( $args{test_requires} || {} ); + $self->configure_requires( $args{configure_requires} || {} ); bless {}, "Module::Depends::Intrusive::Fake::Module::Build"; }; local *Module::Build::subclass = sub { 'Module::Build' }; @@ -40,6 +42,7 @@ my $WriteMakefile = sub { my %args = @_; $self->requires( $args{PREREQ_PM} || {} ); + $self->build_requires ( $args{BUILD_REQUIRES} || {} ); 1; }; local *main::WriteMakefile; @@ -61,7 +64,7 @@ all_from auto_install AUTOLOAD build_requires check_nmake include include_deps installdirs Makefile makemaker_args Meta name no_index requires WriteAll clean_files can_cc sign cc_inc_paths cc_files - cc_optimize_flags author license + cc_optimize_flags author license configure_requires test_requires ); local *inc::Module::Install::AUTOLOAD = sub { 1 }; @@ -74,6 +77,14 @@ my %deps = (@_ == 1 ? ( $_[0] => 0 ) : @_); $self->build_requires->{ $_ } = $deps{ $_ } for keys %deps; }; + local *inc::Module::Install::test_requires = sub { + my %deps = (@_ == 1 ? ( $_[0] => 0 ) : @_); + $self->test_requires->{ $_ } = $deps{ $_ } for keys %deps; + }; + local *inc::Module::Install::configure_requires = sub { + my %deps = (@_ == 1 ? ( $_[0] => 0 ) : @_); + $self->configure_requires->{ $_ } = $deps{ $_ } for keys %deps; + }; my $file = File::Spec->catfile( getcwd(), $pl ); eval { --- a/lib/Module/Depends.pm +++ b/lib/Module/Depends.pm @@ -1,9 +1,9 @@ use strict; package Module::Depends; -use Parse::CPAN::Meta; +use CPAN::Meta; use Cwd qw( getcwd ); use base qw( Class::Accessor::Chained ); -__PACKAGE__->mk_accessors(qw( dist_dir debug libs requires build_requires error )); +__PACKAGE__->mk_accessors(qw( dist_dir debug libs requires build_requires test_requires configure_requires error )); our $VERSION = '0.15'; =head1 NAME @@ -12,7 +12,6 @@ =head1 SYNOPSIS - use YAML; use Module::Depends; my $deps = Module::Depends->new->dist_dir( '.' )->find_modules; print "Our dependencies:\n", Dump $deps->requires; @@ -42,6 +41,8 @@ libs => [], requires => {}, build_requires => {}, + test_requires => {}, + configure_requires => {}, error => '', }); } @@ -52,7 +53,7 @@ =head2 find_modules -scan the C<dist_dir> to populate C<libs>, C<requires>, and C<build_requires> +scan the C<dist_dir> to populate C<libs>, C<requires>, C<configure_requires>, C<test_requires>, and C<build_requires> =cut @@ -74,14 +75,17 @@ sub _find_modules { my $self = shift; - my ($file) = grep { -e $_ } qw( MYMETA.yml META.yml ); + my ($file) = grep { -e $_ } qw( MYMETA.json MYMETA.yml META.json META.yml ); if ($file) { - my $meta = ( Parse::CPAN::Meta::LoadFile( $file ) )[0]; - $self->requires( $meta->{requires} ); - $self->build_requires( $meta->{build_requires} ); + my $meta = CPAN::Meta->load_file( $file ); + my $prereqs = $meta->effective_prereqs(); + $self->requires( $prereqs->requirements_for( 'runtime', 'requires' )->as_string_hash() ); + $self->build_requires( $prereqs->requirements_for( 'build', 'requires' )->as_string_hash() ); + $self->configure_requires( $prereqs->requirements_for( 'configure', 'requires' )->as_string_hash() ); + $self->test_requires( $prereqs->requirements_for( 'test', 'requires' )->as_string_hash() ); } else { - $self->error( "No META.yml found in ". $self->dist_dir ); + $self->error( "No {MY,}META.{json,yml} found in ". $self->dist_dir ); } return $self; } --- /dev/null +++ b/t/with-json/META.json @@ -0,0 +1,56 @@ +{ + "abstract" : "identify the dependencies of a distribution", + "author" : [ + "unknown" + ], + "dynamic_config" : 1, + "generated_by" : "Module::Build version 0.2608, CPAN::Meta::Converter version 2.110930", + "license" : [ + "perl_5" + ], + "meta-spec" : { + "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", + "version" : "2" + }, + "name" : "Module-Depends", + "prereqs" : { + "build" : { + "requires" : { + "Test::More" : 0 + } + }, + "test" : { + "requires" : { + "Test::Fatal" : 0 + } + }, + "runtime" : { + "requires" : { + "Class::Accessor::Chained" : 0, + "File::Spec" : 0, + "File::chdir" : 0, + "YAML" : 0 + } + } + }, + "provides" : { + "Module::Depends" : { + "file" : "lib/Module/Depends.pm", + "version" : "0.06" + }, + "Module::Depends::Intrusive" : { + "file" : "lib/Module/Depends/Intrusive.pm", + "version" : 0 + }, + "Module::Depends::Intrusive::Fake::Module::Build" : { + "file" : "lib/Module/Depends/Intrusive.pm", + "version" : 0 + }, + "main" : { + "file" : "lib/Module/Depends/Intrusive.pm", + "version" : 0 + } + }, + "release_status" : "stable", + "version" : "0.06" +}