From 9e8b600ee4d963f4e64f3b0e88a89d01350cdbcc Mon Sep 17 00:00:00 2001 From: Kent Fredric Date: Thu, 24 Jul 2014 17:53:05 +1200 Subject: [PATCH] Build results of 5c778eb (on master) --- Changes | 16 + MANIFEST | 6 + META.json | 62 ++-- META.yml | 58 ++-- Makefile.PL | 16 +- README | 27 +- lib/CPAN/Changes/Group/Dependencies/Stats.pm | 99 +++++-- misc/Changes.deps | 15 + misc/Changes.deps.all | 21 ++ misc/Changes.deps.dev | 6 + misc/Changes.deps.opt | 6 + ...CPAN_Changes_Group_Dependencies_Stats_pm.t | 2 +- t/00-report-prereqs.dd | 102 +++++++ t/00-report-prereqs.t | 276 +++++++----------- t/attach.t | 45 +++ 15 files changed, 495 insertions(+), 262 deletions(-) create mode 100644 misc/Changes.deps create mode 100644 misc/Changes.deps.all create mode 100644 misc/Changes.deps.dev create mode 100644 misc/Changes.deps.opt create mode 100644 t/00-report-prereqs.dd create mode 100644 t/attach.t diff --git a/Changes b/Changes index 4a161d5..95cda2a 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,21 @@ Release history for CPAN-Changes-Group-Dependencies-Stats +0.002000 2014-07-24T05:46:13Z + [00 Major] + - Reimplement as a subclass of the new CPAN::Changes::Group + - This greatly simplifies attaching this object to a release. + - Add a 'prelude' property for arbritray pre-text to inject in a group. + - Add a 'name' property which can be set during construction to define the groups name + - Add a 'has_changes' property which will determine if there are changes prior to doing any internal formatting, + allowing usage as a pre-check if you don't want to add over-simplistic change nodes. ( Maybe I should override + is_empty here, not sure ) + + [Dependencies::Stats] + - Dependencies changed since 0.001000, see misc/*.deps* for details + - develop: (suggests: ↑1) + - runtime: +2 + - test: +3 ↑1 (recommends: +1) + 0.001000 2014-07-16T10:47:37Z - First version. diff --git a/MANIFEST b/MANIFEST index aec13d4..4d0ff81 100644 --- a/MANIFEST +++ b/MANIFEST @@ -16,10 +16,16 @@ example/moose-dif/Moose-2.1210-META.json example/moose-diff.pl lib/CPAN/Changes/Group/Dependencies/Stats.pm maint/perlcritic.rc.gen.pl +misc/Changes.deps +misc/Changes.deps.all +misc/Changes.deps.dev +misc/Changes.deps.opt misc/perlcritic.deps perlcritic.rc t/00-compile/lib_CPAN_Changes_Group_Dependencies_Stats_pm.t +t/00-report-prereqs.dd t/00-report-prereqs.t +t/attach.t t/basic.t t/complex.t t/fails.t diff --git a/META.json b/META.json index 7254d31..0c407d9 100644 --- a/META.json +++ b/META.json @@ -75,11 +75,13 @@ }, "suggests" : { "Dist::Zilla::App::Command::bakeini" : "0.001001", - "Dist::Zilla::PluginBundle::Author::KENTNL" : "2.016003" + "Dist::Zilla::PluginBundle::Author::KENTNL" : "2.016004" } }, "runtime" : { "requires" : { + "CPAN::Changes" : "0.29", + "CPAN::Changes::Group" : "0", "CPAN::Meta::Prereqs::Diff" : "0", "Carp" : "0", "Moo" : "0", @@ -93,24 +95,28 @@ "test" : { "recommends" : { "CPAN::Meta" : "0", + "CPAN::Meta::Prereqs" : "0", "CPAN::Meta::Requirements" : "2.120900", "ExtUtils::MakeMaker" : "6.98", "Test::More" : "1.001003" }, "requires" : { + "CPAN::Changes::Release" : "0", "ExtUtils::MakeMaker" : "0", + "File::Spec" : "0", "File::Spec::Functions" : "0", "List::Util" : "0", + "Scalar::Util" : "0", "Test::Differences" : "0", "Test::More" : "0.89", - "version" : "0" + "version" : "0.77" } } }, "provides" : { "CPAN::Changes::Group::Dependencies::Stats" : { "file" : "lib/CPAN/Changes/Group/Dependencies/Stats.pm", - "version" : "0.001000" + "version" : "0.002000" } }, "release_status" : "stable", @@ -125,10 +131,16 @@ "web" : "https://github.com/kentnl/CPAN-Changes-Group-Dependencies-Stats" } }, - "version" : "0.001000", + "version" : "0.002000", "x_BuiltWith" : { + "failures" : { + "CPAN::Changes::Group" : "Module::MetaData could not parse a version from /home/kent/perl5/perlbrew/perls/5.21.1-sdbm/lib/site_perl/5.21.1/CPAN/Changes/Group.pm", + "CPAN::Changes::Release" : "Module::MetaData could not parse a version from /home/kent/perl5/perlbrew/perls/5.21.1-sdbm/lib/site_perl/5.21.1/CPAN/Changes/Release.pm" + }, "modules" : { + "CPAN::Changes" : "0.29", "CPAN::Meta" : "2.141520", + "CPAN::Meta::Prereqs" : "2.141520", "CPAN::Meta::Prereqs::Diff" : "0.001000", "CPAN::Meta::Requirements" : "2.125", "Carp" : "1.34", @@ -143,7 +155,7 @@ "Dist::Zilla::Plugin::Git::Commit" : "2.023", "Dist::Zilla::Plugin::Git::CommitBuild" : "2.023", "Dist::Zilla::Plugin::Git::GatherDir" : "2.023", - "Dist::Zilla::Plugin::Git::NextRelease" : "0.002010", + "Dist::Zilla::Plugin::Git::NextRelease" : "0.002011", "Dist::Zilla::Plugin::Git::Tag" : "2.023", "Dist::Zilla::Plugin::GithubMeta" : "0.46", "Dist::Zilla::Plugin::License" : "5.019", @@ -151,7 +163,7 @@ "Dist::Zilla::Plugin::Manifest" : "5.019", "Dist::Zilla::Plugin::ManifestSkip" : "5.019", "Dist::Zilla::Plugin::MetaConfig" : "5.019", - "Dist::Zilla::Plugin::MetaData::BuiltWith" : "1.000000", + "Dist::Zilla::Plugin::MetaData::BuiltWith" : "1.000001", "Dist::Zilla::Plugin::MetaJSON" : "5.019", "Dist::Zilla::Plugin::MetaProvides::Package" : "2.000002", "Dist::Zilla::Plugin::MetaTests" : "5.019", @@ -161,34 +173,36 @@ "Dist::Zilla::Plugin::PodSyntaxTests" : "5.019", "Dist::Zilla::Plugin::PodWeaver" : "4.005", "Dist::Zilla::Plugin::Prereqs" : "5.019", - "Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled" : "0.001000", + "Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled" : "0.002000", "Dist::Zilla::Plugin::ReadmeAnyFromPod" : "0.141760", "Dist::Zilla::Plugin::ReadmeFromPod" : "0.21", - "Dist::Zilla::Plugin::RewriteVersion::Sanitized" : "0.001000", + "Dist::Zilla::Plugin::RewriteVersion::Sanitized" : "0.001001", "Dist::Zilla::Plugin::RunExtraTests" : "0.022", "Dist::Zilla::Plugin::Test::CPAN::Changes" : "0.008", - "Dist::Zilla::Plugin::Test::Compile::PerFile" : "0.002000", + "Dist::Zilla::Plugin::Test::Compile::PerFile" : "0.002001", "Dist::Zilla::Plugin::Test::Kwalitee" : "2.07", "Dist::Zilla::Plugin::Test::MinimumVersion" : "2.000005", "Dist::Zilla::Plugin::Test::Perl::Critic" : "2.112410", - "Dist::Zilla::Plugin::Test::ReportPrereqs" : "0.013", + "Dist::Zilla::Plugin::Test::ReportPrereqs" : "0.014", "Dist::Zilla::Plugin::TestRelease" : "5.019", "Dist::Zilla::Plugin::Twitter" : "0.025", "Dist::Zilla::Plugin::UploadToCPAN" : "5.019", - "Dist::Zilla::PluginBundle::Author::KENTNL" : "2.016003", + "Dist::Zilla::PluginBundle::Author::KENTNL" : "2.016004", "ExtUtils::MakeMaker" : "6.98", + "File::Spec" : "3.48", "File::Spec::Functions" : "3.48", "List::Util" : "1.39", "Moo" : "1.005000", - "MooX::Lsub" : "0.001001", + "MooX::Lsub" : "0.001002", "Pod::Coverage::TrustPod" : "0.100003", - "Test::CPAN::Changes" : "0.28", + "Scalar::Util" : "1.39", + "Test::CPAN::Changes" : "0.29", "Test::CPAN::Meta" : "0.23", "Test::Differences" : "0.62", - "Test::Kwalitee" : "1.18", + "Test::Kwalitee" : "1.19", "Test::More" : "1.001003", "Test::Pod" : "1.48", - "Test::Pod::Coverage" : "1.08", + "Test::Pod::Coverage" : "1.10", "strict" : "1.08", "utf8" : "1.14", "version" : "0.9908", @@ -267,7 +281,7 @@ } }, "name" : "@Author::KENTNL/MetaData::BuiltWith", - "version" : "1.000000" + "version" : "1.000001" }, { "class" : "Dist::Zilla::Plugin::Git::GatherDir", @@ -325,7 +339,7 @@ { "class" : "Dist::Zilla::Plugin::Test::ReportPrereqs", "name" : "@Author::KENTNL/Test::ReportPrereqs", - "version" : "0.013" + "version" : "0.014" }, { "class" : "Dist::Zilla::Plugin::Test::Kwalitee", @@ -362,7 +376,7 @@ } }, "name" : "@Author::KENTNL/Test::Compile::PerFile", - "version" : "0.002000" + "version" : "0.002001" }, { "class" : "Dist::Zilla::Plugin::Test::Perl::Critic", @@ -383,7 +397,7 @@ } }, "name" : "@Author::KENTNL/RewriteVersion::Sanitized", - "version" : "0.001000" + "version" : "0.001001" }, { "class" : "Dist::Zilla::Plugin::PodWeaver", @@ -606,7 +620,7 @@ "Dist::Zilla::Plugin::Git::Tag" : { "branch" : null, "signed" : 0, - "tag" : "0.001000-source", + "tag" : "0.002000-source", "tag_format" : "%v-source", "tag_message" : "v%v", "time_zone" : "local" @@ -621,7 +635,7 @@ { "class" : "Dist::Zilla::Plugin::Git::NextRelease", "name" : "@Author::KENTNL/Git::NextRelease", - "version" : "0.002010" + "version" : "0.002011" }, { "class" : "Dist::Zilla::Plugin::BumpVersionAfterRelease", @@ -677,7 +691,7 @@ "Dist::Zilla::Plugin::Git::Tag" : { "branch" : "releases", "signed" : 0, - "tag" : "0.001000", + "tag" : "0.002000", "tag_format" : "%v", "tag_message" : "v%v", "time_zone" : "local" @@ -724,7 +738,7 @@ } }, "name" : "@Author::KENTNL/Prereqs::Recommend::MatchInstalled", - "version" : "0.001000" + "version" : "0.002000" }, { "class" : "Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled", @@ -743,7 +757,7 @@ } }, "name" : "@Author::KENTNL/always_latest_develop_bundle", - "version" : "0.001000" + "version" : "0.002000" }, { "class" : "Dist::Zilla::Plugin::Prereqs", diff --git a/META.yml b/META.yml index b73c874..60d17f9 100644 --- a/META.yml +++ b/META.yml @@ -3,12 +3,15 @@ abstract: 'Create a Dependencies::Stats section detailing summarized differences author: - 'Kent Fredric ' build_requires: + CPAN::Changes::Release: '0' ExtUtils::MakeMaker: '0' + File::Spec: '0' File::Spec::Functions: '0' List::Util: '0' + Scalar::Util: '0' Test::Differences: '0' Test::More: '0.89' - version: '0' + version: '0.77' configure_requires: ExtUtils::MakeMaker: '6.30' dynamic_config: 0 @@ -21,8 +24,10 @@ name: CPAN-Changes-Group-Dependencies-Stats provides: CPAN::Changes::Group::Dependencies::Stats: file: lib/CPAN/Changes/Group/Dependencies/Stats.pm - version: '0.001000' + version: '0.002000' requires: + CPAN::Changes: '0.29' + CPAN::Changes::Group: '0' CPAN::Meta::Prereqs::Diff: '0' Carp: '0' Moo: '0' @@ -35,10 +40,15 @@ resources: bugtracker: https://github.com/kentnl/CPAN-Changes-Group-Dependencies-Stats/issues homepage: https://github.com/kentnl/CPAN-Changes-Group-Dependencies-Stats repository: https://github.com/kentnl/CPAN-Changes-Group-Dependencies-Stats.git -version: '0.001000' +version: '0.002000' x_BuiltWith: + failures: + CPAN::Changes::Group: 'Module::MetaData could not parse a version from /home/kent/perl5/perlbrew/perls/5.21.1-sdbm/lib/site_perl/5.21.1/CPAN/Changes/Group.pm' + CPAN::Changes::Release: 'Module::MetaData could not parse a version from /home/kent/perl5/perlbrew/perls/5.21.1-sdbm/lib/site_perl/5.21.1/CPAN/Changes/Release.pm' modules: + CPAN::Changes: '0.29' CPAN::Meta: '2.141520' + CPAN::Meta::Prereqs: '2.141520' CPAN::Meta::Prereqs::Diff: '0.001000' CPAN::Meta::Requirements: '2.125' Carp: '1.34' @@ -53,7 +63,7 @@ x_BuiltWith: Dist::Zilla::Plugin::Git::Commit: '2.023' Dist::Zilla::Plugin::Git::CommitBuild: '2.023' Dist::Zilla::Plugin::Git::GatherDir: '2.023' - Dist::Zilla::Plugin::Git::NextRelease: '0.002010' + Dist::Zilla::Plugin::Git::NextRelease: '0.002011' Dist::Zilla::Plugin::Git::Tag: '2.023' Dist::Zilla::Plugin::GithubMeta: '0.46' Dist::Zilla::Plugin::License: '5.019' @@ -61,7 +71,7 @@ x_BuiltWith: Dist::Zilla::Plugin::Manifest: '5.019' Dist::Zilla::Plugin::ManifestSkip: '5.019' Dist::Zilla::Plugin::MetaConfig: '5.019' - Dist::Zilla::Plugin::MetaData::BuiltWith: '1.000000' + Dist::Zilla::Plugin::MetaData::BuiltWith: '1.000001' Dist::Zilla::Plugin::MetaJSON: '5.019' Dist::Zilla::Plugin::MetaProvides::Package: '2.000002' Dist::Zilla::Plugin::MetaTests: '5.019' @@ -71,34 +81,36 @@ x_BuiltWith: Dist::Zilla::Plugin::PodSyntaxTests: '5.019' Dist::Zilla::Plugin::PodWeaver: '4.005' Dist::Zilla::Plugin::Prereqs: '5.019' - Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled: '0.001000' + Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled: '0.002000' Dist::Zilla::Plugin::ReadmeAnyFromPod: '0.141760' Dist::Zilla::Plugin::ReadmeFromPod: '0.21' - Dist::Zilla::Plugin::RewriteVersion::Sanitized: '0.001000' + Dist::Zilla::Plugin::RewriteVersion::Sanitized: '0.001001' Dist::Zilla::Plugin::RunExtraTests: '0.022' Dist::Zilla::Plugin::Test::CPAN::Changes: '0.008' - Dist::Zilla::Plugin::Test::Compile::PerFile: '0.002000' + Dist::Zilla::Plugin::Test::Compile::PerFile: '0.002001' Dist::Zilla::Plugin::Test::Kwalitee: '2.07' Dist::Zilla::Plugin::Test::MinimumVersion: '2.000005' Dist::Zilla::Plugin::Test::Perl::Critic: '2.112410' - Dist::Zilla::Plugin::Test::ReportPrereqs: '0.013' + Dist::Zilla::Plugin::Test::ReportPrereqs: '0.014' Dist::Zilla::Plugin::TestRelease: '5.019' Dist::Zilla::Plugin::Twitter: '0.025' Dist::Zilla::Plugin::UploadToCPAN: '5.019' - Dist::Zilla::PluginBundle::Author::KENTNL: '2.016003' + Dist::Zilla::PluginBundle::Author::KENTNL: '2.016004' ExtUtils::MakeMaker: '6.98' + File::Spec: '3.48' File::Spec::Functions: '3.48' List::Util: '1.39' Moo: '1.005000' - MooX::Lsub: '0.001001' + MooX::Lsub: '0.001002' Pod::Coverage::TrustPod: '0.100003' - Test::CPAN::Changes: '0.28' + Scalar::Util: '1.39' + Test::CPAN::Changes: '0.29' Test::CPAN::Meta: '0.23' Test::Differences: '0.62' - Test::Kwalitee: '1.18' + Test::Kwalitee: '1.19' Test::More: '1.001003' Test::Pod: '1.48' - Test::Pod::Coverage: '1.08' + Test::Pod::Coverage: '1.10' strict: '1.08' utf8: '1.14' version: '0.9908' @@ -159,7 +171,7 @@ x_Dist_Zilla: - -i uname_call: uname name: '@Author::KENTNL/MetaData::BuiltWith' - version: '1.000000' + version: '1.000001' - class: Dist::Zilla::Plugin::Git::GatherDir config: @@ -204,7 +216,7 @@ x_Dist_Zilla: - class: Dist::Zilla::Plugin::Test::ReportPrereqs name: '@Author::KENTNL/Test::ReportPrereqs' - version: '0.013' + version: '0.014' - class: Dist::Zilla::Plugin::Test::Kwalitee name: '@Author::KENTNL/Test::Kwalitee' @@ -233,7 +245,7 @@ x_Dist_Zilla: test_template: 01-basic.t.tpl xt_mode: ~ name: '@Author::KENTNL/Test::Compile::PerFile' - version: '0.002000' + version: '0.002001' - class: Dist::Zilla::Plugin::Test::Perl::Critic name: '@Author::KENTNL/Test::Perl::Critic' @@ -249,7 +261,7 @@ x_Dist_Zilla: mantissa: '6' normal_form: numify name: '@Author::KENTNL/RewriteVersion::Sanitized' - version: '0.001000' + version: '0.001001' - class: Dist::Zilla::Plugin::PodWeaver config: @@ -420,7 +432,7 @@ x_Dist_Zilla: Dist::Zilla::Plugin::Git::Tag: branch: ~ signed: 0 - tag: 0.001000-source + tag: 0.002000-source tag_format: '%v-source' tag_message: v%v time_zone: local @@ -431,7 +443,7 @@ x_Dist_Zilla: - class: Dist::Zilla::Plugin::Git::NextRelease name: '@Author::KENTNL/Git::NextRelease' - version: '0.002010' + version: '0.002011' - class: Dist::Zilla::Plugin::BumpVersionAfterRelease name: '@Author::KENTNL/BumpVersionAfterRelease' @@ -474,7 +486,7 @@ x_Dist_Zilla: Dist::Zilla::Plugin::Git::Tag: branch: releases signed: 0 - tag: '0.001000' + tag: '0.002000' tag_format: '%v' tag_message: v%v time_zone: local @@ -510,7 +522,7 @@ x_Dist_Zilla: - ExtUtils::MakeMaker - Test::More name: '@Author::KENTNL/Prereqs::Recommend::MatchInstalled' - version: '0.001000' + version: '0.002000' - class: Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled config: @@ -523,7 +535,7 @@ x_Dist_Zilla: - Dist::Zilla::PluginBundle::Author::KENTNL - Dist::Zilla::App::Command::bakeini name: '@Author::KENTNL/always_latest_develop_bundle' - version: '0.001000' + version: '0.002000' - class: Dist::Zilla::Plugin::Prereqs config: diff --git a/Makefile.PL b/Makefile.PL index 453be8b..ae8bded 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -20,6 +20,8 @@ my %WriteMakefileArgs = ( "LICENSE" => "perl", "NAME" => "CPAN::Changes::Group::Dependencies::Stats", "PREREQ_PM" => { + "CPAN::Changes" => "0.29", + "CPAN::Changes::Group" => 0, "CPAN::Meta::Prereqs::Diff" => 0, "Carp" => 0, "Moo" => 0, @@ -29,14 +31,17 @@ my %WriteMakefileArgs = ( "warnings" => 0 }, "TEST_REQUIRES" => { + "CPAN::Changes::Release" => 0, "ExtUtils::MakeMaker" => 0, + "File::Spec" => 0, "File::Spec::Functions" => 0, "List::Util" => 0, + "Scalar::Util" => 0, "Test::Differences" => 0, "Test::More" => "0.89", - "version" => 0 + "version" => "0.77" }, - "VERSION" => "0.001000", + "VERSION" => "0.002000", "test" => { "TESTS" => "t/*.t t/00-compile/*.t" } @@ -44,18 +49,23 @@ my %WriteMakefileArgs = ( my %FallbackPrereqs = ( + "CPAN::Changes" => "0.29", + "CPAN::Changes::Group" => 0, + "CPAN::Changes::Release" => 0, "CPAN::Meta::Prereqs::Diff" => 0, "Carp" => 0, "ExtUtils::MakeMaker" => 0, + "File::Spec" => 0, "File::Spec::Functions" => 0, "List::Util" => 0, "Moo" => 0, "MooX::Lsub" => 0, + "Scalar::Util" => 0, "Test::Differences" => 0, "Test::More" => "0.89", "strict" => 0, "utf8" => 0, - "version" => 0, + "version" => "0.77", "warnings" => 0 ); diff --git a/README b/README index 1d8ad24..7b7a6c7 100644 --- a/README +++ b/README @@ -3,28 +3,22 @@ NAME section detailing summarized differences VERSION - version 0.001000 + version 0.002000 SYNOPSIS - use CPAN::Changes::Release; + use CPAN::Changes::Release 0.29; use CPAN::Changes::Group::Dependencies::Stats; my $s = CPAN::Changes::Group::Dependencies::Stats->new( - new_prereqs => CPAN::Meta->load_file('Dist-Foo-1.01/META.json')->effective_prereqs - old_prereqs => CPAN::Meta->load_file('Dist-Foo-1.00/META.json')->effective_prereqs + prelude => [ 'Change statistics since 1.00' ], + new_prereqs => CPAN::Meta->load_file('Dist-Foo-1.01/META.json')->effective_prereqs, + old_prereqs => CPAN::Meta->load_file('Dist-Foo-1.00/META.json')->effective_prereqs, ); # Currently slightly complicated due to groups themselves # not presently being pluggable. my $rel = CPAN::Changes::Release->new( version => '1.01' ); - if (@{ my $changes = $s->changes }) { - $rel->add_group( 'Dependencies::Stats' ); - $rel->add_changes( - { group => 'Dependencies::Stats' }, - 'Change statistics since 1.00', - @{$changes} - ); - } + $rel->attach( $s ) if $s->has_changes; $rel->serialize(); # RESULT @@ -37,6 +31,15 @@ SYNOPSIS # - test: (recommends: +1 ↑1) METHODS + "has_changes" + Returns whether this group has any interesting changes or not. + + if ( $group->has_changes ) { + $release->attach_group( $group ); + } else { + $release->delete_group( $group->name ); + } + "changes" Returns a list of change entries. diff --git a/lib/CPAN/Changes/Group/Dependencies/Stats.pm b/lib/CPAN/Changes/Group/Dependencies/Stats.pm index da27b20..543e5a5 100644 --- a/lib/CPAN/Changes/Group/Dependencies/Stats.pm +++ b/lib/CPAN/Changes/Group/Dependencies/Stats.pm @@ -5,14 +5,16 @@ use utf8; package CPAN::Changes::Group::Dependencies::Stats; -our $VERSION = '0.001000'; +our $VERSION = '0.002000'; # ABSTRACT: Create a Dependencies::Stats section detailing summarized differences our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY -use Moo; +use Moo qw( extends has ); use Carp qw( croak ); +use CPAN::Changes 0.29; +use CPAN::Changes::Group; use CPAN::Meta::Prereqs::Diff; use MooX::Lsub qw( lsub ); @@ -43,14 +45,31 @@ use MooX::Lsub qw( lsub ); +extends 'CPAN::Changes::Group'; +sub FOREIGNBUILDARGS { + my ( undef, @args ) = @_; + if ( @args % 2 == 0 ) { + my (%args) = @args; + $args{'name'} = 'Dependencies::Stats' unless exists $args{'name'}; + return %args; + } + return @args; +} + +lsub prelude => sub { [] }; +lsub new_prereqs => sub { croak 'Required attribute was not provided' }; +lsub old_prereqs => sub { croak 'Required attribute was not provided' }; +lsub symbol_Added => sub { q[+] }; +lsub symbol_Upgrade => sub { q[↑] }; +lsub symbol_Downgrade => sub { q[↓] }; +lsub symbol_Removed => sub { q[-] }; +lsub symbol_Changed => sub { q[~] }; -lsub new_prereqs => sub { croak 'Required attribute was not provided' }; -lsub old_prereqs => sub { croak 'Required attribute was not provided' }; lsub prereqs_diff => sub { my ($self) = @_; return CPAN::Meta::Prereqs::Diff->new( @@ -58,11 +77,32 @@ lsub prereqs_diff => sub { old_prereqs => $self->old_prereqs, ); }; -lsub symbol_Added => sub { q[+] }; -lsub symbol_Upgrade => sub { q[↑] }; -lsub symbol_Downgrade => sub { q[↓] }; -lsub symbol_Removed => sub { q[-] }; -lsub symbol_Changed => sub { q[~] }; + +lsub _diff_items => sub { + my ($self) = @_; + my (@diffs) = $self->prereqs_diff->diff( + phases => [qw( configure build runtime test develop )], + types => [qw( requires recommends suggests conflicts )], + ); + return \@diffs; +}; + + + + + + + + + + + + + +sub has_changes { + my ($self) = @_; + return @{ $self->_diff_items } > 0; +} sub _phase_rel_changes { my ( $self, $phase, $rel, $phases ) = @_; @@ -107,13 +147,10 @@ sub _phase_changes { } sub _phase_rel_stats { - my ($self) = @_; - my (@diffs) = $self->prereqs_diff->diff( - phases => [qw( configure build runtime test develop )], - types => [qw( requires recommends suggests conflicts )], - ); + my ($self) = @_; my $phases = {}; - for my $diff (@diffs) { + + for my $diff ( @{ $self->_diff_items } ) { my $phase_m = $diff->phase; my $rel = $diff->type; @@ -180,7 +217,7 @@ sub _phase_rel_stats { sub changes { my ($self) = @_; - my @changes = (); + my @changes = @{ $self->prelude }; my $phases = $self->_phase_rel_stats; @@ -206,29 +243,23 @@ CPAN::Changes::Group::Dependencies::Stats - Create a Dependencies::Stats section =head1 VERSION -version 0.001000 +version 0.002000 =head1 SYNOPSIS - use CPAN::Changes::Release; + use CPAN::Changes::Release 0.29; use CPAN::Changes::Group::Dependencies::Stats; my $s = CPAN::Changes::Group::Dependencies::Stats->new( - new_prereqs => CPAN::Meta->load_file('Dist-Foo-1.01/META.json')->effective_prereqs - old_prereqs => CPAN::Meta->load_file('Dist-Foo-1.00/META.json')->effective_prereqs + prelude => [ 'Change statistics since 1.00' ], + new_prereqs => CPAN::Meta->load_file('Dist-Foo-1.01/META.json')->effective_prereqs, + old_prereqs => CPAN::Meta->load_file('Dist-Foo-1.00/META.json')->effective_prereqs, ); # Currently slightly complicated due to groups themselves # not presently being pluggable. my $rel = CPAN::Changes::Release->new( version => '1.01' ); - if (@{ my $changes = $s->changes }) { - $rel->add_group( 'Dependencies::Stats' ); - $rel->add_changes( - { group => 'Dependencies::Stats' }, - 'Change statistics since 1.00', - @{$changes} - ); - } + $rel->attach( $s ) if $s->has_changes; $rel->serialize(); # RESULT @@ -242,6 +273,16 @@ version 0.001000 =head1 METHODS +=head2 C + +Returns whether this group has any interesting changes or not. + + if ( $group->has_changes ) { + $release->attach_group( $group ); + } else { + $release->delete_group( $group->name ); + } + =head2 C Returns a list of change entries. @@ -279,6 +320,8 @@ For instance, this L diff --git a/misc/Changes.deps b/misc/Changes.deps new file mode 100644 index 0000000..2f191c1 --- /dev/null +++ b/misc/Changes.deps @@ -0,0 +1,15 @@ +This file contains changes in REQUIRED dependencies for standard CPAN phases (configure/build/runtime/test) + +0.001001 + [Added / runtime requires] + - CPAN::Changes 0.29 + - CPAN::Changes::Group + + [Added / test requires] + - CPAN::Changes::Release + - File::Spec + - Scalar::Util + + [Changed / test requires] + - version 0 → 0.77 + diff --git a/misc/Changes.deps.all b/misc/Changes.deps.all new file mode 100644 index 0000000..ab6e57d --- /dev/null +++ b/misc/Changes.deps.all @@ -0,0 +1,21 @@ +This file contains ALL changes in dependencies in both REQUIRED / OPTIONAL dependencies for all phases (configure/build/runtime/test/develop) + +0.001001 + [Added / runtime requires] + - CPAN::Changes 0.29 + - CPAN::Changes::Group + + [Added / test recommends] + - CPAN::Meta::Prereqs + + [Added / test requires] + - CPAN::Changes::Release + - File::Spec + - Scalar::Util + + [Changed / develop suggests] + - Dist::Zilla::PluginBundle::Author::KENTNL 2.016003 → 2.016004 + + [Changed / test requires] + - version 0 → 0.77 + diff --git a/misc/Changes.deps.dev b/misc/Changes.deps.dev new file mode 100644 index 0000000..63535d5 --- /dev/null +++ b/misc/Changes.deps.dev @@ -0,0 +1,6 @@ +This file contains changes to DEVELOPMENT dependencies only ( both REQUIRED and OPTIONAL ) + +0.001001 + [Changed / develop suggests] + - Dist::Zilla::PluginBundle::Author::KENTNL 2.016003 → 2.016004 + diff --git a/misc/Changes.deps.opt b/misc/Changes.deps.opt new file mode 100644 index 0000000..26aae02 --- /dev/null +++ b/misc/Changes.deps.opt @@ -0,0 +1,6 @@ +This file contains changes in OPTIONAL dependencies for standard CPAN phases (configure/build/runtime/test) + +0.001001 + [Added / test recommends] + - CPAN::Meta::Prereqs + diff --git a/t/00-compile/lib_CPAN_Changes_Group_Dependencies_Stats_pm.t b/t/00-compile/lib_CPAN_Changes_Group_Dependencies_Stats_pm.t index 0ad276e..198df2e 100644 --- a/t/00-compile/lib_CPAN_Changes_Group_Dependencies_Stats_pm.t +++ b/t/00-compile/lib_CPAN_Changes_Group_Dependencies_Stats_pm.t @@ -2,7 +2,7 @@ use strict; use warnings; # This test was generated for -# using by Dist::Zilla::Plugin::Test::Compile::PerFile ( @Author::KENTNL/Test::Compile::PerFile ) version 0.002000 +# using by Dist::Zilla::Plugin::Test::Compile::PerFile ( @Author::KENTNL/Test::Compile::PerFile ) version 0.002001 # with template 01-basic.t.tpl use Test::More 0.89 tests => 1; diff --git a/t/00-report-prereqs.dd b/t/00-report-prereqs.dd new file mode 100644 index 0000000..c2e1ac4 --- /dev/null +++ b/t/00-report-prereqs.dd @@ -0,0 +1,102 @@ +do { my $x = { + 'configure' => { + 'recommends' => { + 'ExtUtils::MakeMaker' => '6.98' + }, + 'requires' => { + 'ExtUtils::MakeMaker' => '6.30' + } + }, + 'develop' => { + 'requires' => { + 'Dist::Zilla::Plugin::Authority' => '1.006', + 'Dist::Zilla::Plugin::AutoPrereqs' => '0', + 'Dist::Zilla::Plugin::BumpVersionAfterRelease' => '0', + 'Dist::Zilla::Plugin::ConfirmRelease' => '0', + 'Dist::Zilla::Plugin::CopyFilesFromBuild' => '0', + 'Dist::Zilla::Plugin::EOLTests' => '0', + 'Dist::Zilla::Plugin::Git::Check' => '0', + 'Dist::Zilla::Plugin::Git::Commit' => '0', + 'Dist::Zilla::Plugin::Git::CommitBuild' => '0', + 'Dist::Zilla::Plugin::Git::GatherDir' => '0', + 'Dist::Zilla::Plugin::Git::NextRelease' => '0', + 'Dist::Zilla::Plugin::Git::Tag' => '0', + 'Dist::Zilla::Plugin::GithubMeta' => '0', + 'Dist::Zilla::Plugin::License' => '0', + 'Dist::Zilla::Plugin::MakeMaker' => '0', + 'Dist::Zilla::Plugin::Manifest' => '0', + 'Dist::Zilla::Plugin::ManifestSkip' => '0', + 'Dist::Zilla::Plugin::MetaConfig' => '0', + 'Dist::Zilla::Plugin::MetaData::BuiltWith' => '0', + 'Dist::Zilla::Plugin::MetaJSON' => '0', + 'Dist::Zilla::Plugin::MetaProvides::Package' => '1.14000001', + 'Dist::Zilla::Plugin::MetaTests' => '0', + 'Dist::Zilla::Plugin::MetaYAML' => '0', + 'Dist::Zilla::Plugin::MinimumPerl' => '0', + 'Dist::Zilla::Plugin::PodCoverageTests' => '0', + 'Dist::Zilla::Plugin::PodSyntaxTests' => '0', + 'Dist::Zilla::Plugin::PodWeaver' => '0', + 'Dist::Zilla::Plugin::Prereqs' => '0', + 'Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled' => '0', + 'Dist::Zilla::Plugin::ReadmeAnyFromPod' => '0', + 'Dist::Zilla::Plugin::ReadmeFromPod' => '0', + 'Dist::Zilla::Plugin::RewriteVersion::Sanitized' => '0', + 'Dist::Zilla::Plugin::RunExtraTests' => '0', + 'Dist::Zilla::Plugin::Test::CPAN::Changes' => '0', + 'Dist::Zilla::Plugin::Test::Compile::PerFile' => '0', + 'Dist::Zilla::Plugin::Test::Kwalitee' => '0', + 'Dist::Zilla::Plugin::Test::MinimumVersion' => '0', + 'Dist::Zilla::Plugin::Test::Perl::Critic' => '0', + 'Dist::Zilla::Plugin::Test::ReportPrereqs' => '0', + 'Dist::Zilla::Plugin::TestRelease' => '0', + 'Dist::Zilla::Plugin::Twitter' => '0', + 'Dist::Zilla::Plugin::UploadToCPAN' => '0', + 'Pod::Coverage::TrustPod' => '0', + 'Test::CPAN::Changes' => '0.19', + 'Test::CPAN::Meta' => '0', + 'Test::Kwalitee' => '1.12', + 'Test::Pod' => '1.41', + 'Test::Pod::Coverage' => '1.08' + }, + 'suggests' => { + 'Dist::Zilla::App::Command::bakeini' => '0.001001', + 'Dist::Zilla::PluginBundle::Author::KENTNL' => '2.016004' + } + }, + 'runtime' => { + 'requires' => { + 'CPAN::Changes' => '0.29', + 'CPAN::Changes::Group' => '0', + 'CPAN::Meta::Prereqs::Diff' => '0', + 'Carp' => '0', + 'Moo' => '0', + 'MooX::Lsub' => '0', + 'perl' => '5.008', + 'strict' => '0', + 'utf8' => '0', + 'warnings' => '0' + } + }, + 'test' => { + 'recommends' => { + 'CPAN::Meta' => '0', + 'CPAN::Meta::Prereqs' => '0', + 'CPAN::Meta::Requirements' => '2.120900', + 'ExtUtils::MakeMaker' => '6.98', + 'Test::More' => '1.001003' + }, + 'requires' => { + 'CPAN::Changes::Release' => '0', + 'ExtUtils::MakeMaker' => '0', + 'File::Spec' => '0', + 'File::Spec::Functions' => '0', + 'List::Util' => '0', + 'Scalar::Util' => '0', + 'Test::Differences' => '0', + 'Test::More' => '0.89', + 'version' => '0.77' + } + } + }; + $x; + } \ No newline at end of file diff --git a/t/00-report-prereqs.t b/t/00-report-prereqs.t index 1c2fff4..44a7411 100644 --- a/t/00-report-prereqs.t +++ b/t/00-report-prereqs.t @@ -3,18 +3,20 @@ use strict; use warnings; -# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.013 +# This test was generated by Dist::Zilla::Plugin::Test::ReportPrereqs 0.014 use Test::More tests => 1; use ExtUtils::MakeMaker; use File::Spec::Functions; -use List::Util qw/max/; +use List::Util qw/max first/; +use Scalar::Util qw/blessed/; use version; # hide optional CPAN::Meta modules from prereq scanner # and check if they are available my $cpan_meta = "CPAN::Meta"; +my $cpan_meta_pre = "CPAN::Meta::Prereqs"; my $cpan_meta_req = "CPAN::Meta::Requirements"; my $HAS_CPAN_META = eval "require $cpan_meta"; ## no critic my $HAS_CPAN_META_REQ = eval "require $cpan_meta_req; $cpan_meta_req->VERSION('2.120900')"; @@ -22,207 +24,139 @@ my $HAS_CPAN_META_REQ = eval "require $cpan_meta_req; $cpan_meta_req->VERSION('2 # Verify requirements? my $DO_VERIFY_PREREQS = 1; -sub _merge_requires { +sub _merge_prereqs { my ($collector, $prereqs) = @_; - for my $phase ( qw/configure build test runtime develop/ ) { - next unless exists $prereqs->{$phase}; - if ( my $req = $prereqs->{$phase}{'requires'} ) { - my $cmr = CPAN::Meta::Requirements->from_string_hash( $req ); - $collector->add_requirements( $cmr ); + + # CPAN::Meta::Prereqs object + if (blessed $collector eq $cpan_meta_pre) { + return $collector->with_merged_prereqs( + CPAN::Meta::Prereqs->new( $prereqs ) + ); + } + + # Raw hashrefs + for my $phase ( keys %$prereqs ) { + for my $type ( keys %{ $prereqs->{$phase} } ) { + for my $module ( keys %{ $prereqs->{$phase}{$type} } ) { + $collector->{$phase}{$type}{$module} = $prereqs->{$phase}{$type}{$module}; + } } } + + return $collector; } -my %include = map {; $_ => 1 } qw( +my @include = qw( ); -my %exclude = map {; $_ => 1 } qw( +my @exclude = qw( ); # Add static prereqs to the included modules list -my $static_prereqs = do { my $x = { - 'configure' => { - 'recommends' => { - 'ExtUtils::MakeMaker' => '6.98' - }, - 'requires' => { - 'ExtUtils::MakeMaker' => '6.30' - } - }, - 'develop' => { - 'requires' => { - 'Dist::Zilla::Plugin::Authority' => '1.006', - 'Dist::Zilla::Plugin::AutoPrereqs' => '0', - 'Dist::Zilla::Plugin::BumpVersionAfterRelease' => '0', - 'Dist::Zilla::Plugin::ConfirmRelease' => '0', - 'Dist::Zilla::Plugin::CopyFilesFromBuild' => '0', - 'Dist::Zilla::Plugin::EOLTests' => '0', - 'Dist::Zilla::Plugin::Git::Check' => '0', - 'Dist::Zilla::Plugin::Git::Commit' => '0', - 'Dist::Zilla::Plugin::Git::CommitBuild' => '0', - 'Dist::Zilla::Plugin::Git::GatherDir' => '0', - 'Dist::Zilla::Plugin::Git::NextRelease' => '0', - 'Dist::Zilla::Plugin::Git::Tag' => '0', - 'Dist::Zilla::Plugin::GithubMeta' => '0', - 'Dist::Zilla::Plugin::License' => '0', - 'Dist::Zilla::Plugin::MakeMaker' => '0', - 'Dist::Zilla::Plugin::Manifest' => '0', - 'Dist::Zilla::Plugin::ManifestSkip' => '0', - 'Dist::Zilla::Plugin::MetaConfig' => '0', - 'Dist::Zilla::Plugin::MetaData::BuiltWith' => '0', - 'Dist::Zilla::Plugin::MetaJSON' => '0', - 'Dist::Zilla::Plugin::MetaProvides::Package' => '1.14000001', - 'Dist::Zilla::Plugin::MetaTests' => '0', - 'Dist::Zilla::Plugin::MetaYAML' => '0', - 'Dist::Zilla::Plugin::MinimumPerl' => '0', - 'Dist::Zilla::Plugin::PodCoverageTests' => '0', - 'Dist::Zilla::Plugin::PodSyntaxTests' => '0', - 'Dist::Zilla::Plugin::PodWeaver' => '0', - 'Dist::Zilla::Plugin::Prereqs' => '0', - 'Dist::Zilla::Plugin::Prereqs::Recommend::MatchInstalled' => '0', - 'Dist::Zilla::Plugin::ReadmeAnyFromPod' => '0', - 'Dist::Zilla::Plugin::ReadmeFromPod' => '0', - 'Dist::Zilla::Plugin::RewriteVersion::Sanitized' => '0', - 'Dist::Zilla::Plugin::RunExtraTests' => '0', - 'Dist::Zilla::Plugin::Test::CPAN::Changes' => '0', - 'Dist::Zilla::Plugin::Test::Compile::PerFile' => '0', - 'Dist::Zilla::Plugin::Test::Kwalitee' => '0', - 'Dist::Zilla::Plugin::Test::MinimumVersion' => '0', - 'Dist::Zilla::Plugin::Test::Perl::Critic' => '0', - 'Dist::Zilla::Plugin::Test::ReportPrereqs' => '0', - 'Dist::Zilla::Plugin::TestRelease' => '0', - 'Dist::Zilla::Plugin::Twitter' => '0', - 'Dist::Zilla::Plugin::UploadToCPAN' => '0', - 'Pod::Coverage::TrustPod' => '0', - 'Test::CPAN::Changes' => '0.19', - 'Test::CPAN::Meta' => '0', - 'Test::Kwalitee' => '1.12', - 'Test::Pod' => '1.41', - 'Test::Pod::Coverage' => '1.08' - }, - 'suggests' => { - 'Dist::Zilla::App::Command::bakeini' => '0.001001', - 'Dist::Zilla::PluginBundle::Author::KENTNL' => '2.016003' - } - }, - 'runtime' => { - 'requires' => { - 'CPAN::Meta::Prereqs::Diff' => '0', - 'Carp' => '0', - 'Moo' => '0', - 'MooX::Lsub' => '0', - 'perl' => '5.008', - 'strict' => '0', - 'utf8' => '0', - 'warnings' => '0' - } - }, - 'test' => { - 'recommends' => { - 'CPAN::Meta' => '0', - 'CPAN::Meta::Requirements' => '2.120900', - 'ExtUtils::MakeMaker' => '6.98', - 'Test::More' => '1.001003' - }, - 'requires' => { - 'ExtUtils::MakeMaker' => '0', - 'File::Spec::Functions' => '0', - 'List::Util' => '0', - 'Test::Differences' => '0', - 'Test::More' => '0.89', - 'version' => '0' - } - } - }; - $x; - }; - -delete $static_prereqs->{develop} if not $ENV{AUTHOR_TESTING}; -$include{$_} = 1 for map { keys %$_ } map { values %$_ } values %$static_prereqs; - -# Merge requirements for major phases (if we can) -my $all_requires; -if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META_REQ ) { - $all_requires = $cpan_meta_req->new; - _merge_requires($all_requires, $static_prereqs); +my $static_prereqs = do 't/00-report-prereqs.dd'; + +### XXX: Assume these are Runtime Requires +my $static_prereqs_requires = $static_prereqs->{runtime}{requires}; +for my $mod (@include) { + $static_prereqs_requires->{$mod} = 0 unless exists $static_prereqs_requires->{$mod}; } +# Merge all prereqs (either with ::Prereqs or a hashref) +my $full_prereqs = _merge_prereqs( + ( $HAS_CPAN_META ? $cpan_meta_pre->new : {} ), + $static_prereqs +); # Add dynamic prereqs to the included modules list (if we can) -my ($source) = grep { -f } 'MYMETA.json', 'MYMETA.yml'; +my $source = first { -f } 'MYMETA.json', 'MYMETA.yml'; if ( $source && $HAS_CPAN_META ) { - if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { - my $dynamic_prereqs = $meta->prereqs; - delete $dynamic_prereqs->{develop} if not $ENV{AUTHOR_TESTING}; - $include{$_} = 1 for map { keys %$_ } map { values %$_ } values %$dynamic_prereqs; - - if ( $DO_VERIFY_PREREQS && $HAS_CPAN_META_REQ ) { - _merge_requires($all_requires, $dynamic_prereqs); + if ( my $meta = eval { CPAN::Meta->load_file($source) } ) { + $full_prereqs = _merge_prereqs($full_prereqs, $meta->prereqs); } - } } else { - $source = 'static metadata'; + $source = 'static metadata'; } -my @modules = sort grep { ! $exclude{$_} } keys %include; -my @reports = [qw/Version Module/]; +my @full_reports; my @dep_errors; -my $req_hash = defined($all_requires) ? $all_requires->as_string_hash : {}; - -for my $mod ( @modules ) { - next if $mod eq 'perl'; - my $file = $mod; - $file =~ s{::}{/}g; - $file .= ".pm"; - my ($prefix) = grep { -e catfile($_, $file) } @INC; - if ( $prefix ) { - my $ver = MM->parse_version( catfile($prefix, $file) ); - $ver = "undef" unless defined $ver; # Newer MM should do this anyway - push @reports, [$ver, $mod]; - - if ( $DO_VERIFY_PREREQS && $all_requires ) { - my $req = $req_hash->{$mod}; - if ( defined $req && length $req ) { - if ( ! defined eval { version->parse($ver) } ) { - push @dep_errors, "$mod version '$ver' cannot be parsed (version '$req' required)"; - } - elsif ( ! $all_requires->accepts_module( $mod => $ver ) ) { - push @dep_errors, "$mod version '$ver' is not in required range '$req'"; +my $req_hash = $HAS_CPAN_META ? $full_prereqs->as_string_hash : $full_prereqs; + +for my $phase ( qw(configure build test runtime develop) ) { + next unless $req_hash->{$phase}; + next if ($phase eq 'develop' and not $ENV{AUTHOR_TESTING}); + + for my $type ( qw(requires recommends suggests conflicts) ) { + next unless $req_hash->{$phase}{$type}; + + my $title = ucfirst($phase).' '.ucfirst($type); + my @reports = [qw/Module Want Have/]; + + for my $mod ( sort keys %{ $req_hash->{$phase}{$type} } ) { + next if $mod eq 'perl'; + next if first { $_ eq $mod } @exclude; + + my $file = $mod; + $file =~ s{::}{/}g; + $file .= ".pm"; + my $prefix = first { -e catfile($_, $file) } @INC; + + my $want = $req_hash->{$phase}{$type}{$mod}; + $want = "undef" unless defined $want; + $want = "any" if !$want && $want == 0; + + my $req_string = $want eq 'any' ? 'any version required' : "version '$want' required"; + + if ($prefix) { + my $have = MM->parse_version( catfile($prefix, $file) ); + $have = "undef" unless defined $have; + push @reports, [$mod, $want, $have]; + + if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { + if ( ! defined eval { version->parse($have) } ) { + push @dep_errors, "$mod version '$have' cannot be parsed ($req_string)"; + } + elsif ( ! $full_prereqs->requirements_for( $phase, $type )->accepts_module( $mod => $have ) ) { + push @dep_errors, "$mod version '$have' is not in required range '$want'"; + } + } + } + else { + push @reports, [$mod, $want, "missing"]; + + if ( $DO_VERIFY_PREREQS && $type eq 'requires' ) { + push @dep_errors, "$mod is not installed ($req_string)"; + } + } } - } - } - } - else { - push @reports, ["missing", $mod]; + if ( @reports ) { + push @full_reports, "=== $title ===\n\n"; - if ( $DO_VERIFY_PREREQS && $all_requires ) { - my $req = $req_hash->{$mod}; - if ( defined $req && length $req ) { - push @dep_errors, "$mod is not installed (version '$req' required)"; - } + my $ml = max map { length $_->[0] } @reports; + my $wl = max map { length $_->[1] } @reports; + my $hl = max map { length $_->[2] } @reports; + splice @reports, 1, 0, ["-" x $ml, "-" x $wl, "-" x $hl]; + + push @full_reports, map { sprintf(" %*s %*s %*s\n", -$ml, $_->[0], $wl, $_->[1], $hl, $_->[2]) } @reports; + push @full_reports, "\n"; + } } - } } -if ( @reports ) { - my $vl = max map { length $_->[0] } @reports; - my $ml = max map { length $_->[1] } @reports; - splice @reports, 1, 0, ["-" x $vl, "-" x $ml]; - diag "\nVersions for all modules listed in $source (including optional ones):\n", - map {sprintf(" %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports; +if ( @full_reports ) { + diag "\nVersions for all modules listed in $source (including optional ones):\n\n", @full_reports; } if ( @dep_errors ) { - diag join("\n", - "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", - "The following REQUIRED prerequisites were not satisfied:\n", - @dep_errors, - "\n" - ); + diag join("\n", + "\n*** WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING ***\n", + "The following REQUIRED prerequisites were not satisfied:\n", + @dep_errors, + "\n" + ); } pass; diff --git a/t/attach.t b/t/attach.t new file mode 100644 index 0000000..a2f24ce --- /dev/null +++ b/t/attach.t @@ -0,0 +1,45 @@ +use strict; +use warnings; + +use Test::More; + +# FILENAME: attach.t +# CREATED: 07/24/14 17:13:46 by Kent Fredric (kentnl) +# ABSTRACT: Test attaching data to a release +use Test::Differences qw( eq_or_diff ); + +use CPAN::Changes::Group::Dependencies::Stats; +use CPAN::Changes 0.29; +use CPAN::Changes::Release; + +my $release = CPAN::Changes::Release->new( + version => '0.01', + date => '2009-07-06', + +); + +my $stats = CPAN::Changes::Group::Dependencies::Stats->new( + old_prereqs => {}, + new_prereqs => { runtime => { requires => { 'Moo' => 2 } } }, +); + +my $other_stats = CPAN::Changes::Group::Dependencies::Stats->new( + name => "Other::Name", + old_prereqs => {}, + new_prereqs => {}, +); + +$release->attach_group($stats) if $stats->has_changes; +$release->attach_group($other_stats) if $other_stats->has_changes; + +my $string = $release->serialize; + +eq_or_diff $string, <<'EOF', 'Serialize as expected'; +0.01 2009-07-06 + [Dependencies::Stats] + - runtime: +1 + +EOF + +done_testing; +