diff --git a/.travis.yml b/.travis.yml index bd1b07157..5ee5fa25b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,11 +7,8 @@ perl: - "5.24" - "5.22" - "5.20" - - "5.18" - - "5.16" - - "5.14" before_install: - - git clone git://github.com/rjbs/travis-perl-helpers -b release-testing ~/travis-perl-helpers + - git clone git://github.com/travis-perl/helpers ~/travis-perl-helpers - source ~/travis-perl-helpers/init - build-perl - perl -V diff --git a/Changes b/Changes index a21523052..62006a4d2 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,30 @@ Revision history for {{$dist->name}} {{$NEXT}} + [THIS RELEASE MIGHT BREAK YOUR BUILD] + - now requires perl v5.20.0 + - the "plugins" and "plugins_with" methods, along with a few others, + now are meant to be called in list context rather than scalar; you + should update to calling in list context, as Dist::Zilla v8 will stop + returning references + + [LESS TERRIFYING CHANGES] + - Introducing Dist::Zilla::Dialect! This library turns on the features + being used by core Dist::Zilla code. Probably don't just use this + blindly in your code, but there it is. + - replace uses of File::HomeDir with a simple glob() (thanks, Karen + Etheridge) + - Dist::Zilla::Tester no longer changes into the source directory when + building. This may break some plugins that do not prepend + $zilla->root to paths when they should. (thanks, Karen Etheridge) + - version strings must now pass version.pm's is_strict checks, which + eliminates such discouraged constructs as v1.23_01 (thanks, Karen + Etheridge) + - the test generated by [MetaTests] is now an author test, not a + release test (thanks, Karen Etheridge) + - all builds now result in a .build/latest symlink (thanks again, + Karen) + - more plugins add their config to metadata when [MetaConfig] is used 6.012 2018-04-21 10:20:21+02:00 Europe/Oslo - revert addition of Archive::Tar::Wrapper as a mandatory prereq (in diff --git a/corpus/dist/AuthorDeps/dist.ini b/corpus/dist/AuthorDeps/dist.ini index 7a5abf8ef..1e05044a0 100644 --- a/corpus/dist/AuthorDeps/dist.ini +++ b/corpus/dist/AuthorDeps/dist.ini @@ -25,3 +25,5 @@ skip = ^DZPA::Skip :version = 5.0 encoding = bytes filename = t/data.bin + +[MetaConfig] diff --git a/corpus/dist/AutoPrereqs/dist.ini b/corpus/dist/AutoPrereqs/dist.ini index 34e0f681e..47208bcd2 100644 --- a/corpus/dist/AutoPrereqs/dist.ini +++ b/corpus/dist/AutoPrereqs/dist.ini @@ -25,3 +25,5 @@ Archive::Tar::Wrapper = 0.15 [Prereqs / RuntimeSuggests] PPI::XS = 1.23 + +[MetaConfig] diff --git a/corpus/dist/DZ-NonAscii/dist.ini b/corpus/dist/DZ-NonAscii/dist.ini index 46e0c934a..e7c4ce5c7 100644 --- a/corpus/dist/DZ-NonAscii/dist.ini +++ b/corpus/dist/DZ-NonAscii/dist.ini @@ -8,3 +8,4 @@ copyright_holder = ภูมิพลอดุลยเดช [@Classic] [MetaJSON] [NextRelease] +[MetaConfig] diff --git a/corpus/dist/DZ1/dist.ini b/corpus/dist/DZ1/dist.ini index 1215b7e23..1ed1b5fe5 100644 --- a/corpus/dist/DZ1/dist.ini +++ b/corpus/dist/DZ1/dist.ini @@ -5,3 +5,4 @@ license = Perl_5 copyright_holder = E. Xavier Ample [@Classic] +[MetaConfig] diff --git a/dist.ini b/dist.ini index ff3fe04b0..b6377e956 100644 --- a/dist.ini +++ b/dist.ini @@ -32,7 +32,7 @@ Data::OptList = 0.110 PPI::XS = 0 [Prereqs] -perl = v5.14.0 ; how tempted am I to set this to v5.20? very! +perl = v5.20.0 ; how tempted am I to set this to v5.24? somewhat! parent = 0 ; used by the AutoPrereq test corpus diff --git a/lib/Dist/Zilla.pm b/lib/Dist/Zilla.pm index e07cc8767..249010625 100644 --- a/lib/Dist/Zilla.pm +++ b/lib/Dist/Zilla.pm @@ -7,10 +7,12 @@ with 'Dist::Zilla::Role::ConfigDumper'; # This comment has fün̈n̈ÿ characters. use MooseX::Types::Moose qw(ArrayRef Bool HashRef Object Str); -use MooseX::Types::Perl qw(DistName LaxVersionStr); +use MooseX::Types::Perl qw(DistName); use Moose::Util::TypeConstraints; -use Dist::Zilla::Types qw(Path License ReleaseStatus); +use Dist::Zilla::Dialect; + +use Dist::Zilla::Types qw(Path License ReleaseStatus VersionStr); use Log::Dispatchouli 1.100712; # proxy_loggers, quiet_fatal use Dist::Zilla::Path; @@ -71,25 +73,22 @@ This is the version of the distribution to be created. =cut has _version_override => ( - isa => LaxVersionStr, + isa => VersionStr, is => 'ro' , init_arg => 'version', ); -# XXX: *clearly* this needs to be really much smarter -- rjbs, 2008-06-01 has version => ( is => 'rw', - isa => LaxVersionStr, + isa => VersionStr, lazy => 1, init_arg => undef, builder => '_build_version', ); -sub _build_name { - my ($self) = @_; - +sub _build_name ($self) { my $name; - for my $plugin (@{ $self->plugins_with(-NameProvider) }) { + for my $plugin ($self->plugins_with(-NameProvider)) { next unless defined(my $this_name = $plugin->provide_name); $self->log_fatal('attempted to set name twice') if defined $name; @@ -102,12 +101,10 @@ sub _build_name { $name; } -sub _build_version { - my ($self) = @_; - +sub _build_version ($self) { my $version = $self->_version_override; - for my $plugin (@{ $self->plugins_with(-VersionProvider) }) { + for my $plugin ($self->plugins_with(-VersionProvider)) { next unless defined(my $this_version = $plugin->provide_version); $self->log_fatal('attempted to set version twice') if defined $version; @@ -155,9 +152,7 @@ has release_status => ( builder => '_build_release_status', ); -sub _build_release_status { - my ($self) = @_; - +sub _build_release_status ($self) { # environment variables override completely return $self->_release_status_from_env if $self->_release_status_from_env; @@ -169,7 +164,7 @@ sub _build_release_status { # the version $status = 'testing' if $self->_override_is_trial; - for my $plugin (@{ $self->plugins_with(-ReleaseStatusProvider) }) { + for my $plugin ($self->plugins_with(-ReleaseStatusProvider)) { next unless defined(my $this_status = $plugin->provide_release_status); $self->log_fatal('attempted to set release status twice') @@ -189,7 +184,6 @@ has _release_status_from_env => ( ); sub _build_release_status_from_env { - my ($self) = @_; return $ENV{RELEASE_STATUS} if $ENV{RELEASE_STATUS}; return $ENV{TRIAL} ? 'testing' : ''; } @@ -205,9 +199,7 @@ has abstract => ( is => 'rw', isa => 'Str', lazy => 1, - default => sub { - my ($self) = @_; - + default => sub ($self, @) { unless ($self->main_module) { die "no abstract given and no main_module found; make sure your main module is in ./lib\n"; } @@ -254,25 +246,23 @@ has main_module => ( isa => 'Dist::Zilla::Role::File', lazy => 1, init_arg => undef, - default => sub { - my ($self) = @_; - + default => sub ($self, @) { my $file; my $guess; if ( $self->_has_main_module_override ) { $file = first { $_->name eq $self->_main_module_override } - @{ $self->files }; + $self->files->@*; } else { # We're having to guess $guess = $self->name =~ s{-}{/}gr; $guess = "lib/$guess.pm"; - $file = (first { $_->name eq $guess } @{ $self->files }) + $file = (first { $_->name eq $guess } $self->files->@*) || (sort { length $a->name <=> length $b->name } grep { $_->name =~ m{\.pm\z} and $_->name =~ m{\Alib/} } - @{ $self->files })[0]; + $self->files->@*)[0]; $self->log("guessing dist's main_module is " . ($file ? $file->name : $guess)); } @@ -285,9 +275,9 @@ has main_module => ( } else { push @errorlines,"We tried to guess '$guess' but no file like that existed"; } - if (not @{ $self->files }) { + if (not $self->files->@*) { push @errorlines, "Upon further inspection we didn't find any files in your dist, did you add any?"; - } elsif ( none { $_->name =~ m{^lib/.+\.pm\z} } @{ $self->files } ){ + } elsif ( none { $_->name =~ m{^lib/.+\.pm\z} } $self->files->@* ){ push @errorlines, "We didn't find any .pm files in your dist, this is probably a problem."; } push @errorlines,"Cannot continue without a main_module"; @@ -326,16 +316,14 @@ has license => ( }, ); -sub _build_license { - my ($self) = @_; - +sub _build_license ($self) { my $license_class = $self->_license_class; my $copyright_holder = $self->_copyright_holder; my $copyright_year = $self->_copyright_year; my $provided_license; - for my $plugin (@{ $self->plugins_with(-LicenseProvider) }) { + for my $plugin ($self->plugins_with(-LicenseProvider)) { my $this_license = $plugin->provide_license({ copyright_holder => $copyright_holder, copyright_year => $copyright_year, @@ -402,8 +390,8 @@ has _license_class => ( lazy => 1, init_arg => 'license', clearer => '_clear_license_class', - default => sub { - my $stash = $_[0]->stash_named('%Rights'); + default => sub ($self, @) { + my $stash = $self->stash_named('%Rights'); $stash && return $stash->license_class; return; } @@ -415,8 +403,8 @@ has _copyright_holder => ( lazy => 1, init_arg => 'copyright_holder', clearer => '_clear_copyright_holder', - default => sub { - return unless my $stash = $_[0]->stash_named('%Rights'); + default => sub ($self, @) { + return unless my $stash = $self->stash_named('%Rights'); $stash && return $stash->copyright_holder; return; } @@ -428,7 +416,7 @@ has _copyright_year => ( lazy => 1, init_arg => 'copyright_year', clearer => '_clear_copyright_year', - default => sub { + default => sub ($self, @) { # Oh man. This is a terrible idea! I mean, what if by the code gets run # around like Dec 31, 23:59:59.9 and by the time the default gets called # it's the next year but the default was already set up? Oh man. That @@ -436,7 +424,7 @@ has _copyright_year => ( # but think of the performance hit! I guess we'll have to suffer through # this until we can optimize the code to not take .1s to run, right? -- # rjbs, 2008-06-13 - my $stash = $_[0]->stash_named('%Rights'); + my $stash = $self->stash_named('%Rights'); my $year = $stash && $stash->copyright_year; return( $year // (localtime)[5] + 1900 ); } @@ -444,6 +432,8 @@ has _copyright_year => ( =attr authors + my @authors = $zilla->authors; + This is an arrayref of author strings, like this: [ @@ -451,19 +441,18 @@ This is an arrayref of author strings, like this: 'X. Ample, Jr ', ] -This is likely to change at some point in the near future. +The method C returns a list of the authors. =cut has authors => ( - is => 'ro', isa => ArrayRef[Str], lazy => 1, - default => sub { - my ($self) = @_; - + traits => [ 'Array' ], + reader => '_authors', + default => sub ($self) { if (my $stash = $self->stash_named('%User')) { - return $stash->authors; + return [ $stash->authors ]; } my $author = try { $self->copyright_holder }; @@ -476,6 +465,22 @@ has authors => ( }, ); +sub authors ($self) { + state %warned; + + my $authors = $self->_authors; + + if (! wantarray) { + my ($package, $pmfile, $line) = caller; + Carp::carp('in v7, $zilla->authors should only be called in list context; scalar context behavior will change in Dist::Zilla v8') + unless $warned{ $pmfile, $line }++; + + return $authors; + } + + return @$authors; +} + =attr files This is an arrayref of objects implementing L that @@ -495,13 +500,12 @@ has files => ( default => sub { [] }, ); -sub prune_file { - my ($self, $file) = @_; - my @files = @{ $self->files }; +sub prune_file ($self, $file) { + my @files = $self->files->@*; for my $i (0 .. $#files) { next unless $file == $files[ $i ]; - splice @{ $self->files }, $i, 1; + splice $self->files->@*, $i, 1; return; } @@ -546,28 +550,45 @@ has _override_is_trial => ( default => 0, ); -sub _build_is_trial { - my ($self) = @_; - return $self->release_status =~ /\A(?:testing|unstable)\z/ ? 1 : 0; +sub _build_is_trial ($self) { + return $self->release_status =~ /\A(?:testing|unstable)\z/ ? 1 : 0; } =attr plugins -This is an arrayref of plugins that have been plugged into this Dist::Zilla -object. - -Non-core code B alter this arrayref. Public access to this attribute -B in the future. +This is a list of plugins that have been plugged into this Dist::Zilla object. =cut has plugins => ( - is => 'ro', isa => 'ArrayRef[Dist::Zilla::Role::Plugin]', init_arg => undef, + traits => [ 'Array' ], + reader => '_plugins', default => sub { [ ] }, ); +sub _add_plugin ($self, $plugin) { + push $self->_plugins->@*, $plugin; + return; +} + +sub plugins ($self) { + state %warned; + + my $plugins = $self->_plugins; + + if (! wantarray) { + my ($package, $pmfile, $line) = caller; + Carp::carp('in v7, $zilla->plugins should only be called in list context; scalar context behavior will change in Dist::Zilla v8') + unless $warned{ $pmfile, $line }++; + + return $plugins; + } + + return @$plugins; +} + =attr distmeta This is a hashref containing the metadata about this distribution that will be @@ -584,14 +605,12 @@ has distmeta => ( builder => '_build_distmeta', ); -sub _build_distmeta { - my ($self) = @_; - +sub _build_distmeta ($self) { require CPAN::Meta::Merge; my $meta_merge = CPAN::Meta::Merge->new(default_version => 2); my $meta = {}; - for (@{ $self->plugins_with(-MetaProvider) }) { + for ($self->plugins_with(-MetaProvider)) { $meta = $meta_merge->merge($meta, $_->metadata); } @@ -603,7 +622,7 @@ sub _build_distmeta { name => $self->name, version => $self->version, abstract => $self->abstract, - author => $self->authors, + author => [ $self->authors ], license => [ $self->license->meta2_name ], release_status => $self->release_status, @@ -647,9 +666,8 @@ has prereqs => ( =cut -sub plugin_named { - my ($self, $name) = @_; - my $plugin = first { $_->plugin_name eq $name } @{ $self->plugins }; +sub plugin_named ($self, $name) { + my $plugin = first { $_->plugin_name eq $name } $self->plugins; return $plugin if $plugin; return; @@ -657,21 +675,28 @@ sub plugin_named { =method plugins_with - my $roles = $zilla->plugins_with( -SomeRole ); + my @roles = $zilla->plugins_with( -SomeRole ); -This method returns an arrayref containing all the Dist::Zilla object's plugins -that perform the named role. If the given role name begins with a dash, the -dash is replaced with "Dist::Zilla::Role::" +This method returns a list of all the Dist::Zilla object's plugins that perform +the named role. If the given role name begins with a dash, the dash is +replaced with "Dist::Zilla::Role::" =cut -sub plugins_with { - my ($self, $role) = @_; - +sub plugins_with ($self, $role) { $role =~ s/^-/Dist::Zilla::Role::/; - my $plugins = [ grep { $_->does($role) } @{ $self->plugins } ]; + my @plugins = grep { $_->does($role) } $self->plugins; + + state %warned; + if (! wantarray) { + my ($package, $pmfile, $line) = caller; + Carp::carp('in v7, $zilla->plugins_with should only be called in list context; scalar context behavior will change in Dist::Zilla v8') + unless $warned{ $pmfile, $line }++; + + return \@plugins; + } - return $plugins; + return @plugins; } =method find_files @@ -685,9 +710,7 @@ found, an exception will be raised. =cut -sub find_files { - my ($self, $finder_name) = @_; - +sub find_files ($self, $finder_name) { $self->log_fatal("no plugin named $finder_name found") unless my $plugin = $self->plugin_named($finder_name); @@ -697,16 +720,14 @@ sub find_files { $plugin->find_files; } -sub _check_dupe_files { - my ($self) = @_; - +sub _check_dupe_files ($self) { my %files_named; my @dupes; - for my $file (@{ $self->files }) { + for my $file ($self->files->@*) { my $filename = $file->name; if (my $seen = $files_named{ $filename }) { - push @{ $seen }, $file; - push @dupes, $filename if @{ $seen } == 2; + push @$seen, $file; + push @dupes, $filename if @$seen == 2; } else { $files_named{ $filename } = [ $file ]; } @@ -716,16 +737,14 @@ sub _check_dupe_files { for my $name (@dupes) { $self->log("attempt to add $name multiple times; added by: " - . join('; ', map { $_->added_by } @{ $files_named{ $name } }) + . join('; ', map { $_->added_by } $files_named{ $name }->@*) ); } Carp::croak("aborting; duplicate files would be produced"); } -sub _write_out_file { - my ($self, $file, $build_root) = @_; - +sub _write_out_file ($self, $file, $build_root) { # Okay, this is a bit much, until we have ->debug. -- rjbs, 2008-06-13 # $self->log("writing out " . $file->name); @@ -762,13 +781,12 @@ has logger => ( isa => 'Log::Dispatchouli::Proxy', # could be duck typed, I guess lazy => 1, handles => [ qw(log log_debug log_fatal) ], - default => sub { - $_[0]->chrome->logger->proxy({ proxy_prefix => '[DZ] ' }) + default => sub ($self, @) { + $self->chrome->logger->proxy({ proxy_prefix => '[DZ] ' }) }, ); -around dump_config => sub { - my ($orig, $self) = @_; +around dump_config => sub ($orig, $self) { my $config = $self->$orig; $config->{is_trial} = $self->is_trial; return $config; @@ -798,9 +816,7 @@ stash (from the user's global configuration). =cut -sub stash_named { - my ($self, $name) = @_; - +sub stash_named ($self, $name) { return $self->_local_stashes->{ $name } if $self->_local_stashes->{$name}; return $self->_global_stashes->{ $name }; } diff --git a/lib/Dist/Zilla/App.pm b/lib/Dist/Zilla/App.pm index 0ebe969f6..890118603 100644 --- a/lib/Dist/Zilla/App.pm +++ b/lib/Dist/Zilla/App.pm @@ -5,27 +5,25 @@ package Dist::Zilla::App; use App::Cmd::Setup 0.330 -app; # better compilation error detection +use Dist::Zilla::Dialect; + use Carp (); use Try::Tiny; $Carp::Internal{'Module::Runtime'} = 1; -sub global_opt_spec { - my ($self) = @_; - +sub global_opt_spec ($self) { return ( [ "verbose|v", "log additional output" ], [ "verbose-plugin|V=s@", "log additional output from some plugins only" ], [ "lib-inc|I=s@", "additional \@INC dirs", { - callbacks => { 'always fine' => sub { unshift @INC, @{$_[0]}; } } + callbacks => { 'always fine' => sub { unshift @INC, $_[0]->@* } } } ], $self->SUPER::global_opt_spec, ); } -sub _build_global_stashes { - my ($self) = @_; - +sub _build_global_stashes ($self) { return $self->{__global_stashes__} if $self->{__global_stashes__}; # tests shouldn't depend on the user's configuration @@ -98,8 +96,7 @@ been constructed, one will be by calling C<< Dist::Zilla->from_config >>. =cut -sub chrome { - my ($self) = @_; +sub chrome ($self) { require Dist::Zilla::Chrome::Term; return $self->{__chrome__} if $self->{__chrome__}; @@ -107,7 +104,7 @@ sub chrome { $self->{__chrome__} = Dist::Zilla::Chrome::Term->new; my @v_plugins = $self->global_options->verbose_plugin - ? grep { length } @{ $self->global_options->verbose_plugin } + ? grep { length } $self->global_options->verbose_plugin->@* : (); my $verbose = $self->global_options->verbose; @@ -117,14 +114,12 @@ sub chrome { return $self->{__chrome__}; } -sub zilla { - my ($self) = @_; - +sub zilla ($self) { require Dist::Zilla::Dist::Builder; return $self->{'' . __PACKAGE__}{zilla} ||= do { my @v_plugins = $self->global_options->verbose_plugin - ? grep { length } @{ $self->global_options->verbose_plugin } + ? grep { length } $self->global_options->verbose_plugin->@* : (); my $verbose = $self->global_options->verbose; @@ -149,7 +144,7 @@ sub zilla { VERBOSE_PLUGIN: for my $plugin_name (grep { ! m{\A[-_]\z} } @v_plugins) { my @plugins = grep { $_->plugin_name =~ /\b\Q$plugin_name\E\b/ } - @{ $zilla->plugins }; + $zilla->plugins; $zilla->log_fatal("can't find plugins matching $plugin_name to set debug") unless @plugins; diff --git a/lib/Dist/Zilla/App/Command.pm b/lib/Dist/Zilla/App/Command.pm index 7523ce0d8..a773ade35 100644 --- a/lib/Dist/Zilla/App/Command.pm +++ b/lib/Dist/Zilla/App/Command.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command; use App::Cmd::Setup -command; +use Dist::Zilla::Dialect; + =method zilla This returns the Dist::Zilla object in use by the command. If none has yet @@ -14,9 +16,7 @@ been constructed, one will be by calling C<< Dist::Zilla->from_config >>. =cut -sub zilla { - return $_[0]->app->zilla; -} +sub zilla ($self) { $self->app->zilla } =method log @@ -24,8 +24,8 @@ This method calls the C method of the application's chrome. =cut -sub log { - $_[0]->app->chrome->logger->log($_[1]); +sub log ($self, $what) { + $self->app->chrome->logger->log($what); } 1; diff --git a/lib/Dist/Zilla/App/Command/add.pm b/lib/Dist/Zilla/App/Command/add.pm index 3607385ec..7d79b59b9 100644 --- a/lib/Dist/Zilla/App/Command/add.pm +++ b/lib/Dist/Zilla/App/Command/add.pm @@ -4,6 +4,9 @@ package Dist::Zilla::App::Command::add; # ABSTRACT: add a module to a dist use Dist::Zilla::App -command; + +use Dist::Zilla::Dialect; + use Dist::Zilla::Path; =head1 SYNOPSIS @@ -31,9 +34,7 @@ sub opt_spec { # [ 'module|m=s@', 'module(s) to create; may be given many times' ], } -sub validate_args { - my ($self, $opt, $args) = @_; - +sub validate_args ($self, $opt, $args) { require MooseX::Types::Perl; $self->usage_error('dzil add takes one or more arguments') if @$args < 1; @@ -44,12 +45,10 @@ sub validate_args { } } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { my $zilla = $self->zilla; my $dist = $zilla->name; - + require File::pushd; require Dist::Zilla::Dist::Minter; @@ -71,7 +70,7 @@ sub execute { $factory->make_module({ name => $name }); } - for my $file ( @{ $factory->zilla->files} ) { + for my $file ($factory->zilla->files->@*) { $zilla->_write_out_file($file, $root); } } diff --git a/lib/Dist/Zilla/App/Command/authordeps.pm b/lib/Dist/Zilla/App/Command/authordeps.pm index e730b0682..0ee7a9a7d 100644 --- a/lib/Dist/Zilla/App/Command/authordeps.pm +++ b/lib/Dist/Zilla/App/Command/authordeps.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::authordeps; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS $ dzil authordeps @@ -28,9 +30,7 @@ sub opt_spec { ); } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { require Dist::Zilla::Path; require Dist::Zilla::Util::AuthorDeps; diff --git a/lib/Dist/Zilla/App/Command/build.pm b/lib/Dist/Zilla/App/Command/build.pm index 5feaa4c5d..78de5d778 100644 --- a/lib/Dist/Zilla/App/Command/build.pm +++ b/lib/Dist/Zilla/App/Command/build.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::build; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS dzil build [ --trial ] [ --tgz | --no-tgz ] [ --in /path/to/build/dir ] @@ -86,9 +88,7 @@ necessary, the directory will be created. An archive will not be created. =cut -sub execute { - my ($self, $opt, $args) = @_; - +sub execute ($self, $opt, $args) { if ($opt->in) { require Path::Tiny; die qq{using "--in ." would destroy your working directory!\n} diff --git a/lib/Dist/Zilla/App/Command/clean.pm b/lib/Dist/Zilla/App/Command/clean.pm index dc48278e6..6e36f87e9 100644 --- a/lib/Dist/Zilla/App/Command/clean.pm +++ b/lib/Dist/Zilla/App/Command/clean.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::clean; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS dzil clean [ --dry-run|-n ] @@ -30,9 +32,7 @@ Nothing is removed; instead, everything that would be removed will be listed. sub abstract { 'clean up after build, test, or install' } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { $self->zilla->clean($opt->dry_run); } diff --git a/lib/Dist/Zilla/App/Command/install.pm b/lib/Dist/Zilla/App/Command/install.pm index c746b05f5..640f95376 100644 --- a/lib/Dist/Zilla/App/Command/install.pm +++ b/lib/Dist/Zilla/App/Command/install.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::install; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS Installs your distribution using a specified command. @@ -43,9 +45,7 @@ Dist::Zilla. =cut -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { $self->zilla->install({ $opt->install_command ? (install_command => [ $opt->install_command ]) diff --git a/lib/Dist/Zilla/App/Command/listdeps.pm b/lib/Dist/Zilla/App/Command/listdeps.pm index 336f30d50..77005ae21 100644 --- a/lib/Dist/Zilla/App/Command/listdeps.pm +++ b/lib/Dist/Zilla/App/Command/listdeps.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::listdeps; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS $ dzil listdeps | cpan @@ -80,15 +82,13 @@ sub opt_spec { [ 'omit-core=s', 'Omit dependencies that are shipped with the specified version of perl' ], } -sub prereqs { - my ($self, $zilla) = @_; - - $_->before_build for @{ $zilla->plugins_with(-BeforeBuild) }; - $_->gather_files for @{ $zilla->plugins_with(-FileGatherer) }; - $_->set_file_encodings for @{ $zilla->plugins_with(-EncodingProvider) }; - $_->prune_files for @{ $zilla->plugins_with(-FilePruner) }; - $_->munge_files for @{ $zilla->plugins_with(-FileMunger) }; - $_->register_prereqs for @{ $zilla->plugins_with(-PrereqSource) }; +sub prereqs ($self, $zilla) { + $_->before_build for $zilla->plugins_with(-BeforeBuild); + $_->gather_files for $zilla->plugins_with(-FileGatherer); + $_->set_file_encodings for $zilla->plugins_with(-EncodingProvider); + $_->prune_files for $zilla->plugins_with(-FilePruner); + $_->munge_files for $zilla->plugins_with(-FileMunger); + $_->register_prereqs for $zilla->plugins_with(-PrereqSource); my $prereqs = $zilla->prereqs; } @@ -96,8 +96,7 @@ sub prereqs { my @phases = qw/configure build test runtime develop/; my @relationships = qw/requires recommends suggests/; -sub filter_core { - my ($prereqs, $core_version) = @_; +my sub filter_core ($prereqs, $core_version) { $core_version = sprintf '%7.6f', $core_version if $core_version >= 5.010; $prereqs = $prereqs->clone if $prereqs->is_finalized; require Module::CoreList; @@ -113,9 +112,7 @@ sub filter_core { return $prereqs; } -sub extract_dependencies { - my ($self, $zilla, $phases, $opt) = @_; - +sub extract_dependencies ($self, $zilla, $phases, $opt) { my $prereqs = $self->prereqs($zilla); $prereqs = filter_core($prereqs, $opt->omit_core) if $opt->omit_core; @@ -149,9 +146,7 @@ sub extract_dependencies { return map { $_ => $versions->{$_} } @required; } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { $self->app->chrome->logger->mute; my @phases = qw(build test configure runtime); diff --git a/lib/Dist/Zilla/App/Command/new.pm b/lib/Dist/Zilla/App/Command/new.pm index c841607fb..6e9850eee 100644 --- a/lib/Dist/Zilla/App/Command/new.pm +++ b/lib/Dist/Zilla/App/Command/new.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::new; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS Creates a new Dist-Zilla based distribution under the current directory. @@ -53,9 +55,7 @@ sub opt_spec { # [ 'module|m=s@', 'module(s) to create; may be given many times' ], } -sub validate_args { - my ($self, $opt, $args) = @_; - +sub validate_args ($self, $opt, $args) { require MooseX::Types::Perl; $self->usage_error('dzil new takes exactly one argument') if @$args != 1; @@ -71,9 +71,7 @@ sub validate_args { $args->[0] = $name; } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { my $dist = $arg->[0]; require Dist::Zilla::Dist::Minter; diff --git a/lib/Dist/Zilla/App/Command/nop.pm b/lib/Dist/Zilla/App/Command/nop.pm index 06d5c16b7..007baa246 100644 --- a/lib/Dist/Zilla/App/Command/nop.pm +++ b/lib/Dist/Zilla/App/Command/nop.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::nop; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS This command does nothing. It initializes Dist::Zilla, then exits. This is @@ -24,10 +26,6 @@ sub description { "It is sometimes useful for diagnostic purposes." } -sub execute { - my ($self, $opt, $arg) = @_; - - $self->zilla; -} +sub execute ($self, @) { $self->zilla } 1; diff --git a/lib/Dist/Zilla/App/Command/release.pm b/lib/Dist/Zilla/App/Command/release.pm index 07a480bdb..a4f412e61 100644 --- a/lib/Dist/Zilla/App/Command/release.pm +++ b/lib/Dist/Zilla/App/Command/release.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::release; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS dzil release @@ -24,9 +26,7 @@ sub opt_spec { [ 'trial' => 'build a trial release that PAUSE will not index' ], } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { my $zilla; { # isolate changes to RELEASE_STATUS to zilla construction diff --git a/lib/Dist/Zilla/App/Command/run.pm b/lib/Dist/Zilla/App/Command/run.pm index e5044b9e6..0ba083bbc 100644 --- a/lib/Dist/Zilla/App/Command/run.pm +++ b/lib/Dist/Zilla/App/Command/run.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::run; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS $ dzil run ./bin/myscript @@ -54,9 +56,7 @@ sub usage_desc { return '%c run %o [ command [ arg1 arg2 ... ] ]'; } -sub execute { - my ($self, $opt, $args) = @_; - +sub execute ($self, $opt, $args) { unless (@$args) { my $envname = $^O eq 'MSWin32' ? 'COMSPEC' : 'SHELL'; unless ($ENV{$envname}) { diff --git a/lib/Dist/Zilla/App/Command/setup.pm b/lib/Dist/Zilla/App/Command/setup.pm index 2e0277ccb..d5e1c86dc 100644 --- a/lib/Dist/Zilla/App/Command/setup.pm +++ b/lib/Dist/Zilla/App/Command/setup.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::setup; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS $ dzil setup @@ -28,15 +30,11 @@ sub description { "a basic Dist::Zilla configuration in ~/.dzil/config.ini" } -sub validate_args { - my ($self, $opt, $args) = @_; - +sub validate_args ($self, $opt, $args) { $self->usage_error('too many arguments') if @$args != 0; } -sub execute { - my ($self, $opt, $arg) = @_; - +sub execute ($self, $opt, $arg) { my $chrome = $self->app->chrome; require Dist::Zilla::Util; diff --git a/lib/Dist/Zilla/App/Command/smoke.pm b/lib/Dist/Zilla/App/Command/smoke.pm index 2695e2396..bb6390e56 100644 --- a/lib/Dist/Zilla/App/Command/smoke.pm +++ b/lib/Dist/Zilla/App/Command/smoke.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::smoke; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS dzil smoke [ --release ] [ --author ] [ --no-automated ] @@ -54,11 +56,9 @@ This will run the test suite with AUTHOR_TESTING=1 sub abstract { 'smoke your dist' } -sub execute { - my ($self, $opt, $arg) = @_; - - local $ENV{RELEASE_TESTING} = 1 if $opt->release; - local $ENV{AUTHOR_TESTING} = 1 if $opt->author; +sub execute ($self, $opt, $arg) { + local $ENV{RELEASE_TESTING} = 1 if $opt->release; + local $ENV{AUTHOR_TESTING} = 1 if $opt->author; local $ENV{AUTOMATED_TESTING} = 1 if $opt->automated; $self->zilla->test; diff --git a/lib/Dist/Zilla/App/Command/test.pm b/lib/Dist/Zilla/App/Command/test.pm index eb1e44c08..212ca1ba8 100644 --- a/lib/Dist/Zilla/App/Command/test.pm +++ b/lib/Dist/Zilla/App/Command/test.pm @@ -5,6 +5,8 @@ package Dist::Zilla::App::Command::test; use Dist::Zilla::App -command; +use Dist::Zilla::Dialect; + =head1 SYNOPSIS dzil test [ --release ] [ --no-author ] [ --automated ] [ --extended ] [ --all ] @@ -65,13 +67,11 @@ Equivalent to --release --automated --extended --author sub abstract { 'test your dist' } -sub execute { - my ($self, $opt, $arg) = @_; - - local $ENV{RELEASE_TESTING} = 1 if $opt->release or $opt->all; - local $ENV{AUTHOR_TESTING} = 1 if $opt->author or $opt->all; - local $ENV{AUTOMATED_TESTING} = 1 if $opt->automated or $opt->all; - local $ENV{EXTENDED_TESTING} = 1 if $opt->extended or $opt->all; +sub execute ($self, $opt, $arg) { + local $ENV{RELEASE_TESTING} = 1 if $opt->all or $opt->release; + local $ENV{AUTHOR_TESTING} = 1 if $opt->all or $opt->author; + local $ENV{AUTOMATED_TESTING} = 1 if $opt->all or $opt->automated; + local $ENV{EXTENDED_TESTING} = 1 if $opt->all or $opt->extended; $self->zilla->test({ $opt->keep_build_dir @@ -80,9 +80,9 @@ sub execute { $opt->jobs ? (jobs => $opt->jobs) : (), - $opt->test_verbose - ? (test_verbose => $opt->test_verbose) - : (), + $opt->test_verbose + ? (test_verbose => $opt->test_verbose) + : (), }); } diff --git a/lib/Dist/Zilla/App/Command/version.pm b/lib/Dist/Zilla/App/Command/version.pm index 7e8d75918..1139ddccb 100644 --- a/lib/Dist/Zilla/App/Command/version.pm +++ b/lib/Dist/Zilla/App/Command/version.pm @@ -11,6 +11,8 @@ BEGIN { unshift @ISA, 'App::Cmd::Command::version'; } +use Dist::Zilla::Dialect; + =head1 SYNOPSIS Print dzil version @@ -19,11 +21,9 @@ Print dzil version =cut -sub version_for_display { - my $version_pkg = $_[0]->version_package; - my $version = ( $version_pkg->VERSION ? - $version_pkg->VERSION : - 'dev' ); +sub version_for_display ($self) { + my $version_pkg = $self->version_package; + my $version = $version_pkg->VERSION // 'dev'; } 1; diff --git a/lib/Dist/Zilla/App/Tester.pm b/lib/Dist/Zilla/App/Tester.pm index b1138ff81..eaab38b6f 100644 --- a/lib/Dist/Zilla/App/Tester.pm +++ b/lib/Dist/Zilla/App/Tester.pm @@ -6,6 +6,8 @@ package Dist::Zilla::App::Tester; use parent 'App::Cmd::Tester::CaptureExternal'; use App::Cmd::Tester 0.306 (); # result_class, ->app +use Dist::Zilla::Dialect; + use Dist::Zilla::App; use File::Copy::Recursive qw(dircopy); use File::pushd (); @@ -21,10 +23,7 @@ use Sub::Exporter -setup => { sub result_class { 'Dist::Zilla::App::Tester::Result' } -sub test_dzil { - my ($self, $source, $argv, $arg) = @_; - $arg ||= {}; - +sub test_dzil ($self, $source, $argv, $arg = {}) { local @INC = map {; ref($_) ? $_ : File::Spec->rel2abs($_) } @INC; my $tmpdir = $arg->{tempdir} || File::Temp::tempdir(CLEANUP => 1); @@ -47,34 +46,28 @@ sub test_dzil { BEGIN { our @ISA = qw(App::Cmd::Tester::Result); } - sub tempdir { - my ($self) = @_; + sub tempdir ($self) { return $self->{tempdir}; } - sub zilla { - my ($self) = @_; + sub zilla ($self) { return $self->app->zilla; } - sub build_dir { - my ($self) = @_; + sub build_dir ($self) { return $self->zilla->built_in; } - sub clear_log_events { - my ($self) = @_; + sub clear_log_events ($self) { $self->app->zilla->logger->logger->clear_events; } - sub log_events { - my ($self) = @_; + sub log_events ($self) { $self->app->zilla->logger->logger->events; } - sub log_messages { - my ($self) = @_; - [ map {; $_->{message} } @{ $self->app->zilla->logger->logger->events } ]; + sub log_messages ($self) { + [ map {; $_->{message} } $self->app->zilla->logger->logger->events->@* ]; } } @@ -86,15 +79,15 @@ This module exports only one function, C. This function is used to test L. It receives two mandatory options. The first is the path to a Dist::Zilla-based -distribution. The second, an array reference to a list of arguments. +distribution. The second, an array reference to a list of arguments. The third optional argument is a hash reference, with further options. At the moment the only supported option is c. -It returns a L, that inherits from +It returns a L, that inherits from L. Typical methods called from this result are: -=over 4 +=over 4 =item C diff --git a/lib/Dist/Zilla/Chrome/Term.pm b/lib/Dist/Zilla/Chrome/Term.pm index b18200ae9..59b6f186e 100644 --- a/lib/Dist/Zilla/Chrome/Term.pm +++ b/lib/Dist/Zilla/Chrome/Term.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Chrome::Term; use Moose; +use Dist::Zilla::Dialect; + =head1 OVERVIEW This class provides a L implementation for use in a @@ -25,8 +27,7 @@ has logger => ( builder => '_build_logger', ); -sub _build_logger { - my $self = shift; +sub _build_logger ($self, @) { my $enc = $self->term_enc; if ($enc && Encode::resolve_alias($enc)) { @@ -64,9 +65,7 @@ has term_enc => ( }, ); -sub prompt_str { - my ($self, $prompt, $arg) = @_; - $arg ||= {}; +sub prompt_str ($self, $prompt, $arg = {}) { my $default = $arg->{default}; my $check = $arg->{check}; @@ -105,9 +104,7 @@ sub prompt_str { return $input; } -sub prompt_yn { - my ($self, $prompt, $arg) = @_; - $arg ||= {}; +sub prompt_yn ($self, $prompt, $arg = {}) { my $default = $arg->{default}; if (! $self->_isa_tty) { @@ -133,8 +130,7 @@ sub _isa_tty { return $isa_tty; } -sub prompt_any_key { - my ($self, $prompt) = @_; +sub prompt_any_key ($self, $prompt) { $prompt ||= 'press any key to continue'; my $isa_tty = $self->_isa_tty; diff --git a/lib/Dist/Zilla/Chrome/Test.pm b/lib/Dist/Zilla/Chrome/Test.pm index c47011f84..d20db9f72 100644 --- a/lib/Dist/Zilla/Chrome/Test.pm +++ b/lib/Dist/Zilla/Chrome/Test.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Chrome::Test; use Moose; +use Dist::Zilla::Dialect; + use MooseX::Types::Moose qw(ArrayRef HashRef Str); use Dist::Zilla::Types qw(OneZero); use Log::Dispatchouli 1.102220; @@ -47,10 +49,7 @@ has response_for => ( }, ); -sub prompt_str { - my ($self, $prompt, $arg) = @_; - $arg ||= {}; - +sub prompt_str ($self, $prompt, $arg = {}) { my $response = $self->response_for($prompt); $response = shift @$response if ref $response; @@ -63,10 +62,8 @@ sub prompt_str { return $response; } -sub prompt_yn { - my $self = shift; - - return OneZero->coerce( $self->prompt_str(@_) ); +sub prompt_yn ($self, @rest) { + return OneZero->coerce( $self->prompt_str(@rest) ); } sub prompt_any_key { return } diff --git a/lib/Dist/Zilla/Dialect.pm b/lib/Dist/Zilla/Dialect.pm new file mode 100644 index 000000000..61d7e42fa --- /dev/null +++ b/lib/Dist/Zilla/Dialect.pm @@ -0,0 +1,12 @@ +package Dist::Zilla::Dialect; + +use v5.20.0; +use warnings; +use experimental (); + +sub import { + feature->import(':5.20'); + experimental->import(qw(lexical_subs postderef signatures)); +} + +1; diff --git a/lib/Dist/Zilla/Dist/Builder.pm b/lib/Dist/Zilla/Dist/Builder.pm index d8340c99b..fc19766db 100644 --- a/lib/Dist/Zilla/Dist/Builder.pm +++ b/lib/Dist/Zilla/Dist/Builder.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Dist::Builder; use Moose 0.92; # role composition fixes extends 'Dist::Zilla'; +use Dist::Zilla::Dialect; + use MooseX::Types::Moose qw(HashRef); use Dist::Zilla::Types qw(Path); @@ -32,10 +34,7 @@ Valid arguments are: =cut -sub from_config { - my ($class, $arg) = @_; - $arg ||= {}; - +sub from_config ($class, $arg = {}) { my $root = path($arg->{dist_root} || '.'); my $sequence = $class->_load_config({ @@ -52,23 +51,21 @@ sub from_config { return $self; } -sub _setup_default_plugins { - my ($self) = @_; +sub _setup_default_plugins ($self) { unless ($self->plugin_named(':InstallModules')) { require Dist::Zilla::Plugin::FinderCode; my $plugin = Dist::Zilla::Plugin::FinderCode->new({ plugin_name => ':InstallModules', zilla => $self, style => 'grep', - code => sub { - my ($file, $self) = @_; + code => sub ($file, $) { local $_ = $file->name; return 1 if m{\Alib/} and m{\.(pm|pod)$}; return; }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':IncModules')) { @@ -77,15 +74,14 @@ sub _setup_default_plugins { plugin_name => ':IncModules', zilla => $self, style => 'grep', - code => sub { - my ($file, $self) = @_; + code => sub ($file, $) { local $_ = $file->name; return 1 if m{\Ainc/} and m{\.pm$}; return; }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':TestFiles')) { @@ -94,10 +90,10 @@ sub _setup_default_plugins { plugin_name => ':TestFiles', zilla => $self, style => 'grep', - code => sub { local $_ = $_->name; m{\At/} }, + code => sub { $_->name =~ m{\At/} }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':ExtraTestFiles')) { @@ -109,7 +105,7 @@ sub _setup_default_plugins { code => sub { local $_ = $_->name; m{\Axt/} }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':ExecFiles')) { @@ -118,15 +114,15 @@ sub _setup_default_plugins { plugin_name => ':ExecFiles', zilla => $self, style => 'list', - code => sub { - my $plugins = $_[0]->zilla->plugins_with(-ExecFiles); - my @files = uniq map {; @{ $_->find_files } } @$plugins; + code => sub ($file, @) { + my @files = uniq map {; $_->find_files->@* } + $file->zilla->plugins_with(-ExecFiles); return \@files; }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':PerlExecFiles')) { @@ -140,12 +136,12 @@ sub _setup_default_plugins { my @files = grep { $_->name =~ m{\.pl$} or $_->content =~ m{^\s*\#\!.*perl\b}; - } @{ $parent_plugin->find_files }; + } $parent_plugin->find_files->@*; return \@files; }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':ShareFiles')) { @@ -154,25 +150,25 @@ sub _setup_default_plugins { plugin_name => ':ShareFiles', zilla => $self, style => 'list', - code => sub { - my $self = shift; - my $map = $self->zilla->_share_dir_map; + code => sub ($file, @) { + my $zilla = $file->zilla; + my $map = $zilla->_share_dir_map; my @files; if ( $map->{dist} ) { push @files, grep {; $_->name =~ m{\A\Q$map->{dist}\E/} } - @{ $self->zilla->files }; + $zilla->files->@*; } if ( my $mod_map = $map->{module} ) { for my $mod ( keys %$mod_map ) { push @files, grep { $_->name =~ m{\A\Q$mod_map->{$mod}\E/} } - @{ $self->zilla->files }; + $zilla->files->@*; } } return \@files; }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':MainModule')) { @@ -181,15 +177,14 @@ sub _setup_default_plugins { plugin_name => ':MainModule', zilla => $self, style => 'grep', - code => sub { - my ($file, $self) = @_; + code => sub ($file, $self) { local $_ = $file->name; return 1 if $_ eq $self->zilla->main_module->name; return; }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':AllFiles')) { @@ -201,7 +196,7 @@ sub _setup_default_plugins { code => sub { return 1 }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } unless ($self->plugin_named(':NoFiles')) { @@ -213,7 +208,7 @@ sub _setup_default_plugins { code => sub { [] }, }); - push @{ $self->plugins }, $plugin; + $self->_add_plugin($plugin); } } @@ -225,12 +220,10 @@ has _share_dir_map => ( builder => '_build_share_dir_map', ); -sub _build_share_dir_map { - my ($self) = @_; - +sub _build_share_dir_map ($self) { my $share_dir_map = {}; - for my $plugin (@{ $self->plugins_with(-ShareDir) }) { + for my $plugin ($self->plugins_with(-ShareDir)) { next unless my $sub_map = $plugin->share_dir_map; if ( $sub_map->{dist} ) { @@ -252,10 +245,7 @@ sub _build_share_dir_map { } -sub _load_config { - my ($class, $arg) = @_; - $arg ||= {}; - +sub _load_config ($class, $arg = {}) { my $config_class = $arg->{config_class} ||= 'Dist::Zilla::MVP::Reader::Finder'; @@ -333,35 +323,33 @@ for the preposition! sub build { $_[0]->build_in } -sub build_in { - my ($self, $root) = @_; - +sub build_in ($self, $root = undef) { $self->log_fatal("tried to build with a minter") if $self->isa('Dist::Zilla::Dist::Minter'); $self->log_fatal("attempted to build " . $self->name . " a second time") if $self->built_in; - $_->before_build for @{ $self->plugins_with(-BeforeBuild) }; + $_->before_build for $self->plugins_with(-BeforeBuild); $self->log("beginning to build " . $self->name); - $_->gather_files for @{ $self->plugins_with(-FileGatherer) }; - $_->set_file_encodings for @{ $self->plugins_with(-EncodingProvider) }; - $_->prune_files for @{ $self->plugins_with(-FilePruner) }; + $_->gather_files for $self->plugins_with(-FileGatherer); + $_->set_file_encodings for $self->plugins_with(-EncodingProvider); + $_->prune_files for $self->plugins_with(-FilePruner); $self->version; # instantiate this lazy attribute now that files are gathered - $_->munge_files for @{ $self->plugins_with(-FileMunger) }; + $_->munge_files for $self->plugins_with(-FileMunger); - $_->register_prereqs for @{ $self->plugins_with(-PrereqSource) }; + $_->register_prereqs for $self->plugins_with(-PrereqSource); $self->prereqs->finalize; # Barf if someone has already set up a prereqs entry? -- rjbs, 2010-04-13 $self->distmeta->{prereqs} = $self->prereqs->as_string_hash; - $_->setup_installer for @{ $self->plugins_with(-InstallTool) }; + $_->setup_installer for $self->plugins_with(-InstallTool); $self->_check_dupe_files; @@ -369,12 +357,14 @@ sub build_in { $self->log("writing " . $self->name . " in $build_root"); - for my $file (@{ $self->files }) { + for my $file ($self->files->@*) { $self->_write_out_file($file, $build_root); } $_->after_build({ build_root => $build_root }) - for @{ $self->plugins_with(-AfterBuild) }; + for $self->plugins_with(-AfterBuild); + + $self->_create_build_symlinks(path('.build'), $build_root); $self->built_in($build_root); } @@ -411,9 +401,7 @@ sub ensure_built { $_[0]->ensure_built_in; } -sub ensure_built_in { - my ($self, $root) = @_; - +sub ensure_built_in ($self, $root = undef) { # $root ||= $self->name . q{-} . $self->version; return $self->built_in if $self->built_in and (!$root or ($self->built_in eq $root)); @@ -432,8 +420,7 @@ does not include C<-TRIAL>, even if building a trial dist. =cut -sub dist_basename { - my ($self) = @_; +sub dist_basename ($self) { return join(q{}, $self->name, '-', @@ -452,8 +439,7 @@ might not exist. =cut -sub archive_filename { - my ($self) = @_; +sub archive_filename ($self) { return join(q{}, $self->dist_basename, ( $self->is_trial && $self->version !~ /_/ ? '-TRIAL' : '' ), @@ -470,15 +456,13 @@ tarball of the build directory in the current directory. =cut -sub build_archive { - my ($self) = @_; - +sub build_archive ($self) { my $built_in = $self->ensure_built; my $basename = $self->dist_basename; my $basedir = path($basename); - $_->before_archive for @{ $self->plugins_with(-BeforeArchive) }; + $_->before_archive for $self->plugins_with(-BeforeArchive); my $method = eval { +require Archive::Tar::Wrapper; Archive::Tar::Wrapper->VERSION('0.15'); 1 } @@ -487,7 +471,7 @@ sub build_archive { my $archive = $self->$method($built_in, $basename, $basedir); - my $file = path($self->archive_filename); + my $file = path($self->root, $self->archive_filename); $self->log("writing archive to $file"); $archive->write("$file", 9); @@ -495,16 +479,14 @@ sub build_archive { return $file; } -sub _build_archive { - my ($self, $built_in, $basename, $basedir) = @_; - +sub _build_archive ($self, $built_in, $basename, $basedir) { $self->log("building archive with Archive::Tar; install Archive::Tar::Wrapper 0.15 or newer for improved speed"); require Archive::Tar; my $archive = Archive::Tar->new; my %seen_dir; for my $distfile ( - sort { length($a->name) <=> length($b->name) } @{ $self->files } + sort { length($a->name) <=> length($b->name) } $self->files->@* ) { my $in = path($distfile->name)->parent; @@ -527,15 +509,13 @@ sub _build_archive { return $archive; } -sub _build_archive_with_wrapper { - my ($self, $built_in, $basename, $basedir) = @_; - +sub _build_archive_with_wrapper ($self, $built_in, $basename, $basedir) { $self->log("building archive with Archive::Tar::Wrapper"); my $archive = Archive::Tar::Wrapper->new; for my $distfile ( - sort { length($a->name) <=> length($b->name) } @{ $self->files } + sort { length($a->name) <=> length($b->name) } $self->files->@* ) { my $in = path($distfile->name)->parent; @@ -550,9 +530,7 @@ sub _build_archive_with_wrapper { return $archive; } -sub _prep_build_root { - my ($self, $build_root) = @_; - +sub _prep_build_root ($self, $build_root = undef) { $build_root = path($build_root || $self->dist_basename); $build_root->mkpath unless -d $build_root; @@ -588,24 +566,22 @@ by the loaded plugins. =cut -sub release { - my $self = shift; - +sub release ($self) { Carp::croak("you can't release without any Releaser plugins") - unless my @releasers = @{ $self->plugins_with(-Releaser) }; + unless my @releasers = $self->plugins_with(-Releaser); $ENV{DZIL_RELEASING} = 1; my $tgz = $self->build_archive; # call all plugins implementing BeforeRelease role - $_->before_release($tgz) for @{ $self->plugins_with(-BeforeRelease) }; + $_->before_release($tgz) for $self->plugins_with(-BeforeRelease); # do the actual release - $_->release($tgz) for @releasers; + $_->release($tgz) for @releasers; # call all plugins implementing AfterRelease role - $_->after_release($tgz) for @{ $self->plugins_with(-AfterRelease) }; + $_->after_release($tgz) for $self->plugins_with(-AfterRelease); } =method clean @@ -617,9 +593,7 @@ like matching the glob C. =cut -sub clean { - my ($self, $dry_run) = @_; - +sub clean ($self, $dry_run) { require File::Path; for my $x (grep { -e } '.build', glob($self->name . '-*')) { if ($dry_run) { @@ -640,9 +614,7 @@ subdirectory. It will return the path for the temporary build location. =cut -sub ensure_built_in_tmpdir { - my $self = shift; - +sub ensure_built_in_tmpdir ($self) { require File::Temp; my $build_root = path('.build'); @@ -651,28 +623,38 @@ sub ensure_built_in_tmpdir { my $target = path( File::Temp::tempdir(DIR => $build_root) ); $self->log("building distribution under $target for installation"); + my ($latest, $previous) = $self->_create_build_symlinks($build_root, $target); + + $self->build_in($target); + + return ($target, $latest, $previous); +} + +sub _create_build_symlinks ($self, $symlink_root, $build_target) { + $symlink_root->mkpath unless -d $symlink_root; + my $os_has_symlinks = eval { symlink("",""); 1 }; my $previous; my $latest; if( $os_has_symlinks ) { - $previous = path( $build_root, 'previous' ); - $latest = path( $build_root, 'latest' ); + $previous = path( $symlink_root, 'previous' ); + $latest = path( $symlink_root, 'latest' ); if( -l $previous ) { $previous->remove - or $self->log("cannot remove old .build/previous link"); + or $self->log([ 'cannot remove old %s/previous link', "$symlink_root" ]); } if( -l $latest ) { rename $latest, $previous - or $self->log("cannot move .build/latest link to .build/previous"); + or $self->log([ 'cannot move %s/latest link to .build/previous', "$symlink_root" ]); } - symlink $target->basename, $latest - or $self->log('cannot create link .build/latest'); - } - $self->ensure_built_in($target); + my $link_dest = path($build_target)->relative(path($latest)->parent); + symlink $link_dest->stringify, $latest + or $self->log([ 'cannot create link %s/latest', "$symlink_root" ]); + } - return ($target, $latest, $previous); + return ($latest, $previous); } =method install @@ -694,17 +676,14 @@ Valid arguments are: =cut -sub install { - my ($self, $arg) = @_; - $arg ||= {}; - +sub install ($self, $arg = {}) { my ($target, $latest) = $self->ensure_built_in_tmpdir; my $ok = eval { ## no critic Punctuation my $wd = File::pushd::pushd($target); my @cmd = $arg->{install_command} - ? @{ $arg->{install_command} } + ? $arg->{install_command}->@* : (cpanm => "."); $self->log_debug([ 'installing via %s', \@cmd ]); @@ -743,11 +722,9 @@ C<\%arg> may be omitted. Otherwise, valid arguments are: =cut -sub test { - my ($self, $arg) = @_; - +sub test ($self, $arg = {}) { Carp::croak("you can't test without any TestRunner plugins") - unless my @testers = @{ $self->plugins_with(-TestRunner) }; + unless my @testers = $self->plugins_with(-TestRunner); my ($target, $latest) = $self->ensure_built_in_tmpdir; my $error = $self->run_tests_in($target, $arg); @@ -775,11 +752,9 @@ does it clean up C<$directory> afterwards. =cut -sub run_tests_in { - my ($self, $target, $arg) = @_; - +sub run_tests_in ($self, $target, $arg = {}) { Carp::croak("you can't test without any TestRunner plugins") - unless my @testers = @{ $self->plugins_with(-TestRunner) }; + unless my @testers = $self->plugins_with(-TestRunner); for my $tester (@testers) { my $wd = File::pushd::pushd($target); @@ -799,12 +774,11 @@ non-zero, the directory will be left in place. =cut -sub run_in_build { - my ($self, $cmd, $arg) = @_; +sub run_in_build ($self, $cmd, $arg) { + my @runners = $self->plugins_with(-BuildRunner); $self->log_fatal("you can't build without any BuildRunner plugins") - unless ($arg and exists $arg->{build} and ! $arg->{build}) - or @{ $self->plugins_with(-BuildRunner) }; + unless ($arg and exists $arg->{build} and ! $arg->{build}) or @runners; require "Config.pm"; # skip autoprereq @@ -849,11 +823,9 @@ sub run_in_build { # C<-BuildRunner> plugins to generate it. Useful for commands that operate on # F, such as C or C. -sub _ensure_blib { - my ($self) = @_; - +sub _ensure_blib ($self) { unless ( -d 'blib' ) { - my @builders = @{ $self->plugins_with( -BuildRunner ) }; + my @builders = $self->plugins_with( -BuildRunner ); $self->log_fatal("no BuildRunner plugins specified") unless @builders; $_->build for @builders; $self->log_fatal("no blib; failed to build properly?") unless -d 'blib'; diff --git a/lib/Dist/Zilla/Dist/Minter.pm b/lib/Dist/Zilla/Dist/Minter.pm index 346f93ad3..3ffc44384 100644 --- a/lib/Dist/Zilla/Dist/Minter.pm +++ b/lib/Dist/Zilla/Dist/Minter.pm @@ -4,15 +4,15 @@ package Dist::Zilla::Dist::Minter; use Moose 0.92; # role composition fixes extends 'Dist::Zilla'; +use Dist::Zilla::Dialect; + use File::pushd (); use Dist::Zilla::Path; use Module::Runtime 'require_module'; use namespace::autoclean; -sub _setup_default_plugins { - my ($self) = @_; - +sub _setup_default_plugins ($self) { unless ($self->plugin_named(':DefaultModuleMaker')) { require Dist::Zilla::Plugin::TemplateModule; my $plugin = Dist::Zilla::Plugin::TemplateModule->new({ @@ -20,14 +20,11 @@ sub _setup_default_plugins { zilla => $self, }); - push @{ $self->plugins }, $plugin; + push $self->_plugins->@*, $plugin; } } -sub _new_from_profile { - my ($class, $profile_data, $arg) = @_; - $arg ||= {}; - +sub _new_from_profile ($class, $profile_data, $arg = {}) { my $config_class = $arg->{config_class} ||= 'Dist::Zilla::MVP::Reader::Finder'; require_module($config_class); @@ -81,9 +78,7 @@ sub _new_from_profile { return $self; } -sub _mint_target_dir { - my ($self) = @_; - +sub _mint_target_dir ($self) { my $name = $self->name; my $dir = path($name); $self->log_fatal("./$name already exists") if -e $dir; @@ -91,9 +86,7 @@ sub _mint_target_dir { return $dir = $dir->absolute; } -sub mint_dist { - my ($self, $arg) = @_; - +sub mint_dist ($self, $arg = {}) { my $name = $self->name; my $dir = $self->_mint_target_dir; @@ -108,7 +101,7 @@ sub mint_dist { my $wd = File::pushd::pushd($self->root); - $_->before_mint for @{ $self->plugins_with(-BeforeMint) }; + $_->before_mint for $self->plugins_with(-BeforeMint); for my $module (@modules) { my $minter = $self->plugin_named( @@ -118,21 +111,20 @@ sub mint_dist { $minter->make_module({ name => $module->{name} }) } - $_->gather_files for @{ $self->plugins_with(-FileGatherer) }; - $_->set_file_encodings for @{ $self->plugins_with(-EncodingProvider) }; - $_->prune_files for @{ $self->plugins_with(-FilePruner) }; - $_->munge_files for @{ $self->plugins_with(-FileMunger) }; + $_->gather_files for $self->plugins_with(-FileGatherer); + $_->set_file_encodings for $self->plugins_with(-EncodingProvider); + $_->prune_files for $self->plugins_with(-FilePruner); + $_->munge_files for $self->plugins_with(-FileMunger); $self->_check_dupe_files; $self->log("writing files to $dir"); - for my $file (@{ $self->files }) { + for my $file ($self->files->@*) { $self->_write_out_file($file, $dir); } - $_->after_mint({ mint_root => $dir }) - for @{ $self->plugins_with(-AfterMint) }; + $_->after_mint({ mint_root => $dir }) for $self->plugins_with(-AfterMint); $self->log("dist minted in ./$name"); } diff --git a/lib/Dist/Zilla/File/FromCode.pm b/lib/Dist/Zilla/File/FromCode.pm index 4ba83f069..5653da91c 100644 --- a/lib/Dist/Zilla/File/FromCode.pm +++ b/lib/Dist/Zilla/File/FromCode.pm @@ -4,6 +4,8 @@ package Dist::Zilla::File::FromCode; use Moose; use Moose::Util::TypeConstraints; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -51,8 +53,7 @@ has encoding => ( builder => "_build_encoding", ); -sub _build_encoding { - my ($self) = @_; +sub _build_encoding ($self) { return $self->code_return_type eq 'text' ? 'UTF-8' : 'bytes'; } @@ -60,10 +61,8 @@ sub _build_encoding { =cut -sub content { - my ($self) = @_; - - confess("cannot set content of a FromCode file") if @_ > 1; +sub content ($self, @rest) { + confess("cannot set content of a FromCode file") if @rest; my $code = $self->code; my $result = $self->$code; @@ -80,10 +79,8 @@ sub content { =cut -sub encoded_content { - my ($self) = @_; - - confess( "cannot set encoded_content of a FromCode file" ) if @_ > 1; +sub encoded_content ($self, @rest) { + confess( "cannot set encoded_content of a FromCode file" ) if @rest; my $code = $self->code; my $result = $self->$code; @@ -96,8 +93,7 @@ sub encoded_content { } } -sub _set_added_by { - my ($self, $value) = @_; +sub _set_added_by ($self, $value) { return $self->_push_added_by(sprintf("%s from coderef added by %s", $self->code_return_type, $value)); }; diff --git a/lib/Dist/Zilla/File/InMemory.pm b/lib/Dist/Zilla/File/InMemory.pm index 6d98f4d18..ed500e618 100644 --- a/lib/Dist/Zilla/File/InMemory.pm +++ b/lib/Dist/Zilla/File/InMemory.pm @@ -1,6 +1,8 @@ package Dist::Zilla::File::InMemory; # ABSTRACT: a file that you build entirely in memory +use Dist::Zilla::Dialect; + use Moose; use namespace::autoclean; diff --git a/lib/Dist/Zilla/File/OnDisk.pm b/lib/Dist/Zilla/File/OnDisk.pm index ecd6fc0da..4b865e7d5 100644 --- a/lib/Dist/Zilla/File/OnDisk.pm +++ b/lib/Dist/Zilla/File/OnDisk.pm @@ -3,6 +3,8 @@ package Dist::Zilla::File::OnDisk; use Moose; +use Dist::Zilla::Dialect; + use Dist::Zilla::Path; use namespace::autoclean; @@ -24,13 +26,11 @@ has _original_name => ( init_arg => undef, ); -after 'BUILD' => sub { - my ($self) = @_; +after 'BUILD' => sub ($self, @) { $self->_set_original_name( $self->name ); }; -sub _build_encoded_content { - my ($self) = @_; +sub _build_encoded_content ($self) { return path($self->_original_name)->slurp_raw; } diff --git a/lib/Dist/Zilla/MVP/Assembler.pm b/lib/Dist/Zilla/MVP/Assembler.pm index b6f6594e1..d9b524efb 100644 --- a/lib/Dist/Zilla/MVP/Assembler.pm +++ b/lib/Dist/Zilla/MVP/Assembler.pm @@ -5,6 +5,8 @@ use Moose; extends 'Config::MVP::Assembler'; with 'Config::MVP::Assembler::WithBundles' => { -version => '2.200010' }; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::Util; @@ -42,25 +44,22 @@ has logger => ( isa => 'Log::Dispatchouli::Proxy', # could be duck typed, I guess lazy => 1, handles => [ qw(log log_debug log_fatal) ], - default => sub { - $_[0]->chrome->logger->proxy({ proxy_prefix => '[DZ] ' }) + default => sub ($self, @) { + $self->chrome->logger->proxy({ proxy_prefix => '[DZ] ' }) }, ); -sub expand_package { +sub expand_package ($self, $pkg) { return scalar Dist::Zilla::Util->expand_config_package_name($_[1]); } -sub package_bundle_method { - my ($self, $pkg) = @_; +sub package_bundle_method ($self, $pkg) { return unless $pkg->isa('Moose::Object') and $pkg->does('Dist::Zilla::Role::PluginBundle'); return 'bundle_config'; } -before add_value => sub { - my ($self, $name) = @_; - +before add_value => sub ($self, $name, $) { return unless $name =~ /\A(?:plugin_name|zilla)\z/; my $section_name = $self->current_section->name; diff --git a/lib/Dist/Zilla/MVP/Assembler/GlobalConfig.pm b/lib/Dist/Zilla/MVP/Assembler/GlobalConfig.pm index f0b88740d..6e41370a9 100644 --- a/lib/Dist/Zilla/MVP/Assembler/GlobalConfig.pm +++ b/lib/Dist/Zilla/MVP/Assembler/GlobalConfig.pm @@ -4,6 +4,8 @@ package Dist::Zilla::MVP::Assembler::GlobalConfig; use Moose; extends 'Dist::Zilla::MVP::Assembler'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 OVERVIEW @@ -33,9 +35,7 @@ already taken, in which case an exception is raised. =cut -sub register_stash { - my ($self, $name, $object) = @_; - +sub register_stash ($self, $name, $object) { # $self->log_fatal("tried to register $name stash entry twice") confess("tried to register $name stash entry twice") if $self->stash_registry->{ $name }; diff --git a/lib/Dist/Zilla/MVP/Assembler/Zilla.pm b/lib/Dist/Zilla/MVP/Assembler/Zilla.pm index 11bf12b9b..5ac471e4b 100644 --- a/lib/Dist/Zilla/MVP/Assembler/Zilla.pm +++ b/lib/Dist/Zilla/MVP/Assembler/Zilla.pm @@ -4,6 +4,8 @@ package Dist::Zilla::MVP::Assembler::Zilla; use Moose; extends 'Dist::Zilla::MVP::Assembler'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 OVERVIEW @@ -23,9 +25,7 @@ as the initial section. use MooseX::Types::Perl qw(PackageName); use Dist::Zilla::MVP::RootSection; -sub BUILD { - my ($self) = @_; - +sub BUILD ($self, @) { my $root = Dist::Zilla::MVP::RootSection->new; $self->sequence->add_section($root); } @@ -44,8 +44,7 @@ exception. =cut -sub zilla { - my ($self) = @_; +sub zilla ($self) { $self->sequence->section_named('_')->zilla; } @@ -58,8 +57,7 @@ is already taken, in which case an exception is raised. =cut -sub register_stash { - my ($self, $name, $object) = @_; +sub register_stash ($self, $name, $object) { $self->log_fatal("tried to register $name stash entry twice") if $self->zilla->_local_stashes->{ $name }; diff --git a/lib/Dist/Zilla/MVP/Reader/Finder.pm b/lib/Dist/Zilla/MVP/Reader/Finder.pm index 348c6c92d..c20c34cad 100644 --- a/lib/Dist/Zilla/MVP/Reader/Finder.pm +++ b/lib/Dist/Zilla/MVP/Reader/Finder.pm @@ -5,6 +5,8 @@ use Moose; use Config::MVP::Reader 2.101540; # if_none extends 'Config::MVP::Reader::Finder'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::MVP::Assembler; diff --git a/lib/Dist/Zilla/MVP/Reader/Perl.pm b/lib/Dist/Zilla/MVP/Reader/Perl.pm index a0fe3c5ae..2b2d36287 100644 --- a/lib/Dist/Zilla/MVP/Reader/Perl.pm +++ b/lib/Dist/Zilla/MVP/Reader/Perl.pm @@ -5,6 +5,8 @@ use Moose; extends 'Config::MVP::Reader'; with qw(Config::MVP::Reader::Findable::ByExtension); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -15,9 +17,7 @@ Dist::Zilla::Config reads in the F file for a distribution. sub default_extension { 'pl' } -sub read_into_assembler { - my ($self, $location, $asm) = @_; - +sub read_into_assembler ($self, $location, $asm) { my @input = do File::Spec->rel2abs($location); while (@input and ! ref $input[0]) { my ($key, $value) = (shift(@input), shift(@input)); diff --git a/lib/Dist/Zilla/MVP/RootSection.pm b/lib/Dist/Zilla/MVP/RootSection.pm index be7b404ed..a1b671e17 100644 --- a/lib/Dist/Zilla/MVP/RootSection.pm +++ b/lib/Dist/Zilla/MVP/RootSection.pm @@ -4,6 +4,11 @@ package Dist::Zilla::MVP::RootSection; use Moose; extends 'Config::MVP::Section'; +use Moose::Util::TypeConstraints; +use MooseX::LazyRequire; # turns warnings on aaauuugh -- rjbs, 2018-04-23 + +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -22,9 +27,7 @@ Those useful defaults are: =cut -use MooseX::LazyRequire; use MooseX::SetOnce; -use Moose::Util::TypeConstraints; has '+name' => (default => '_'); @@ -40,12 +43,10 @@ has zilla => ( lazy_required => 1, ); -after finalize => sub { - my ($self) = @_; - +after finalize => sub ($self, @) { my $assembler = $self->sequence->assembler; - my %payload = %{ $self->payload }; + my %payload = $self->payload->%*; my %dzil; $dzil{$_} = delete $payload{":$_"} for grep { s/\A:// } keys %payload; diff --git a/lib/Dist/Zilla/MVP/Section.pm b/lib/Dist/Zilla/MVP/Section.pm index 0ad988eff..05ce183b2 100644 --- a/lib/Dist/Zilla/MVP/Section.pm +++ b/lib/Dist/Zilla/MVP/Section.pm @@ -4,13 +4,13 @@ package Dist::Zilla::MVP::Section; use Moose; extends 'Config::MVP::Section'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Config::MVP::Section 2.200009; # not-installed error with section_name -around add_value => sub { - my ($orig, $self, $name, $value) = @_; - +around add_value => sub ($orig, $self, $name, $value) { if ($name =~ s/\A://) { if ($name eq 'version') { Dist::Zilla::Util->_assert_loaded_class_version_ok( @@ -25,16 +25,14 @@ around add_value => sub { $self->$orig($name, $value); }; -after finalize => sub { - my ($self) = @_; - +after finalize => sub ($self, @) { my ($name, $plugin_class, $arg) = ( $self->name, $self->package, $self->payload, ); - my %payload = %{ $self->payload }; + my %payload = $self->payload->%*; $plugin_class->register_component($name, \%payload, $self); diff --git a/lib/Dist/Zilla/MintingProfile/Default.pm b/lib/Dist/Zilla/MintingProfile/Default.pm index d9c68fa7d..9b36ca7c4 100644 --- a/lib/Dist/Zilla/MintingProfile/Default.pm +++ b/lib/Dist/Zilla/MintingProfile/Default.pm @@ -4,6 +4,8 @@ package Dist::Zilla::MintingProfile::Default; use Moose; with 'Dist::Zilla::Role::MintingProfile::ShareDir'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::Util; @@ -17,9 +19,7 @@ if not found it looks among the default profiles shipped with Dist::Zilla. =cut -around profile_dir => sub { - my ($orig, $self, $profile_name) = @_; - +around profile_dir => sub ($orig, $self, $profile_name) { $profile_name ||= 'default'; # shouldn't look in user's config when testing diff --git a/lib/Dist/Zilla/Path.pm b/lib/Dist/Zilla/Path.pm index fd976975a..194a01e39 100644 --- a/lib/Dist/Zilla/Path.pm +++ b/lib/Dist/Zilla/Path.pm @@ -5,47 +5,12 @@ use utf8; package Dist::Zilla::Path; # ABSTRACT: a helper to get Path::Tiny objects -use parent 'Path::Tiny'; +use Dist::Zilla::Dialect; -use Path::Tiny 0.052 qw(); # issue 427 -use Scalar::Util qw( blessed ); +use Path::Tiny 0.052 qw( path ); # issue 427 use Sub::Exporter -setup => { exports => [ qw( path ) ], groups => { default => [ qw( path ) ] }, }; -sub path { - my ($thing, @rest) = @_; - - if (@rest == 0 && blessed $thing) { - return $thing if $thing->isa(__PACKAGE__); - - return bless(Path::Tiny::path("$thing"), __PACKAGE__) - if $thing->isa('Path::Class::Entity') || $thing->isa('Path::Tiny'); - } - - return bless(Path::Tiny::path($thing, @rest), __PACKAGE__); -} - -my %warned; - -sub file { - my ($self, @file) = @_; - - my ($package, $pmfile, $line) = caller; - unless ($warned{ $pmfile, $line }++) { - Carp::carp("->file called on a Dist::Zilla::Path object; this will cease to work in Dist::Zilla v7; downstream code should be updated to use Path::Tiny API, not Path::Class"); - } - - require Path::Class; - Path::Class::dir($self)->file(@file); -} - -sub subdir { - my ($self, @subdir) = @_; - Carp::carp("->subdir called on a Dist::Zilla::Path object; this will cease to work in Dist::Zilla v7; downstream code should be updated to use Path::Tiny API, not Path::Class"); - require Path::Class; - Path::Class::dir($self)->subdir(@subdir); -} - 1; diff --git a/lib/Dist/Zilla/Plugin/AutoPrereqs.pm b/lib/Dist/Zilla/Plugin/AutoPrereqs.pm index 3f9570c1b..70bd1d156 100644 --- a/lib/Dist/Zilla/Plugin/AutoPrereqs.pm +++ b/lib/Dist/Zilla/Plugin/AutoPrereqs.pm @@ -9,6 +9,9 @@ with( ); use Moose::Util::TypeConstraints 'enum'; + +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -115,9 +118,7 @@ has scanners => ( has _scanner => ( is => 'ro', lazy => 1, - default => sub { - my $self = shift; - + default => sub ($self, @) { require Perl::PrereqScanner; Perl::PrereqScanner->VERSION('1.016'); # don't skip "lib" @@ -135,14 +136,26 @@ has type => ( default => 'requires', ); -sub scan_file_reqs { - my ($self, $file) = @_; +sub scan_file_reqs ($self, $file) { return $self->_scanner->scan_ppi_document($self->ppi_document_for_file($file)) } -sub register_prereqs { - my $self = shift; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = +{ + (map { $_ => [ sort @{ $self->$_ } ] } qw(extra_scanners)), + (map { $_ => $self->$_ } qw(type)), + ($self->has_scanners ? (scanners => $self->scanners) : ()), + }; + + return $config; +}; +sub register_prereqs ($self) { my $type = $self->type; my $reqs_by_phase = $self->scan_prereqs; diff --git a/lib/Dist/Zilla/Plugin/AutoVersion.pm b/lib/Dist/Zilla/Plugin/AutoVersion.pm index d1a75936a..3e08da935 100644 --- a/lib/Dist/Zilla/Plugin/AutoVersion.pm +++ b/lib/Dist/Zilla/Plugin/AutoVersion.pm @@ -7,6 +7,8 @@ with( 'Dist::Zilla::Role::TextTemplate', ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -64,9 +66,20 @@ has format => ( . q<{{$ENV{DEV} ? (sprintf '_%03u', $ENV{DEV}) : ''}}> ); -sub provide_version { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => $self->$_ } qw(major format time_zone), + }; + + return $config; +}; +sub provide_version ($self) { if (exists $ENV{V}) { $self->log_debug([ 'providing version %s', $ENV{V} ]); return $ENV{V}; diff --git a/lib/Dist/Zilla/Plugin/CPANFile.pm b/lib/Dist/Zilla/Plugin/CPANFile.pm index 011fb28be..4d0c930f8 100644 --- a/lib/Dist/Zilla/Plugin/CPANFile.pm +++ b/lib/Dist/Zilla/Plugin/CPANFile.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::CPANFile; use Moose; with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::File::FromCode; @@ -41,9 +43,7 @@ has filename => ( default => 'cpanfile', ); -sub _hunkify_hunky_hunk_hunks { - my ($self, $indent, $type, $req) = @_; - +sub _hunkify_hunky_hunk_hunks ($self, $indent, $type, $req) { my $str = ''; for my $module (sort $req->required_modules) { my $vstr = $req->requirements_for_module($module); @@ -53,9 +53,18 @@ sub _hunkify_hunky_hunk_hunks { return $str; } -sub gather_files { - my ($self, $arg) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { filename => $self->filename }; + + return $config; +}; +sub gather_files ($self) { my $zilla = $self->zilla; my $file = Dist::Zilla::File::FromCode->new({ diff --git a/lib/Dist/Zilla/Plugin/ConfirmRelease.pm b/lib/Dist/Zilla/Plugin/ConfirmRelease.pm index 02d6929ad..f1d305bb4 100644 --- a/lib/Dist/Zilla/Plugin/ConfirmRelease.pm +++ b/lib/Dist/Zilla/Plugin/ConfirmRelease.pm @@ -4,16 +4,16 @@ package Dist::Zilla::Plugin::ConfirmRelease; use Moose; with 'Dist::Zilla::Role::BeforeRelease'; -use namespace::autoclean; +use Dist::Zilla::Dialect; -sub before_release { - my ($self, $tgz) = @_; +use namespace::autoclean; +sub before_release ($self, $tgz) { my $releasers = join q{, }, map {; $_->plugin_name } - @{ $self->zilla->plugins_with(-Releaser) }; + $self->zilla->plugins_with(-Releaser); - $self->log("*** Preparing to release $tgz with $releasers ***"); + $self->log([ '*** Preparing to release %s with %s ***', $tgz->basename, $releasers ]); my $prompt = "Do you want to continue the release process?"; my $default = exists $ENV{DZIL_CONFIRMRELEASE_DEFAULT} diff --git a/lib/Dist/Zilla/Plugin/DistINI.pm b/lib/Dist/Zilla/Plugin/DistINI.pm index a369983ba..d4ea919a7 100644 --- a/lib/Dist/Zilla/Plugin/DistINI.pm +++ b/lib/Dist/Zilla/Plugin/DistINI.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::DistINI; use Moose; with qw(Dist::Zilla::Role::FileGatherer); +use Dist::Zilla::Dialect; + use Dist::Zilla::File::FromCode; use MooseX::Types::Moose qw(ArrayRef Str); @@ -59,14 +61,12 @@ has append_file => ( default => sub { [] }, ); -sub gather_files { - my ($self, $arg) = @_; - +sub gather_files ($self) { my $zilla = $self->zilla; my $postlude = ''; - for (@{ $self->append_file }) { + for ($self->append_file->@*) { my $fn = $self->zilla->root->child($_); $postlude .= path($fn)->slurp_utf8; @@ -84,7 +84,7 @@ sub gather_files { my $content = ''; $content .= sprintf "name = %s\n", $zilla->name; - $content .= sprintf "author = %s\n", $_ for @{ $zilla->authors }; + $content .= sprintf "author = %s\n", $_ for $zilla->authors; $content .= sprintf "license = %s\n", $license; $content .= sprintf "copyright_holder = %s\n", $zilla->copyright_holder; $content .= sprintf "copyright_year = %s\n", (localtime)[5] + 1900; diff --git a/lib/Dist/Zilla/Plugin/Encoding.pm b/lib/Dist/Zilla/Plugin/Encoding.pm index f2ec4db9f..80d13df2f 100644 --- a/lib/Dist/Zilla/Plugin/Encoding.pm +++ b/lib/Dist/Zilla/Plugin/Encoding.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::Encoding; use Moose; with 'Dist::Zilla::Role::EncodingProvider'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -78,20 +80,32 @@ has ignore => ( default => sub { [] }, ); -sub set_file_encodings { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + encoding => $self->encoding, + map { $_ => [ sort @{ $self->$_ } ] } qw(filenames matches), + }; + + return $config; +}; +sub set_file_encodings ($self) { # never match (at least the filename characters) my $matches_regex = qr/\000/; - $matches_regex = qr/$matches_regex|$_/ for @{$self->matches}; + $matches_regex = qr/$matches_regex|$_/ for $self->matches->@*; # \A\Q$_\E should also handle the `eq` check - $matches_regex = qr/$matches_regex|\A\Q$_\E/ for @{$self->filenames}; + $matches_regex = qr/$matches_regex|\A\Q$_\E/ for $self->filenames->@*; - my( $ignore_regex ) = map { $_ && qr/$_/ } join '|', @{ $self->ignore }; + my( $ignore_regex ) = map { $_ && qr/$_/ } join '|', $self->ignore->@*; - for my $file (@{$self->zilla->files}) { + for my $file ($self->zilla->files->@*) { next unless $file->name =~ $matches_regex; next if $ignore_regex and $file->name =~ $ignore_regex; diff --git a/lib/Dist/Zilla/Plugin/ExecDir.pm b/lib/Dist/Zilla/Plugin/ExecDir.pm index afd2c7039..4b47a46f6 100644 --- a/lib/Dist/Zilla/Plugin/ExecDir.pm +++ b/lib/Dist/Zilla/Plugin/ExecDir.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Plugin::ExecDir; use Moose; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -23,5 +25,17 @@ has dir => ( ); with 'Dist::Zilla::Role::ExecFiles'; + +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { dir => $self->dir }; + + return $config; +}; + __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/Dist/Zilla/Plugin/ExtraTests.pm b/lib/Dist/Zilla/Plugin/ExtraTests.pm index 329d6e5e5..7a4ae937a 100644 --- a/lib/Dist/Zilla/Plugin/ExtraTests.pm +++ b/lib/Dist/Zilla/Plugin/ExtraTests.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::ExtraTests; use Moose; with 'Dist::Zilla::Role::FileMunger'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -20,9 +22,7 @@ not set. =cut -sub munge_file { - my ($self, $file) = @_; - +sub munge_file ($self, $file) { return unless $file->name =~ m{\Axt/(smoke|author|release)/.+\.t\z}; my $method = "_rewrite_$1\_test"; @@ -31,24 +31,19 @@ sub munge_file { $self->$method($file); } -sub _rewrite_smoke_test { - my ($self, $file) = @_; +sub _rewrite_smoke_test ($self, $file) { $self->_rewrite($file, 'AUTOMATED_TESTING', '"smoke bot" testing'); } -sub _rewrite_author_test { - my ($self, $file) = @_; +sub _rewrite_author_test ($self, $file) { $self->_rewrite($file, 'AUTHOR_TESTING', 'testing by the author'); } -sub _rewrite_release_test { - my ($self, $file) = @_; +sub _rewrite_release_test ($self, $file) { $self->_rewrite($file, 'RELEASE_TESTING', 'release candidate testing'); } -sub _rewrite { - my ($self, $file, $env, $msg) = @_; - +sub _rewrite ($self, $file, $env, $msg) { my $name = $file->name =~ s{^xt/([^/]+)/}{t/$1-}r; $file->name($name); diff --git a/lib/Dist/Zilla/Plugin/FakeRelease.pm b/lib/Dist/Zilla/Plugin/FakeRelease.pm index ada74e692..2276e5442 100644 --- a/lib/Dist/Zilla/Plugin/FakeRelease.pm +++ b/lib/Dist/Zilla/Plugin/FakeRelease.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::FakeRelease; use Moose; with 'Dist::Zilla::Role::Releaser'; +use Dist::Zilla::Dialect; + use namespace::autoclean; has user => ( @@ -15,9 +17,18 @@ has user => ( sub cpanid { shift->user } -sub release { +around dump_config => sub { + my $orig = shift; my $self = shift; + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { user => $self->user }; + + return $config; +}; + +sub release ($self, $) { for my $env ( 'DIST_ZILLA_FAKERELEASE_FAIL', # old 'DZIL_FAKERELEASE_FAIL', # new diff --git a/lib/Dist/Zilla/Plugin/FileFinder/ByName.pm b/lib/Dist/Zilla/Plugin/FileFinder/ByName.pm index 20ee6d060..8ebb4c78f 100644 --- a/lib/Dist/Zilla/Plugin/FileFinder/ByName.pm +++ b/lib/Dist/Zilla/Plugin/FileFinder/ByName.pm @@ -4,6 +4,10 @@ package Dist::Zilla::Plugin::FileFinder::ByName; use Moose; with 'Dist::Zilla::Role::FileFinder'; +use Moose::Util::TypeConstraints; + +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -23,7 +27,6 @@ This plugin was originally contributed by Christopher J. Madsen. =cut -use Moose::Util::TypeConstraints; use MooseX::Types::Moose qw(ArrayRef RegexpRef Str); use Text::Glob 0.08 qw(glob_to_regex_string); @@ -93,8 +96,7 @@ sub mvp_aliases { +{ qw( sub mvp_multivalue_args { qw(dirs files matches skips) } -sub _join_re { - my $list = shift; +my sub _join_re ($list) { return undef unless @$list; # Special case to avoid stringify+compile return $list->[0] if @$list == 1; @@ -103,14 +105,25 @@ sub _join_re { qr/$re/ } -sub find_files { +around dump_config => sub { + my $orig = shift; my $self = shift; + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => [ sort @{ $self->$_ } ] } qw(dirs files matches skips), + }; + + return $config; +}; + +sub find_files ($self) { my $skip = _join_re($self->skips); - my $dir = _join_re([ map { qr!^\Q$_/! } @{ $self->dirs } ]); + my $dir = _join_re([ map { qr!^\Q$_/! } $self->dirs->@* ]); my $match = _join_re([ (map { my $re = glob_to_regex_string($_); qr!(?:\A|/)$re\z! } - @{ $self->files }), + $self->files->@*), @{ $self->matches } ]); diff --git a/lib/Dist/Zilla/Plugin/FileFinder/Filter.pm b/lib/Dist/Zilla/Plugin/FileFinder/Filter.pm index 89f01667f..09c9a0c34 100644 --- a/lib/Dist/Zilla/Plugin/FileFinder/Filter.pm +++ b/lib/Dist/Zilla/Plugin/FileFinder/Filter.pm @@ -9,6 +9,10 @@ with( }, ); +use Moose::Util::TypeConstraints; + +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -26,7 +30,6 @@ This plugin was originally contributed by Christopher J. Madsen. =cut -use Moose::Util::TypeConstraints; use MooseX::Types::Moose qw(ArrayRef RegexpRef Str); { @@ -59,12 +62,23 @@ sub mvp_aliases { +{ qw( sub mvp_multivalue_args { qw(skips) } -sub find_files { +around dump_config => sub { + my $orig = shift; my $self = shift; + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => [ sort @{ $self->$_ } ] } qw(finder skips), + }; + + return $config; +}; + +sub find_files ($self) { my $files = $self->found_files; - foreach my $re (@{ $self->skips }) { + foreach my $re ($self->skips->@*) { @$files = grep { $_->name !~ $re } @$files; } diff --git a/lib/Dist/Zilla/Plugin/FinderCode.pm b/lib/Dist/Zilla/Plugin/FinderCode.pm index fb14f0869..3b25f49ee 100644 --- a/lib/Dist/Zilla/Plugin/FinderCode.pm +++ b/lib/Dist/Zilla/Plugin/FinderCode.pm @@ -4,10 +4,12 @@ package Dist::Zilla::Plugin::FinderCode; use Moose; with 'Dist::Zilla::Role::FileFinder'; -use namespace::autoclean; - use Moose::Util::TypeConstraints; +use Dist::Zilla::Dialect; + +use namespace::autoclean; + has code => ( is => 'ro', isa => 'CodeRef', @@ -20,24 +22,29 @@ has style => ( required => 1, ); -sub find_files { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { style => $self->style }; + + return $config; +}; + +sub find_files ($self) { my $method = '_find_via_' . $self->style; $self->$method; } -sub _find_via_grep { - my ($self) = @_; - - my @files = grep { $self->code->($_, $self) } @{ $self->zilla->files }; +sub _find_via_grep ($self) { + my @files = grep { $self->code->($_, $self) } $self->zilla->files->@*; return \@files; } -sub _find_via_list { - my ($self) = @_; - +sub _find_via_list ($self) { my $code = $self->code; $self->$code; } diff --git a/lib/Dist/Zilla/Plugin/GatherDir.pm b/lib/Dist/Zilla/Plugin/GatherDir.pm index df70ea740..d3661399f 100644 --- a/lib/Dist/Zilla/Plugin/GatherDir.pm +++ b/lib/Dist/Zilla/Plugin/GatherDir.pm @@ -3,8 +3,11 @@ package Dist::Zilla::Plugin::GatherDir; use Moose; use Dist::Zilla::Types qw(Path); +use Dist::Zilla::Util; with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -12,7 +15,7 @@ use namespace::autoclean; This is a very, very simple L plugin. It looks in the directory named in the L attribute and adds all the files it finds there. If the root begins with a tilde, the tilde is -replaced with the current user's home directory according to L. +passed through C first. Almost every dist will be built with one GatherDir plugin, since it's the easiest way to get files from disk into your dist. Most users just need: @@ -56,7 +59,7 @@ has root => ( lazy => 1, coerce => 1, required => 1, - default => sub { shift->zilla->root }, + default => sub ($self, @) { $self->zilla->root }, ); =attr prefix @@ -149,10 +152,7 @@ has prune_directory => ( default => sub { [] }, ); -around dump_config => sub { - my $orig = shift; - my $self = shift; - +around dump_config => sub ($orig, $self) { my $config = $self->$orig; $config->{+__PACKAGE__} = { @@ -160,27 +160,24 @@ around dump_config => sub { # only report relative to dist root to avoid leaking private info root => path($self->root)->relative($self->zilla->root), (map { $_ => $self->$_ ? 1 : 0 } qw(include_dotfiles follow_symlinks)), - (map { $_ => [ sort @{ $self->$_ } ] } qw(exclude_filename exclude_match prune_directory)), + (map { $_ => [ sort $self->$_->@* ] } qw(exclude_filename exclude_match prune_directory)), }; return $config; }; -sub gather_files { - my ($self) = @_; - +sub gather_files ($self) { my $exclude_regex = qr/\000/; - $exclude_regex = qr/(?:$exclude_regex)|$_/ - for @{ $self->exclude_match }; + $exclude_regex = qr/(?:$exclude_regex)|$_/ for $self->exclude_match->@*; my $repo_root = $self->zilla->root; my $root = "" . $self->root; - $root =~ s{^~([\\/])}{require File::HomeDir; File::HomeDir::->my_home . $1}e; + $root =~ s{^~([\\/])}{ Dist::Zilla::Util->homedir . $1 }e; $root = path($root)->absolute($repo_root)->stringify if path($root)->is_relative; my $prune_regex = qr/\000/; $prune_regex = qr/$prune_regex|$_/ - for ( @{ $self->prune_directory }, + for ( $self->prune_directory->@*, $self->include_dotfiles ? () : ( qr/^\.[^.]/ ) ); # build up the rules @@ -208,7 +205,7 @@ sub gather_files { $rule->exec(sub { my $relative = path($_[-1])->relative($root); $relative !~ $exclude_regex && - all { $relative ne $_ } @{ $self->exclude_filename } + all { $relative ne $_ } $self->exclude_filename->@* }); FILE: for my $filename ($rule->in($root)) { @@ -229,9 +226,7 @@ sub gather_files { return; } -sub _file_from_filename { - my ($self, $filename) = @_; - +sub _file_from_filename ($self, $filename) { my @stat = stat $filename or $self->log_fatal("$filename does not exist!"); return Dist::Zilla::File::OnDisk->new({ diff --git a/lib/Dist/Zilla/Plugin/GatherDir/Template.pm b/lib/Dist/Zilla/Plugin/GatherDir/Template.pm index db82a5e7d..f50016257 100644 --- a/lib/Dist/Zilla/Plugin/GatherDir/Template.pm +++ b/lib/Dist/Zilla/Plugin/GatherDir/Template.pm @@ -5,6 +5,8 @@ use Moose; extends 'Dist::Zilla::Plugin::GatherDir'; with 'Dist::Zilla::Role::TextTemplate'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use autodie; @@ -48,11 +50,8 @@ has _rename => ( default => sub { +{} }, ); -around BUILDARGS => sub { - my $orig = shift; - my ($class, @arg) = @_; - - my $args = $class->$orig(@arg); +around BUILDARGS => sub ($orig, $class, @rest) { + my $args = $class->$orig(@rest); my %retargs = %$args; for my $rename (grep /^rename/, keys %retargs) { @@ -64,16 +63,14 @@ around BUILDARGS => sub { return \%retargs; }; -sub _file_from_filename { - my ($self, $filename) = @_; - +sub _file_from_filename ($self, $filename) { my $template = path($filename)->slurp_utf8; my @stat = stat $filename or $self->log_fatal("$filename does not exist!"); my $new_filename = $filename; - for my $token (keys %{$self->_rename}) { + for my $token (keys $self->_rename->%*) { my $expr = $self->_rename->{$token}; my $temp_temp = "{{ $expr }}"; my $replacement = $self->fill_in_string( @@ -90,7 +87,7 @@ sub _file_from_filename { return Dist::Zilla::File::FromCode->new({ name => $new_filename, mode => ($stat[2] & 0755) | 0200, # kill world-writeability, make sure owner-writable. - code => sub { + code => sub ($file, @) { my ($file_obj) = @_; $self->fill_in_string( $template, diff --git a/lib/Dist/Zilla/Plugin/GatherFile.pm b/lib/Dist/Zilla/Plugin/GatherFile.pm index 6d0d7f80f..617df97c5 100644 --- a/lib/Dist/Zilla/Plugin/GatherFile.pm +++ b/lib/Dist/Zilla/Plugin/GatherFile.pm @@ -5,9 +5,12 @@ use Moose; use Dist::Zilla::Types qw(Path ArrayRefOfPaths); with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use MooseX::Types::Moose 'ArrayRef'; use Path::Tiny; use Dist::Zilla::File::OnDisk; +use Dist::Zilla::Util; use namespace::autoclean; =head1 SYNOPSIS @@ -20,8 +23,7 @@ use namespace::autoclean; This is a very, very simple L plugin. It adds all the files referenced by the C option that are found in the directory named in the L attribute. If the root begins -with a tilde, the tilde is replaced with the current user's home directory -according to L. +with a tilde, the tilde is passed through C first. Since normally every distribution will use a GatherDir plugin, you would only need to use the GatherFile plugin if the file was already being excluded (e.g. @@ -76,35 +78,30 @@ has filenames => ( sub mvp_aliases { +{ filename => 'filenames' } } sub mvp_multivalue_args { qw(filenames) } -around dump_config => sub { - my $orig = shift; - my $self = shift; - +around dump_config => sub ($orig, $self) { my $config = $self->$orig; $config->{+__PACKAGE__} = { prefix => $self->prefix, # only report relative to dist root to avoid leaking private info root => path($self->root)->relative($self->zilla->root), - filenames => [ sort @{ $self->filenames } ], + filenames => [ sort $self->filenames->@* ], }; return $config; }; -sub gather_files { - my ($self) = @_; - +sub gather_files ($self) { my $repo_root = $self->zilla->root; my $root = "" . $self->root; - $root =~ s{^~([\\/])}{require File::HomeDir; File::HomeDir::->my_home . $1}e; + $root =~ s{^~([\\/])}{ Dist::Zilla::Util->homedir . $1 }e; $root = path($root); $root = $root->absolute($repo_root) if path($root)->is_relative; - for my $filename (@{ $self->filenames }) - { + for my $filename ($self->filenames->@*) { $filename = $root->child($filename); - $self->log_fatal("$filename is a directory! Use [GatherDir] instead?") if -d $filename; + $self->log_fatal("$filename is a directory! Use [GatherDir] instead?") + if -d $filename; my $fileobj = $self->_file_from_filename($filename->stringify); @@ -120,9 +117,7 @@ sub gather_files { } # as in GatherDir -sub _file_from_filename { - my ($self, $filename) = @_; - +sub _file_from_filename ($self, $filename) { my @stat = stat $filename or $self->log_fatal("$filename does not exist!"); return Dist::Zilla::File::OnDisk->new({ diff --git a/lib/Dist/Zilla/Plugin/GenerateFile.pm b/lib/Dist/Zilla/Plugin/GenerateFile.pm index 20b02ff78..7895d63d5 100644 --- a/lib/Dist/Zilla/Plugin/GenerateFile.pm +++ b/lib/Dist/Zilla/Plugin/GenerateFile.pm @@ -7,6 +7,8 @@ with ( 'Dist::Zilla::Role::TextTemplate', ); +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::File::InMemory; @@ -103,9 +105,21 @@ has name_is_template => ( default => 0, ); -sub gather_files { - my ($self, $arg) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + filename => $self->filename, + map { $_ => $self->$_ ? 1 : 0 } qw(content_is_template name_is_template), + }; + + return $config; +}; +sub gather_files ($self, $arg = {}) { my $file = Dist::Zilla::File::InMemory->new({ name => $self->_filename, content => $self->_content, @@ -115,10 +129,8 @@ sub gather_files { return; } -sub _content { - my $self = shift; - - my $content = join "\n", @{ $self->content }; +sub _content ($self) { + my $content = join "\n", $self->content->@*; $content .= qq{\n}; if ($self->content_is_template) { @@ -134,9 +146,7 @@ sub _content { return $content; } -sub _filename { - my $self = shift; - +sub _filename ($self) { my $filename = $self->filename; if ($self->name_is_template) { diff --git a/lib/Dist/Zilla/Plugin/InlineFiles.pm b/lib/Dist/Zilla/Plugin/InlineFiles.pm index fb30818be..082df2355 100644 --- a/lib/Dist/Zilla/Plugin/InlineFiles.pm +++ b/lib/Dist/Zilla/Plugin/InlineFiles.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::InlineFiles; use Moose; with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -20,9 +22,7 @@ use Data::Section 0.200002 # encoding and bytes '-setup' => { encoding => 'bytes' }; use Dist::Zilla::File::InMemory; -sub gather_files { - my ($self) = @_; - +sub gather_files ($self) { my $data = $self->merged_section_data; return unless $data and %$data; diff --git a/lib/Dist/Zilla/Plugin/License.pm b/lib/Dist/Zilla/Plugin/License.pm index ac2f8cd73..e2be96aab 100644 --- a/lib/Dist/Zilla/Plugin/License.pm +++ b/lib/Dist/Zilla/Plugin/License.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::License; use Moose; with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -26,9 +28,20 @@ has filename => ( default => 'LICENSE', ); -sub gather_files { - my ($self, $arg) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + filename => $self->filename, + }; + + return $config; +}; +sub gather_files ($self) { my $file = Dist::Zilla::File::InMemory->new({ name => $self->filename, content => $self->zilla->license->fulltext, diff --git a/lib/Dist/Zilla/Plugin/MakeMaker.pm b/lib/Dist/Zilla/Plugin/MakeMaker.pm index 29e7b0f2b..ee32e814b 100644 --- a/lib/Dist/Zilla/Plugin/MakeMaker.pm +++ b/lib/Dist/Zilla/Plugin/MakeMaker.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Plugin::MakeMaker; use Moose; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Config; @@ -67,8 +69,7 @@ has '_runner' => ( is => 'ro', lazy => 1, handles => [qw(build test)], - default => sub { - my ($self) = @_; + default => sub ($self, @) { Dist::Zilla::Plugin::MakeMaker::Runner->new({ zilla => $self->zilla, plugin_name => $self->plugin_name . '::Runner', @@ -91,6 +92,20 @@ with qw( Dist::Zilla::Role::TextTemplate ); +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + make_path => $self->make_path, + # default_jobs is dumped by TestRunner + }; + + return $config; +}; + my $template = q!# This file was automatically generated by {{ $generated_by }}. use strict; use warnings; @@ -115,15 +130,13 @@ delete $WriteMakefileArgs{CONFIGURE_REQUIRES} WriteMakefile(%WriteMakefileArgs); {{ $share_dir_code{postamble} || '' }}!; -sub register_prereqs { - my ($self) = @_; - +sub register_prereqs ($self) { $self->zilla->register_prereqs( { phase => 'configure' }, 'ExtUtils::MakeMaker' => $self->eumm_version || 0, ); - return unless keys %{ $self->zilla->_share_dir_map }; + return unless keys $self->zilla->_share_dir_map->%*; $self->zilla->register_prereqs( { phase => 'configure' }, @@ -131,9 +144,7 @@ sub register_prereqs { ); } -sub gather_files { - my ($self) = @_; - +sub gather_files ($self) { require Dist::Zilla::File::InMemory; my $file = Dist::Zilla::File::InMemory->new({ @@ -145,9 +156,7 @@ sub gather_files { return; } -sub share_dir_code { - my ($self) = @_; - +sub share_dir_code ($self) { my $share_dir_code = {}; my $share_dir_map = $self->zilla->_share_dir_map; @@ -178,19 +187,16 @@ PREAMBLE return $share_dir_code; } -sub write_makefile_args { - my ($self) = @_; - +sub write_makefile_args ($self) { my $name = $self->zilla->name =~ s/-/::/gr; - my @exe_files = map { $_->name } - @{ $self->zilla->find_files(':ExecFiles') }; + my @exe_files = map { $_->name } $self->zilla->find_files(':ExecFiles')->@*; $self->log_fatal("can't install files with whitespace in their names") if grep { /\s/ } @exe_files; my %test_dirs; - for my $file (@{ $self->zilla->files }) { + for my $file ($self->zilla->files->@*) { next unless $file->name =~ m{\At/.+\.t\z}; my $dir = $file->name =~ s{/[^/]+\.t\z}{/*.t}gr; @@ -207,25 +213,25 @@ sub write_makefile_args { $perl_prereq = version->parse($perl_prereq)->numify if $perl_prereq; - my $prereqs_dump = sub { + my sub dump_prereqs ($phase, $type) { $self->_normalize_eumm_versions( $prereqs->requirements_for(@_) ->clone ->clear_requirement('perl') - ->as_string_hash - ); - }; + ->as_string_hash) + } - my %require_prereqs = map { - $_ => $prereqs_dump->($_, 'requires'); - } qw(configure build test runtime); + my %require_prereqs = map { $_ => dump_prereqs($_, 'requires'); } + qw(configure build test runtime); # EUMM may soon be able to support this, but until we decide to inject a # higher configure-requires version, we should at least warn the user # https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/issues/215 foreach my $phase (qw(configure build test runtime)) { - if (my @version_ranges = pairgrep { defined($b) && !version::is_lax($b) } %{ $require_prereqs{$phase} } - and ($self->eumm_version || 0) < '7.1101') { + if (my @version_ranges = pairgrep { defined($b) && !version::is_lax($b) } + $require_prereqs{$phase}->%* + and ($self->eumm_version || 0) < '7.1101' + ) { $self->log_fatal([ 'found version range in %s prerequisites, which ExtUtils::MakeMaker cannot parse (must specify eumm_version of at least 7.1101): %s %s', $phase, $_->[0], $_->[1] @@ -236,15 +242,22 @@ sub write_makefile_args { my %write_makefile_args = ( DISTNAME => $self->zilla->name, NAME => $name, - AUTHOR => join(q{, }, @{ $self->zilla->authors }), + AUTHOR => join(q{, }, $self->zilla->authors), ABSTRACT => $self->zilla->abstract, VERSION => $self->zilla->version, LICENSE => $self->zilla->license->meta_yml_name, @exe_files ? ( EXE_FILES => [ sort @exe_files ] ) : (), CONFIGURE_REQUIRES => $require_prereqs{configure}, - keys %{ $require_prereqs{build} } ? ( BUILD_REQUIRES => $require_prereqs{build} ) : (), - keys %{ $require_prereqs{test} } ? ( TEST_REQUIRES => $require_prereqs{test} ) : (), + + keys $require_prereqs{build}->%* + ? ( BUILD_REQUIRES => $require_prereqs{build} ) + : (), + + keys $require_prereqs{test}->%* + ? ( TEST_REQUIRES => $require_prereqs{test} ) + : (), + PREREQ_PM => $require_prereqs{runtime}, test => { TESTS => join q{ }, sort keys %test_dirs }, @@ -255,8 +268,7 @@ sub write_makefile_args { return \%write_makefile_args; } -sub _normalize_eumm_versions { - my ($self, $prereqs) = @_; +sub _normalize_eumm_versions ($self, $prereqs) { for my $v (values %$prereqs) { if (version::is_strict($v)) { my $version = version->parse($v); @@ -273,8 +285,7 @@ sub _normalize_eumm_versions { return $prereqs; } -sub _dump_as { - my ($self, $ref, $name) = @_; +sub _dump_as ($self, $ref, $name) { require Data::Dumper; my $dumper = Data::Dumper->new( [ $ref ], [ $name ] ); $dumper->Sortkeys( 1 ); @@ -283,8 +294,7 @@ sub _dump_as { return $dumper->Dump; } -sub fallback_prereq_pm { - my $self = shift; +sub fallback_prereq_pm ($self) { my $fallback = $self->_normalize_eumm_versions( $self->zilla->prereqs->merged_requires @@ -295,9 +305,7 @@ sub fallback_prereq_pm { return $self->_dump_as( $fallback, '*FallbackPrereqs' ); } -sub setup_installer { - my ($self) = @_; - +sub setup_installer ($self) { my $write_makefile_args = $self->write_makefile_args; $self->__write_makefile_args($write_makefile_args); # save for testing @@ -306,7 +314,7 @@ sub setup_installer { my $dumped_args = $self->_dump_as($write_makefile_args, '*WriteMakefileArgs'); - my $file = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files}; + my $file = first { $_->name eq 'Makefile.PL' } $self->zilla->files->@*; $self->log_debug([ 'updating contents of Makefile.PL in memory' ]); diff --git a/lib/Dist/Zilla/Plugin/MakeMaker/Runner.pm b/lib/Dist/Zilla/Plugin/MakeMaker/Runner.pm index 6a23e57d9..3913c115e 100644 --- a/lib/Dist/Zilla/Plugin/MakeMaker/Runner.pm +++ b/lib/Dist/Zilla/Plugin/MakeMaker/Runner.pm @@ -7,6 +7,8 @@ with( 'Dist::Zilla::Role::TestRunner', ); +use Dist::Zilla::Dialect; + use namespace::autoclean; use Config; @@ -17,9 +19,7 @@ has 'make_path' => ( default => $Config{make} || 'make', ); -sub build { - my $self = shift; - +sub build ($self) { my $make = $self->make_path; my $makefile = $^O eq 'VMS' ? 'Descrip.MMS' : 'Makefile'; @@ -36,9 +36,7 @@ sub build { return; } -sub test { - my ($self, $target, $arg) = @_; - +sub test ($self, $target, $arg = {}) { my $make = $self->make_path; $self->build; diff --git a/lib/Dist/Zilla/Plugin/Manifest.pm b/lib/Dist/Zilla/Plugin/Manifest.pm index 823d7884c..db66de89b 100644 --- a/lib/Dist/Zilla/Plugin/Manifest.pm +++ b/lib/Dist/Zilla/Plugin/Manifest.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::Manifest; use Moose; with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::File::FromCode; @@ -27,17 +29,14 @@ Other modules: L. =cut -sub __fix_filename { - my ($name) = @_; +sub __fix_filename ($name) { return $name unless $name =~ /[ '\\]/; $name =~ s/\\/\\\\/g; $name =~ s/'/\\'/g; return qq{'$name'}; } -sub gather_files { - my ($self, $arg) = @_; - +sub gather_files ($self) { my $zilla = $self->zilla; my $file = Dist::Zilla::File::FromCode->new({ @@ -47,7 +46,10 @@ sub gather_files { my $generated_by = sprintf "%s v%s", ref($self), $self->VERSION || '(dev)'; return "# This file was automatically generated by $generated_by.\n" - . join("\n", map { __fix_filename($_) } sort map { $_->name } @{ $zilla->files }) + . join("\n", map {; __fix_filename($_) } + sort + map {; $_->name } + $zilla->files->@*) . "\n", }, }); diff --git a/lib/Dist/Zilla/Plugin/ManifestSkip.pm b/lib/Dist/Zilla/Plugin/ManifestSkip.pm index c295a7409..40683b822 100644 --- a/lib/Dist/Zilla/Plugin/ManifestSkip.pm +++ b/lib/Dist/Zilla/Plugin/ManifestSkip.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::ManifestSkip; use Moose; with 'Dist::Zilla::Role::FilePruner'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -33,8 +35,18 @@ Other modules: L. has skipfile => (is => 'ro', required => 1, default => 'MANIFEST.SKIP'); -sub prune_files { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { skipfile => $self->skipfile }; + + return $config; +}; + +sub prune_files ($self) { my $files = $self->zilla->files; my $skipfile_name = $self->skipfile; @@ -64,7 +76,7 @@ sub prune_files { my $skip = ExtUtils::Manifest::maniskip($skipfile_name); # Copy list (break reference) so we can mutate. - for my $file ((), @{ $files }) { + for my $file ((), @$files) { next unless $skip->($file->name); $self->log_debug([ 'pruning %s', $file->name ]); diff --git a/lib/Dist/Zilla/Plugin/MetaConfig.pm b/lib/Dist/Zilla/Plugin/MetaConfig.pm index 1424209f3..ff43e5f32 100644 --- a/lib/Dist/Zilla/Plugin/MetaConfig.pm +++ b/lib/Dist/Zilla/Plugin/MetaConfig.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::MetaConfig; use Moose; with 'Dist::Zilla::Role::MetaProvider'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -20,9 +22,7 @@ on. =cut -sub metadata { - my ($self) = @_; - +sub metadata ($self) { my $dump = { }; my @plugins; @@ -39,7 +39,7 @@ sub metadata { version => "$]", }; - for my $plugin (@{ $self->zilla->plugins }) { + for my $plugin ($self->zilla->plugins) { my $config = $plugin->dump_config; push @plugins, { diff --git a/lib/Dist/Zilla/Plugin/MetaJSON.pm b/lib/Dist/Zilla/Plugin/MetaJSON.pm index 6b2223dfe..ec51bbc79 100644 --- a/lib/Dist/Zilla/Plugin/MetaJSON.pm +++ b/lib/Dist/Zilla/Plugin/MetaJSON.pm @@ -3,8 +3,11 @@ package Dist::Zilla::Plugin::MetaJSON; use Moose; with 'Dist::Zilla::Role::FileGatherer'; + use Moose::Util::TypeConstraints; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -37,11 +40,10 @@ If you want a fixed version, specify it. =cut -my $version_type = subtype( - as 'Num', - where { $_ >= 2 }, - message { "MetaJSON version must be 2 or greater" }, -); +my $version_type = subtype + as 'Num', + where { $_ >= 2 }, + message { "MetaJSON version must be 2 or greater" }; has version => ( is => 'ro', @@ -49,9 +51,20 @@ has version => ( default => '2', ); -sub gather_files { - my ($self, $arg) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => $self->$_ } qw(filename version), + }; + + return $config; +}; +sub gather_files ($self) { my $zilla = $self->zilla; require JSON::MaybeXS; diff --git a/lib/Dist/Zilla/Plugin/MetaNoIndex.pm b/lib/Dist/Zilla/Plugin/MetaNoIndex.pm index 49bf721b1..a06d71ee1 100644 --- a/lib/Dist/Zilla/Plugin/MetaNoIndex.pm +++ b/lib/Dist/Zilla/Plugin/MetaNoIndex.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::MetaNoIndex; use Moose; with 'Dist::Zilla::Role::MetaProvider'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =encoding utf8 @@ -46,7 +48,7 @@ sub mvp_aliases { my %alias_for; for my $key (keys %ATTR_ALIAS) { - $alias_for{ $_ } = $key for @{ $ATTR_ALIAS{$key} }; + $alias_for{ $_ } = $key for $ATTR_ALIAS{$key}->@*; } return \%alias_for; @@ -92,6 +94,19 @@ for my $attr (keys %ATTR_ALIAS) { ); } +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => [ sort @{ $self->$_ } ] } qw(directories files packages namespaces), + }; + + return $config; +}; + =method metadata Returns a reference to a hash containing the distribution's no_index metadata. @@ -102,7 +117,7 @@ sub metadata { my $self = shift; return { no_index => { - map {; my $reader = $_->[0]; ($_->[1] => [ sort @{ $self->$reader } ]) } + map {; my $reader = $_->[0]; ($_->[1] => [ sort $self->$reader->@* ]) } grep {; my $pred = "_has_$_->[0]"; $self->$pred } map {; [ $_ => $ATTR_ALIAS{$_}[0] ] } keys %ATTR_ALIAS diff --git a/lib/Dist/Zilla/Plugin/MetaResources.pm b/lib/Dist/Zilla/Plugin/MetaResources.pm index 16f5c9f5d..7d391a163 100644 --- a/lib/Dist/Zilla/Plugin/MetaResources.pm +++ b/lib/Dist/Zilla/Plugin/MetaResources.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::MetaResources; use Moose; with 'Dist::Zilla::Role::MetaProvider'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -26,12 +28,9 @@ has resources => ( required => 1, ); -around BUILDARGS => sub { - my $orig = shift; - my ($class, @arg) = @_; - - my $args = $class->$orig(@arg); - my %copy = %{ $args }; +around BUILDARGS => sub ($orig, $class, @rest) { + my $args = $class->$orig(@rest); + my %copy = %$args; my $zilla = delete $copy{zilla}; my $name = delete $copy{plugin_name}; @@ -64,9 +63,18 @@ around BUILDARGS => sub { }; }; -sub metadata { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { resources => $self->resources }; + + return $config; +}; +sub metadata ($self) { return { resources => $self->resources }; } diff --git a/lib/Dist/Zilla/Plugin/MetaTests.pm b/lib/Dist/Zilla/Plugin/MetaTests.pm index dc611c659..25f9a41b2 100644 --- a/lib/Dist/Zilla/Plugin/MetaTests.pm +++ b/lib/Dist/Zilla/Plugin/MetaTests.pm @@ -5,6 +5,8 @@ use Moose; extends 'Dist::Zilla::Plugin::InlineFiles'; with 'Dist::Zilla::Role::PrereqSource'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -12,7 +14,7 @@ use namespace::autoclean; This is an extension of L, providing the following files: - xt/release/meta-yaml.t - a standard Test::CPAN::Meta test + xt/author/meta-yaml.t - a standard Test::CPAN::Meta test L will be added as a C dependency (which can be installed via C<< dzil listdeps --author | cpanm >>). @@ -28,11 +30,9 @@ L. =cut -# Register the release test prereq as a "develop requires" +# Register the author test prereq as a "develop requires" # so it will be listed in "dzil listdeps --author" -sub register_prereqs { - my ($self) = @_; - +sub register_prereqs ($self) { $self->zilla->register_prereqs( { phase => 'develop', type => 'requires', @@ -45,7 +45,7 @@ __PACKAGE__->meta->make_immutable; 1; __DATA__ -___[ xt/release/distmeta.t ]___ +___[ xt/author/distmeta.t ]___ #!perl # This file was automatically generated by Dist::Zilla::Plugin::MetaTests. diff --git a/lib/Dist/Zilla/Plugin/MetaYAML.pm b/lib/Dist/Zilla/Plugin/MetaYAML.pm index 4fdbc5a92..535544fcf 100644 --- a/lib/Dist/Zilla/Plugin/MetaYAML.pm +++ b/lib/Dist/Zilla/Plugin/MetaYAML.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::MetaYAML; use Moose; with 'Dist::Zilla::Role::FileGatherer'; +use Dist::Zilla::Dialect; + use Try::Tiny; use namespace::autoclean; @@ -26,9 +28,18 @@ has filename => ( default => 'META.yml', ); -sub gather_files { - my ($self, $arg) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { filename => $self->filename }; + return $config; +}; + +sub gather_files ($self) { require Dist::Zilla::File::FromCode; require YAML::Tiny; require CPAN::Meta::Converter; @@ -59,8 +70,7 @@ sub gather_files { my $yaml = try { YAML::Tiny->new($output)->write_string; # text! - } - catch { + } catch { $self->log_fatal("Could not create YAML string: " . YAML::Tiny->errstr) }; return $yaml; diff --git a/lib/Dist/Zilla/Plugin/ModuleBuild.pm b/lib/Dist/Zilla/Plugin/ModuleBuild.pm index 50347bc62..bc6197bbd 100644 --- a/lib/Dist/Zilla/Plugin/ModuleBuild.pm +++ b/lib/Dist/Zilla/Plugin/ModuleBuild.pm @@ -9,6 +9,8 @@ with ( 'Dist::Zilla::Role::TextTemplate', ); +use Dist::Zilla::Dialect; + use namespace::autoclean; use CPAN::Meta::Requirements 2.121; # requirements_for_module @@ -38,8 +40,8 @@ to the generated Build.PL file. =attr mb_lib -B Specify the list of directories to be passed to lib when using -mb_class. Defaults to C. +B Specify the list of directories to be passed to lib when using +mb_class. Defaults to C. =attr build_element @@ -52,9 +54,8 @@ has 'mb_version' => ( isa => 'Str', is => 'rw', lazy => 1, - default => sub { - my $self = shift; - keys %{$self->zilla->_share_dir_map} ? '0.3601' : '0.28'; + default => sub ($self, @) { + keys $self->zilla->_share_dir_map->%* ? '0.3601' : '0.28'; }, ); @@ -101,8 +102,7 @@ my $build = {{ $plugin->mb_class }}->new(%module_build_args); $build->create_build_script; |; -sub _use_custom_class { - my ($self) = @_; +sub _use_custom_class ($self) { my $class = $self->mb_class; if ( $class eq 'Module::Build' ) { return ""; @@ -112,8 +112,7 @@ sub _use_custom_class { } } -sub _dump_as { - my ($self, $ref, $name) = @_; +sub _dump_as ($self, $ref, $name) { require Data::Dumper; my $dumper = Data::Dumper->new( [ $ref ], [ $name ] ); $dumper->Sortkeys( 1 ); @@ -123,13 +122,24 @@ sub _dump_as { } sub _add_build_elements { - my @elems = @{ shift->build_element } or return ''; + my @elems = shift->build_element->@* or return ''; return '$build->add_build_element($_) for qw(' . join(' ', @elems) . ');'; } -sub register_prereqs { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => $self->$_ } qw(mb_version mb_class mb_lib), + }; + + return $config; +}; +sub register_prereqs ($self) { $self->zilla->register_prereqs( { phase => 'configure' }, 'Module::Build' => $self->mb_version, @@ -141,11 +151,9 @@ sub register_prereqs { ); } -sub module_build_args { - my ($self) = @_; - +sub module_build_args ($self) { my @exe_files = map { $_->name } - @{ $self->zilla->find_files(':ExecFiles') }; + $self->zilla->find_files(':ExecFiles')->@*; $self->log_fatal("can't install files with whitespace in their names") if grep { /\s/ } @exe_files; @@ -167,17 +175,18 @@ sub module_build_args { dist_abstract => $self->zilla->abstract, dist_name => $self->zilla->name, dist_version => $self->zilla->version, - dist_author => [ @{ $self->zilla->authors } ], + dist_author => [ $self->zilla->authors ], @exe_files ? ( script_files => [ sort @exe_files ] ) : (), - ( keys %{$self->zilla->_share_dir_map} ? (share_dir => $self->zilla->_share_dir_map) : ()), + (keys $self->zilla->_share_dir_map->%* + ? (share_dir => $self->zilla->_share_dir_map) + : ()), (map {; my $modules = $prereqs{$_}->as_string_hash; keys %$modules ? ( $_ => $modules ) : () } keys %prereqs), recursive_test_files => 1, }; } -sub fallback_build_requires { - my $self = shift; +sub fallback_build_requires ($self) { my $prereqs = $self->zilla->prereqs; my $merged = CPAN::Meta::Requirements->new; for my $phase ( qw/build test/ ) { @@ -187,9 +196,7 @@ sub fallback_build_requires { return $self->_dump_as( $merged->as_string_hash, '*fallback_build_requires' ); } -sub gather_files { - my ($self) = @_; - +sub gather_files ($self) { require Dist::Zilla::File::InMemory; my $file = Dist::Zilla::File::InMemory->new({ @@ -201,9 +208,7 @@ sub gather_files { return; } -sub setup_installer { - my ($self) = @_; - +sub setup_installer ($self) { $self->log_fatal("can't build Build.PL; license has no known META.yml value") unless $self->zilla->license->meta_yml_name; @@ -215,7 +220,7 @@ sub setup_installer { my $fallback_build_requires = $self->fallback_build_requires; - my $file = first { $_->name eq 'Build.PL' } @{$self->zilla->files}; + my $file = first { $_->name eq 'Build.PL' } $self->zilla->files->@*; $self->log_debug([ 'updating contents of Build.PL in memory' ]); my $content = $self->fill_in_string( diff --git a/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm b/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm index 29684f07c..9f3047992 100644 --- a/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm +++ b/lib/Dist/Zilla/Plugin/ModuleShareDirs.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Plugin::ModuleShareDirs; use Moose; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -21,35 +23,30 @@ has _module_map => ( default => sub { {} }, ); -sub find_files { - my ($self) = @_; +sub find_files ($self) { my $modmap = $self->_module_map; my @files; for my $mod ( keys %$modmap ) { my $dir = $modmap->{$mod}; my @mod_files = grep { index($_->name, "$dir/") == 0 } - @{ $self->zilla->files }; + $self->zilla->files->@*; push @files, @mod_files; } return \@files; } -sub share_dir_map { - my ($self) = @_; +sub share_dir_map ($self) { my $modmap = $self->_module_map; return unless keys %$modmap; return { module => $modmap }; } -around BUILDARGS => sub { - my $orig = shift; - my ($class, @arg) = @_; - - my $args = $class->$orig(@arg); - my %copy = %{ $args }; +around BUILDARGS => sub ($orig, $class, @rest) { + my $args = $class->$orig(@rest); + my %copy = %$args; my $zilla = delete $copy{zilla}; my $name = delete $copy{plugin_name}; @@ -62,5 +59,17 @@ around BUILDARGS => sub { }; with 'Dist::Zilla::Role::ShareDir'; + +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { module_map => $self->_module_map }; + + return $config; +}; + __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/Dist/Zilla/Plugin/NextRelease.pm b/lib/Dist/Zilla/Plugin/NextRelease.pm index 07c8b62b3..a5103e153 100644 --- a/lib/Dist/Zilla/Plugin/NextRelease.pm +++ b/lib/Dist/Zilla/Plugin/NextRelease.pm @@ -1,8 +1,6 @@ package Dist::Zilla::Plugin::NextRelease; # ABSTRACT: update the next release number in your changelog -use namespace::autoclean; - use Moose; with ( 'Dist::Zilla::Role::FileMunger', @@ -10,6 +8,10 @@ with ( 'Dist::Zilla::Role::AfterRelease', ); +use Dist::Zilla::Dialect; + +use namespace::autoclean; + use Dist::Zilla::Path; use Moose::Util::TypeConstraints; use List::Util 'first'; @@ -37,7 +39,9 @@ use String::Formatter 0.100680 stringf => { . ($_[0]->zilla->is_trial ? ($_[1] // '-TRIAL') : '') }, P => sub { - my $releaser = first { $_->can('cpanid') } @{ $_[0]->zilla->plugins_with('-Releaser') }; + my $releaser = first { $_->can('cpanid') } + $_[0]->zilla->plugins_with('-Releaser'); + $_[0]->log_fatal('releaser doesn\'t provide cpanid, but %P used') unless $releaser; $releaser->cpanid; }, @@ -103,6 +107,19 @@ sub section_header { return _format_version($self->format, $self); } +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => $self->$_ } qw(time_zone format filename update_filename user_stash), + }; + + return $config; +}; + has _original_changes_content => ( is => 'rw', isa => 'Str', @@ -112,7 +129,7 @@ has _original_changes_content => ( sub munge_files { my ($self) = @_; - my ($file) = grep { $_->name eq $self->filename } @{ $self->zilla->files }; + my ($file) = grep { $_->name eq $self->filename } $self->zilla->files->@*; $self->log_fatal([ 'failed to find %s in the distribution', $self->filename ]) if not $file; # save original unmunged content, for replacing back in the repo later @@ -135,7 +152,7 @@ sub munge_files { sub after_release { my ($self) = @_; my $filename = $self->filename; - my ($gathered_file) = grep { $_->name eq $filename } @{ $self->zilla->files }; + my ($gathered_file) = grep { $_->name eq $filename } $self->zilla->files->@*; $self->log_fatal("failed to find $filename in the distribution") if not $gathered_file; my $iolayer = sprintf(":raw:encoding(%s)", $gathered_file->encoding); @@ -152,7 +169,7 @@ sub after_release { $self->log_debug([ 'updating contents of %s on disk', $update_fn ]); # and finally rewrite the changelog on disk - path($update_fn)->spew({binmode => $iolayer}, $content); + path($self->zilla->root, $update_fn)->spew({binmode => $iolayer}, $content); } __PACKAGE__->meta->make_immutable; diff --git a/lib/Dist/Zilla/Plugin/PkgDist.pm b/lib/Dist/Zilla/Plugin/PkgDist.pm index bf397752f..dc15eaa79 100644 --- a/lib/Dist/Zilla/Plugin/PkgDist.pm +++ b/lib/Dist/Zilla/Plugin/PkgDist.pm @@ -10,6 +10,8 @@ with( 'Dist::Zilla::Role::PPI', ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -30,15 +32,11 @@ typically used when doing monkey patching or other tricky things. =cut -sub munge_files { - my ($self) = @_; - - $self->munge_file($_) for @{ $self->found_files }; +sub munge_files ($self) { + $self->munge_file($_) for $self->found_files->@*; } -sub munge_file { - my ($self, $file) = @_; - +sub munge_file ($self, $file) { # XXX: for test purposes, for now! evil! -- rjbs, 2010-03-17 return if $file->name =~ /^corpus\//; @@ -48,9 +46,7 @@ sub munge_file { return; } -sub munge_perl { - my ($self, $file) = @_; - +sub munge_perl ($self, $file) { my $dist_name = $self->zilla->name; my $document = $self->ppi_document_for_file($file); diff --git a/lib/Dist/Zilla/Plugin/PkgVersion.pm b/lib/Dist/Zilla/Plugin/PkgVersion.pm index 41c2a8afb..66e219a0d 100644 --- a/lib/Dist/Zilla/Plugin/PkgVersion.pm +++ b/lib/Dist/Zilla/Plugin/PkgVersion.pm @@ -10,6 +10,8 @@ with( 'Dist::Zilla::Role::PPI', ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -99,8 +101,7 @@ L<[FileFinder::Filter]|Dist::Zilla::Plugin::FileFinder::Filter> plugins. =cut -sub BUILD { - my ($self) = @_; +sub BUILD ($self, @) { $self->log("use_our option to PkgVersion is deprecated and will be removed") if $self->use_our; @@ -109,15 +110,24 @@ sub BUILD { } } -sub munge_files { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; - $self->munge_file($_) for @{ $self->found_files }; -} + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => $self->$_ ? 1 : 0 } qw(die_on_existing_version die_on_line_insertion), + }; -sub munge_file { - my ($self, $file) = @_; + return $config; +}; +sub munge_files ($self) { + $self->munge_file($_) for $self->found_files->@*; +} + +sub munge_file ($self, $file) { if ($file->is_bytes) { $self->log_debug($file->name . " has 'bytes' encoding, skipping..."); return; @@ -161,9 +171,7 @@ has use_begin => ( default => 0, ); -sub munge_perl { - my ($self, $file) = @_; - +sub munge_perl ($self, $file) { my $version = $self->zilla->version; require version; diff --git a/lib/Dist/Zilla/Plugin/PodCoverageTests.pm b/lib/Dist/Zilla/Plugin/PodCoverageTests.pm index ca82ce60c..8d63d7cec 100644 --- a/lib/Dist/Zilla/Plugin/PodCoverageTests.pm +++ b/lib/Dist/Zilla/Plugin/PodCoverageTests.pm @@ -5,6 +5,8 @@ use Moose; extends 'Dist::Zilla::Plugin::InlineFiles'; with 'Dist::Zilla::Role::PrereqSource'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -27,9 +29,7 @@ C dependencies. # Register the author test prereq as a "develop requires" # so it will be listed in "dzil listdeps --author" -sub register_prereqs { - my ($self) = @_; - +sub register_prereqs ($self) { $self->zilla->register_prereqs( { type => 'requires', diff --git a/lib/Dist/Zilla/Plugin/PodSyntaxTests.pm b/lib/Dist/Zilla/Plugin/PodSyntaxTests.pm index 0b7c91d73..787e1c8d4 100644 --- a/lib/Dist/Zilla/Plugin/PodSyntaxTests.pm +++ b/lib/Dist/Zilla/Plugin/PodSyntaxTests.pm @@ -5,6 +5,8 @@ use Moose; extends 'Dist::Zilla::Plugin::InlineFiles'; with 'Dist::Zilla::Role::PrereqSource'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -18,12 +20,9 @@ L C<1.41> will be added as a C dependency. =cut - # Register the author test prereq as a "develop requires" # so it will be listed in "dzil listdeps --author" -sub register_prereqs { - my ($self) = @_; - +sub register_prereqs ($self) { $self->zilla->register_prereqs( { type => 'requires', @@ -33,7 +32,6 @@ sub register_prereqs { ); } - __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/Dist/Zilla/Plugin/PodVersion.pm b/lib/Dist/Zilla/Plugin/PodVersion.pm index e87009c62..36bcb30fa 100644 --- a/lib/Dist/Zilla/Plugin/PodVersion.pm +++ b/lib/Dist/Zilla/Plugin/PodVersion.pm @@ -9,6 +9,8 @@ with( }, ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -25,21 +27,28 @@ section). =cut -sub munge_files { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; - $self->munge_file($_) for @{ $self->found_files }; -} + my $config = $self->$orig; -sub munge_file { - my ($self, $file) = @_; + $config->{+__PACKAGE__} = { + finder => [ sort @{ $self->finder } ], + }; - return $self->munge_pod($file); + return $config; +}; + +sub munge_files ($self) { + $self->munge_file($_) for $self->found_files->@*; } -sub munge_pod { - my ($self, $file) = @_; +sub munge_file ($self, $file) { + return $self->munge_pod($file); +} +sub munge_pod ($self, $file) { my @content = split /\n/, $file->content; require List::Util; diff --git a/lib/Dist/Zilla/Plugin/Prereqs.pm b/lib/Dist/Zilla/Plugin/Prereqs.pm index 7263d985a..ef65f82a9 100644 --- a/lib/Dist/Zilla/Plugin/Prereqs.pm +++ b/lib/Dist/Zilla/Plugin/Prereqs.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::Prereqs; use Moose; with 'Dist::Zilla::Role::PrereqSource'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -100,8 +102,7 @@ has prereq_type => ( default => 'requires', ); -around dump_config => sub { - my ($orig, $self) = @_; +around dump_config => sub ($orig, $self, @) { my $config = $self->$orig; my $this_config = { @@ -122,12 +123,9 @@ has _prereq => ( sub mvp_aliases { return { -relationship => '-type' } } -around BUILDARGS => sub { - my $orig = shift; - my ($class, @arg) = @_; - - my $args = $class->$orig(@arg); - my %copy = %{ $args }; +around BUILDARGS => sub ($orig, $class, @rest) { + my $args = $class->$orig(@rest); + my %copy = %$args; my $zilla = delete $copy{zilla}; my $name = delete $copy{plugin_name}; @@ -171,15 +169,13 @@ around BUILDARGS => sub { } }; -sub register_prereqs { - my ($self) = @_; - +sub register_prereqs ($self) { $self->zilla->register_prereqs( { type => $self->prereq_type, phase => $self->prereq_phase, }, - %{ $self->_prereq }, + $self->_prereq->%*, ); } diff --git a/lib/Dist/Zilla/Plugin/PruneCruft.pm b/lib/Dist/Zilla/Plugin/PruneCruft.pm index 13aee3bbf..1041fafe2 100644 --- a/lib/Dist/Zilla/Plugin/PruneCruft.pm +++ b/lib/Dist/Zilla/Plugin/PruneCruft.pm @@ -5,6 +5,8 @@ use Moose; use Moose::Util::TypeConstraints; with 'Dist::Zilla::Role::FilePruner'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -48,17 +50,14 @@ L. sub mvp_multivalue_args { qw(except) } } -sub _dont_exclude_file { - my ($self, $file) = @_; - for my $exception (@{ $self->except }) { +sub _dont_exclude_file ($self, $file) { + for my $exception ($self->except->@*) { return 1 if $file->name =~ $exception; } return; } -sub exclude_file { - my ($self, $file) = @_; - +sub exclude_file ($self, $file) { return 0 if $self->_dont_exclude_file($file); return 1 if index($file->name, $self->zilla->name . '-') == 0; return 1 if $file->name =~ /\A\./; @@ -77,7 +76,7 @@ sub exclude_file { return 1 if substr($file->name, 0, 4) eq 'tmp/'; if (my $file = $file->name =~ s/\.c$//r) { - for my $other (@{ $self->zilla->files }) { + for my $other ($self->zilla->files->@*) { return 1 if $other->name eq "${file}.xs"; } } @@ -85,11 +84,22 @@ sub exclude_file { return; } -sub prune_files { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + except => [ sort @{ $self->except } ], + }; + + return $config; +}; +sub prune_files ($self) { # Copy list (break reference) so we can mutate. - for my $file ((), @{ $self->zilla->files }) { + for my $file ((), $self->zilla->files->@*) { next unless $self->exclude_file($file); $self->log_debug([ 'pruning %s', $file->name ]); diff --git a/lib/Dist/Zilla/Plugin/PruneFiles.pm b/lib/Dist/Zilla/Plugin/PruneFiles.pm index 7d15752a9..7c0d03531 100644 --- a/lib/Dist/Zilla/Plugin/PruneFiles.pm +++ b/lib/Dist/Zilla/Plugin/PruneFiles.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::PruneFiles; use Moose; with 'Dist::Zilla::Role::FilePruner'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -55,16 +57,27 @@ has matches => ( default => sub { [] }, ); -sub prune_files { - my ($self) = @_; +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + map { $_ => [ sort @{ $self->$_ } ] } qw(filenames matches), + }; + + return $config; +}; +sub prune_files ($self) { # never match (at least the filename characters) my $matches_regex = qr/\000/; - $matches_regex = qr/$matches_regex|$_/ for (@{ $self->matches }); + $matches_regex = qr/$matches_regex|$_/ for ($self->matches->@*); # \A\Q$_\E should also handle the `eq` check - $matches_regex = qr/$matches_regex|\A\Q$_\E/ for (@{ $self->filenames }); + $matches_regex = qr/$matches_regex|\A\Q$_\E/ for ($self->filenames->@*); # Copy list (break reference) so we can mutate. for my $file ((), @{ $self->zilla->files }) { diff --git a/lib/Dist/Zilla/Plugin/Readme.pm b/lib/Dist/Zilla/Plugin/Readme.pm index 3d39ffeff..8cc9e905f 100644 --- a/lib/Dist/Zilla/Plugin/Readme.pm +++ b/lib/Dist/Zilla/Plugin/Readme.pm @@ -7,6 +7,9 @@ with qw/Dist::Zilla::Role::FileGatherer Dist::Zilla::Role::FileMunger/; use Moose::Util::TypeConstraints; + +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -21,9 +24,7 @@ has _file_obj => ( is => 'rw', isa => role_type('Dist::Zilla::Role::File'), ); -sub gather_files { - my ($self, $arg) = @_; - +sub gather_files ($self) { require Dist::Zilla::File::InMemory; my $template = q| @@ -53,9 +54,7 @@ This README file was generated by {{ $generated_by }}. return; } -sub munge_files { - my $self = shift; - +sub munge_files ($self) { my $file = $self->_file_obj; $file->content( diff --git a/lib/Dist/Zilla/Plugin/RemovePrereqs.pm b/lib/Dist/Zilla/Plugin/RemovePrereqs.pm index 8b05f2ad4..c34a11544 100644 --- a/lib/Dist/Zilla/Plugin/RemovePrereqs.pm +++ b/lib/Dist/Zilla/Plugin/RemovePrereqs.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::RemovePrereqs; use Moose; with 'Dist::Zilla::Role::PrereqSource'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use MooseX::Types::Moose qw(ArrayRef); @@ -40,12 +42,11 @@ has modules_to_remove => ( required => 1, ); -around dump_config => sub { - my ($orig, $self) = @_; +around dump_config => sub ($orig, $self, @) { my $config = $self->$orig; my $this_config = { - modules_to_remove => [ sort @{ $self->modules_to_remove } ], + modules_to_remove => [ sort $self->modules_to_remove->@* ], }; $config->{'' . __PACKAGE__} = $this_config; @@ -56,14 +57,12 @@ around dump_config => sub { my @phases = qw(configure build test runtime develop); my @types = qw(requires recommends suggests conflicts); -sub register_prereqs { - my ($self) = @_; - +sub register_prereqs ($self) { my $prereqs = $self->zilla->prereqs; for my $p (@phases) { for my $t (@types) { - for my $m (@{ $self->modules_to_remove }) { + for my $m ($self->modules_to_remove->@*) { $prereqs->requirements_for($p, $t)->clear_requirement($m); } } diff --git a/lib/Dist/Zilla/Plugin/ShareDir.pm b/lib/Dist/Zilla/Plugin/ShareDir.pm index c12d5abcd..063f28aa7 100644 --- a/lib/Dist/Zilla/Plugin/ShareDir.pm +++ b/lib/Dist/Zilla/Plugin/ShareDir.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Plugin::ShareDir; use Moose; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 SYNOPSIS @@ -22,18 +24,12 @@ has dir => ( default => 'share', ); -sub find_files { - my ($self) = @_; - +sub find_files ($self) { my $dir = $self->dir; - my $files = [ - grep { index($_->name, "$dir/") == 0 } - @{ $self->zilla->files } - ]; + return [ grep { index($_->name, "$dir/") == 0 } $self->zilla->files->@* ]; } -sub share_dir_map { - my ($self) = @_; +sub share_dir_map ($self) { my $files = $self->find_files; return unless @$files; @@ -41,5 +37,17 @@ sub share_dir_map { } with 'Dist::Zilla::Role::ShareDir'; + +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { dir => $self->dir }; + + return $config; +}; + __PACKAGE__->meta->make_immutable; 1; diff --git a/lib/Dist/Zilla/Plugin/TemplateModule.pm b/lib/Dist/Zilla/Plugin/TemplateModule.pm index 6d0cf80fe..4a76da562 100644 --- a/lib/Dist/Zilla/Plugin/TemplateModule.pm +++ b/lib/Dist/Zilla/Plugin/TemplateModule.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::TemplateModule; use Moose; with qw(Dist::Zilla::Role::ModuleMaker Dist::Zilla::Role::TextTemplate); +use Dist::Zilla::Dialect; + use Dist::Zilla::Path; use namespace::autoclean; @@ -65,15 +67,13 @@ has template => ( predicate => 'has_template', ); -sub make_module { - my ($self, $arg) = @_; - +sub make_module ($self, $arg = {}){ my $template; if ($self->has_template) { $template = path( $self->template )->slurp_utf8; } else { - $template = ${ $self->section_data('Module.pm') }; + $template = $self->section_data('Module.pm')->$*; } my $content = $self->fill_in_string( diff --git a/lib/Dist/Zilla/Plugin/TestRelease.pm b/lib/Dist/Zilla/Plugin/TestRelease.pm index 5ca6ff656..a3e292597 100644 --- a/lib/Dist/Zilla/Plugin/TestRelease.pm +++ b/lib/Dist/Zilla/Plugin/TestRelease.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Plugin::TestRelease; use Moose; with 'Dist::Zilla::Role::BeforeRelease'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -26,8 +28,7 @@ This plugin was originally contributed by Christopher J. Madsen. use File::pushd (); use Dist::Zilla::Path; -sub before_release { - my ($self, $tgz) = @_; +sub before_release ($self, $tgz) { $tgz = $tgz->absolute; my $build_root = $self->zilla->root->child('.build'); diff --git a/lib/Dist/Zilla/Plugin/UploadToCPAN.pm b/lib/Dist/Zilla/Plugin/UploadToCPAN.pm index b07718724..df2426fbd 100644 --- a/lib/Dist/Zilla/Plugin/UploadToCPAN.pm +++ b/lib/Dist/Zilla/Plugin/UploadToCPAN.pm @@ -4,9 +4,13 @@ package Dist::Zilla::Plugin::UploadToCPAN; use Moose; with qw(Dist::Zilla::Role::BeforeRelease Dist::Zilla::Role::Releaser); -use File::Spec; use Moose::Util::TypeConstraints; + +use Dist::Zilla::Dialect; + +use File::Spec; use Scalar::Util qw(weaken); +use Dist::Zilla::Util; use Try::Tiny; use namespace::autoclean; @@ -46,9 +50,8 @@ You can't put your password in your F. C'mon now! # Report CPAN::Uploader's version, not ours: sub _ua_string { CPAN::Uploader->_ua_string } - sub log { - my $self = shift; - $self->{'Dist::Zilla'}{plugin}->log(@_); + sub log ($self, @rest) { + $self->{'Dist::Zilla'}{plugin}->log(@rest); } } @@ -71,12 +74,11 @@ has _credentials_stash_obj => ( isa => maybe_type( class_type('Dist::Zilla::Stash::PAUSE') ), lazy => 1, init_arg => undef, - default => sub { $_[0]->zilla->stash_named( $_[0]->credentials_stash ) }, + default => sub ($self, @) { + $self->zilla->stash_named( $self->credentials_stash ) }, ); -sub _credential { - my ($self, $name) = @_; - +sub _credential ($self, $name) { return unless my $stash = $self->_credentials_stash_obj; return $stash->$name; } @@ -97,8 +99,7 @@ has username => ( is => 'ro', isa => 'Str', lazy => 1, - default => sub { - my ($self) = @_; + default => sub ($self, @) { return $self->_credential('username') || $self->pause_cfg->{user} || $self->zilla->chrome->prompt_str("PAUSE username: "); @@ -120,8 +121,7 @@ has password => ( isa => 'Str', init_arg => undef, lazy => 1, - default => sub { - my ($self) = @_; + default => sub ($self, @) { my $pw = $self->_credential('password') || $self->pause_cfg->{password}; unless ($pw){ @@ -154,7 +154,7 @@ has pause_cfg_file => ( =attr pause_cfg_dir This is the directory for resolving a relative L. -It defaults to C<< File::HomeDir->my_home >>. +it defaults to the glob expansion of F<~>. =cut @@ -162,7 +162,7 @@ has pause_cfg_dir => ( is => 'ro', isa => 'Str', lazy => 1, - default => sub { require File::HomeDir; File::HomeDir::->my_home }, + default => sub { Dist::Zilla::Util->homedir }, ); =attr pause_cfg @@ -177,8 +177,7 @@ has pause_cfg => ( is => 'ro', isa => 'HashRef[Str]', lazy => 1, - default => sub { - my $self = shift; + default => sub ($self, @) { require CPAN::Uploader; my $file = $self->pause_cfg_file; $file = File::Spec->catfile($self->pause_cfg_dir, $file) @@ -225,9 +224,7 @@ has uploader => ( is => 'ro', isa => 'CPAN::Uploader', lazy => 1, - default => sub { - my ($self) = @_; - + default => sub ($self, @) { # Load the module lazily require CPAN::Uploader; CPAN::Uploader->VERSION('0.103004'); # require HTTPS @@ -248,9 +245,7 @@ has uploader => ( } ); -sub before_release { - my $self = shift; - +sub before_release ($self, $tgz) { my $problem; try { for my $attr (qw(username password)) { @@ -263,9 +258,7 @@ sub before_release { $self->log_fatal(['You need to supply a %s', $problem]) if $problem; } -sub release { - my ($self, $archive) = @_; - +sub release ($self, $archive) { $self->uploader->upload_file("$archive"); } diff --git a/lib/Dist/Zilla/PluginBundle/Basic.pm b/lib/Dist/Zilla/PluginBundle/Basic.pm index 096d4d8eb..b72655f31 100644 --- a/lib/Dist/Zilla/PluginBundle/Basic.pm +++ b/lib/Dist/Zilla/PluginBundle/Basic.pm @@ -4,11 +4,11 @@ package Dist::Zilla::PluginBundle::Basic; use Moose; with 'Dist::Zilla::Role::PluginBundle::Easy'; -use namespace::autoclean; +use Dist::Zilla::Dialect; -sub configure { - my ($self) = @_; +use namespace::autoclean; +sub configure ($self) { $self->add_plugins(qw( GatherDir PruneCruft diff --git a/lib/Dist/Zilla/PluginBundle/Classic.pm b/lib/Dist/Zilla/PluginBundle/Classic.pm index 97e9e7543..e17404efd 100644 --- a/lib/Dist/Zilla/PluginBundle/Classic.pm +++ b/lib/Dist/Zilla/PluginBundle/Classic.pm @@ -4,11 +4,11 @@ package Dist::Zilla::PluginBundle::Classic; use Moose; with 'Dist::Zilla::Role::PluginBundle::Easy'; -use namespace::autoclean; +use Dist::Zilla::Dialect; -sub configure { - my ($self) = @_; +use namespace::autoclean; +sub configure ($self) { $self->add_plugins(qw( GatherDir PruneCruft diff --git a/lib/Dist/Zilla/PluginBundle/FakeClassic.pm b/lib/Dist/Zilla/PluginBundle/FakeClassic.pm index 8d8ab1c61..9faa94e04 100644 --- a/lib/Dist/Zilla/PluginBundle/FakeClassic.pm +++ b/lib/Dist/Zilla/PluginBundle/FakeClassic.pm @@ -4,12 +4,12 @@ package Dist::Zilla::PluginBundle::FakeClassic; use Moose; extends 'Dist::Zilla::PluginBundle::Classic'; -use namespace::autoclean; +use Dist::Zilla::Dialect; -around bundle_config => sub { - my ($orig, $self, $arg) = @_; +use namespace::autoclean; - my @config = $self->$orig($arg); +around bundle_config => sub ($orig, $self, $arg, @rest) { + my @config = $self->$orig($arg, @rest); for my $i (0 .. $#config) { if ($config[ $i ][1] eq 'Dist::Zilla::Plugin::UploadToCPAN') { diff --git a/lib/Dist/Zilla/PluginBundle/Filter.pm b/lib/Dist/Zilla/PluginBundle/Filter.pm index 6c6e8d59b..a75cd8a04 100644 --- a/lib/Dist/Zilla/PluginBundle/Filter.pm +++ b/lib/Dist/Zilla/PluginBundle/Filter.pm @@ -4,6 +4,8 @@ package Dist::Zilla::PluginBundle::Filter; use Moose; with 'Dist::Zilla::Role::PluginBundle'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use List::Util 1.33 qw(any); @@ -45,14 +47,13 @@ Dist::Zilla roles: L. sub mvp_multivalue_args { qw(remove -remove) } -sub bundle_config { - my ($self, $section) = @_; +sub bundle_config ($self, $section) { my $class = (ref $self) || $self; my $config = {}; - my $has_filter_args = any { /^-/ } keys %{ $section->{payload} }; - for my $key (keys %{ $section->{payload} }) { + my $has_filter_args = any { /^-/ } keys $section->{payload}->%*; + for my $key (keys $section->{payload}->%*) { my $val = $section->{payload}->{$key}; my $target = $has_filter_args && ($key !~ /^-/) ? 'bundle' diff --git a/lib/Dist/Zilla/Prereqs.pm b/lib/Dist/Zilla/Prereqs.pm index 80efd75e4..0c6c75b86 100644 --- a/lib/Dist/Zilla/Prereqs.pm +++ b/lib/Dist/Zilla/Prereqs.pm @@ -2,6 +2,9 @@ package Dist::Zilla::Prereqs; # ABSTRACT: the prerequisites of a Dist::Zilla distribution use Moose; + +use Dist::Zilla::Dialect; + use MooseX::Types::Moose qw(Bool HashRef); use CPAN::Meta::Prereqs 2.120630; # add_string_requirement @@ -78,10 +81,9 @@ If not given, phase and type default to runtime and requires, respectively. =cut -sub register_prereqs { - my $self = shift; - my $arg = ref($_[0]) ? shift(@_) : {}; - my %prereq = @_; +sub register_prereqs ($self, @rest) { + my $arg = ref($rest[0]) ? shift(@rest) : {}; + my %prereq = @rest; my $phase = $arg->{phase} || 'runtime'; my $type = $arg->{type} || 'requires'; @@ -95,18 +97,14 @@ sub register_prereqs { return; } -before 'finalize' => sub { - my ($self) = @_; +before 'finalize' => sub ($self) { $self->sync_runtime_build_test_requires; }; - # this avoids a long-standing CPAN.pm bug that incorrectly merges runtime and # "build" (build+test) requirements by ensuring requirements stay unified # across all three phases -sub sync_runtime_build_test_requires { - my $self = shift; - +sub sync_runtime_build_test_requires ($self) { # first pass: generated merged requirements for my $phase ( qw/runtime build test/ ) { my $req = $self->requirements_for($phase, 'requires'); diff --git a/lib/Dist/Zilla/Role/AfterBuild.pm b/lib/Dist/Zilla/Role/AfterBuild.pm index 9be779a51..3c19d0f9f 100644 --- a/lib/Dist/Zilla/Role/AfterBuild.pm +++ b/lib/Dist/Zilla/Role/AfterBuild.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::AfterBuild; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/AfterMint.pm b/lib/Dist/Zilla/Role/AfterMint.pm index 7cca7eb62..111e37ebf 100644 --- a/lib/Dist/Zilla/Role/AfterMint.pm +++ b/lib/Dist/Zilla/Role/AfterMint.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::AfterMint; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/BeforeArchive.pm b/lib/Dist/Zilla/Role/BeforeArchive.pm index 80856efd4..8005d4858 100644 --- a/lib/Dist/Zilla/Role/BeforeArchive.pm +++ b/lib/Dist/Zilla/Role/BeforeArchive.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::BeforeArchive; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/BeforeBuild.pm b/lib/Dist/Zilla/Role/BeforeBuild.pm index f86dc8903..89066b243 100644 --- a/lib/Dist/Zilla/Role/BeforeBuild.pm +++ b/lib/Dist/Zilla/Role/BeforeBuild.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::BeforeBuild; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/BeforeMint.pm b/lib/Dist/Zilla/Role/BeforeMint.pm index 87c9b1ca7..580299739 100644 --- a/lib/Dist/Zilla/Role/BeforeMint.pm +++ b/lib/Dist/Zilla/Role/BeforeMint.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::BeforeMint; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/BeforeRelease.pm b/lib/Dist/Zilla/Role/BeforeRelease.pm index 0098cd808..78f69c243 100644 --- a/lib/Dist/Zilla/Role/BeforeRelease.pm +++ b/lib/Dist/Zilla/Role/BeforeRelease.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::BeforeRelease; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/BuildPL.pm b/lib/Dist/Zilla/Role/BuildPL.pm index c7ea2cac5..a3d811e92 100644 --- a/lib/Dist/Zilla/Role/BuildPL.pm +++ b/lib/Dist/Zilla/Role/BuildPL.pm @@ -2,13 +2,14 @@ package Dist::Zilla::Role::BuildPL; # ABSTRACT: Common ground for Build.PL based builders use Moose::Role; - with qw( Dist::Zilla::Role::InstallTool Dist::Zilla::Role::BuildRunner Dist::Zilla::Role::TestRunner ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -20,9 +21,7 @@ and L roles yourself. =cut -sub build { - my $self = shift; - +sub build ($self) { return if -e 'Build' and (stat 'Build.PL')[9] <= (stat 'Build')[9]; @@ -35,9 +34,7 @@ sub build { return; } -sub test { - my ($self, $target, $arg) = @_; - +sub test ($self, $target, $arg = {}) { $self->build; my $job_count = $arg && exists $arg->{jobs} diff --git a/lib/Dist/Zilla/Role/ExecFiles.pm b/lib/Dist/Zilla/Role/ExecFiles.pm index 957c5bca6..2f1ebc1fd 100644 --- a/lib/Dist/Zilla/Role/ExecFiles.pm +++ b/lib/Dist/Zilla/Role/ExecFiles.pm @@ -4,18 +4,15 @@ package Dist::Zilla::Role::ExecFiles; use Moose::Role; with 'Dist::Zilla::Role::FileFinder'; +use Dist::Zilla::Dialect; + use namespace::autoclean; requires 'dir'; -sub find_files { - my ($self) = @_; - +sub find_files ($self) { my $dir = $self->dir; - my $files = [ - grep { index($_->name, "$dir/") == 0 } - @{ $self->zilla->files } - ]; + return [ grep { index($_->name, "$dir/") == 0 } $self->zilla->files->@* ]; } 1; diff --git a/lib/Dist/Zilla/Role/File.pm b/lib/Dist/Zilla/Role/File.pm index 6ea9d7175..986a73255 100644 --- a/lib/Dist/Zilla/Role/File.pm +++ b/lib/Dist/Zilla/Role/File.pm @@ -3,8 +3,11 @@ package Dist::Zilla::Role::File; use Moose::Role; -use Dist::Zilla::Types qw(_Filename); use Moose::Util::TypeConstraints; + +use Dist::Zilla::Dialect; + +use Dist::Zilla::Types qw(_Filename); use Try::Tiny; use namespace::autoclean; @@ -49,21 +52,16 @@ has added_by => ( }, ); -around name => sub { - my $orig = shift; - my $self = shift; - if (@_) { +around name => sub ($orig, $self, @rest) { + if (@rest) { my ($pkg, $line) = $self->_caller_of('name'); $self->_push_added_by(sprintf("filename set by %s (%s line %s)", $self->_caller_plugin_name, $pkg, $line)); } - return $self->$orig(@_); + return $self->$orig(@rest); }; -sub _caller_of { - my ($self, $function) = @_; - - for (my $level = 1; $level < 50; ++$level) - { +sub _caller_of ($self, $function) { + for (my $level = 1; $level < 50; ++$level) { my @frame = caller($level); last if not defined $frame[0]; return ( (caller($level))[0,2] ) if $frame[3] =~ m/::${function}$/; @@ -71,11 +69,8 @@ sub _caller_of { return 'unknown', '0'; } -sub _caller_plugin_name { - my $self = shift; - - for (my $level = 1; $level < 50; ++$level) - { +sub _caller_plugin_name ($self) { + for (my $level = 1; $level < 50; ++$level) { my @frame = caller($level); last if not defined $frame[0]; return $1 if $frame[0] =~ m/^Dist::Zilla::Plugin::(.+)$/; @@ -113,28 +108,23 @@ C will be an error. =cut -sub is_bytes { - my ($self) = @_; - return $self->encoding eq 'bytes'; +sub is_bytes ($self) { + return $self->encoding eq 'bytes'; } -sub _encode { - my ($self, $text) = @_; +sub _encode ($self, $text) { my $enc = $self->encoding; - if ( $self->is_bytes ) { + if ($self->is_bytes) { return $text; # XXX hope you were right that it really was bytes - } - else { + } else { require Encode; - my $bytes = - try { Encode::encode($enc, $text, Encode::FB_CROAK()) } - catch { $self->_throw("encode $enc" => $_) }; + my $bytes = try { Encode::encode($enc, $text, Encode::FB_CROAK()) } + catch { $self->_throw("encode $enc" => $_) }; return $bytes; } } -sub _decode { - my ($self, $bytes) = @_; +sub _decode ($self, $bytes) { my $enc = $self->encoding; if ( $self->is_bytes ) { $self->_throw(decode => "Can't decode text from 'bytes' encoding"); @@ -163,8 +153,7 @@ sub _decode { } } -sub _throw { - my ($self, $op, $msg) = @_; +sub _throw ($self, $op, $msg) { my ($name, $added_by) = map {; $self->$_ } qw/name added_by/; confess( "Could not $op $name; $added_by; error was: $msg; maybe you need the [Encoding] plugin to specify an encoding" diff --git a/lib/Dist/Zilla/Role/FileFinder.pm b/lib/Dist/Zilla/Role/FileFinder.pm index c21857169..4263652f4 100644 --- a/lib/Dist/Zilla/Role/FileFinder.pm +++ b/lib/Dist/Zilla/Role/FileFinder.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::FileFinder; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/FileFinderUser.pm b/lib/Dist/Zilla/Role/FileFinderUser.pm index 214b97f99..8dc02eaad 100644 --- a/lib/Dist/Zilla/Role/FileFinderUser.pm +++ b/lib/Dist/Zilla/Role/FileFinderUser.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Role::FileFinderUser; use MooseX::Role::Parameterized 1.01; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -18,7 +20,7 @@ Here's an example of a finder: ( taken from AutoPrereqs ) Then you use it in your code like this: - foreach my $file ( @{ $self->found_files }) { + foreach my $file ($self->found_files->@*) { # $file is an object! Look at L } @@ -120,20 +122,16 @@ parameter method => ( role { my ($p) = @_; - my ($finder_arg, @finder_arg_aliases) = @{ $p->finder_arg_names }; + my ($finder_arg, @finder_arg_aliases) = $p->finder_arg_names->@*; confess "no finder arg names given!" unless $finder_arg; - around mvp_multivalue_args => sub { - my ($orig, $self) = @_; - + around mvp_multivalue_args => sub ($orig, $self) { my @start = $self->$orig; return (@start, $finder_arg); }; if (@finder_arg_aliases) { - around mvp_aliases => sub { - my ($orig, $self) = @_; - + around mvp_aliases => sub ($orig, $self) { my $start = $self->$orig; for my $alias (@finder_arg_aliases) { @@ -149,14 +147,12 @@ role { has $finder_arg => ( is => 'ro', isa => 'ArrayRef[Str]', - default => sub { [ @{ $p->default_finders } ] }, + default => sub { [ $p->default_finders->@* ] }, ); - method $p->method => sub { - my ($self) = @_; - + method $p->method => sub ($self) { my @filesets = map {; $self->zilla->find_files($_) } - @{ $self->$finder_arg }; + $self->$finder_arg->@*; my %by_name = map {; $_->name, $_ } map { @$_ } @filesets; diff --git a/lib/Dist/Zilla/Role/FileGatherer.pm b/lib/Dist/Zilla/Role/FileGatherer.pm index 79187fd03..8a9ec3fbe 100644 --- a/lib/Dist/Zilla/Role/FileGatherer.pm +++ b/lib/Dist/Zilla/Role/FileGatherer.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::FileGatherer; use Moose::Role; with qw/Dist::Zilla::Role::Plugin Dist::Zilla::Role::FileInjector/; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/FileInjector.pm b/lib/Dist/Zilla/Role/FileInjector.pm index 276008204..5fbac4236 100644 --- a/lib/Dist/Zilla/Role/FileInjector.pm +++ b/lib/Dist/Zilla/Role/FileInjector.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Role::FileInjector; use Moose::Role; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -29,7 +31,7 @@ sub add_file { ); $self->log_debug([ 'adding file %s', $file->name ]); - push @{ $self->zilla->files }, $file; + push $self->zilla->files->@*, $file; } 1; diff --git a/lib/Dist/Zilla/Role/FileMunger.pm b/lib/Dist/Zilla/Role/FileMunger.pm index 17c0a0c10..0150d2e73 100644 --- a/lib/Dist/Zilla/Role/FileMunger.pm +++ b/lib/Dist/Zilla/Role/FileMunger.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::FileMunger; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -23,13 +25,11 @@ C method. =cut -sub munge_files { - my ($self) = @_; - +sub munge_files ($self) { $self->log_fatal("no munge_file behavior implemented!") unless $self->can('munge_file'); - my @files = @{ $self->zilla->files }; + my @files = $self->zilla->files->@*; for my $file ( @files ) { if ($file->is_bytes) { $self->log_debug($file->name . " has 'bytes' encoding, skipping..."); diff --git a/lib/Dist/Zilla/Role/FilePruner.pm b/lib/Dist/Zilla/Role/FilePruner.pm index 48823eefe..cde97c8f7 100644 --- a/lib/Dist/Zilla/Role/FilePruner.pm +++ b/lib/Dist/Zilla/Role/FilePruner.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::FilePruner; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/InstallTool.pm b/lib/Dist/Zilla/Role/InstallTool.pm index cfe41e34f..d4bfe5244 100644 --- a/lib/Dist/Zilla/Role/InstallTool.pm +++ b/lib/Dist/Zilla/Role/InstallTool.pm @@ -7,6 +7,8 @@ with qw( Dist::Zilla::Role::FileInjector ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/LicenseProvider.pm b/lib/Dist/Zilla/Role/LicenseProvider.pm index 854c7212e..713ea20d3 100644 --- a/lib/Dist/Zilla/Role/LicenseProvider.pm +++ b/lib/Dist/Zilla/Role/LicenseProvider.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::LicenseProvider; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + =head1 DESCRIPTION Plugins implementing this role must provide a C method that @@ -15,7 +17,12 @@ ignored. =head1 REQUIRED METHODS -=head2 C<< provide_license({ copyright_holder => $holder, copyright_year => $year }) >> +=head2 provide_license + + $plugin->provide_license({ + copyright_holder => $holder, + copyright_year => $year, + }); Generate license object. Returned object should be an instance of L. diff --git a/lib/Dist/Zilla/Role/MetaProvider.pm b/lib/Dist/Zilla/Role/MetaProvider.pm index 08dd78f85..2c05e007d 100644 --- a/lib/Dist/Zilla/Role/MetaProvider.pm +++ b/lib/Dist/Zilla/Role/MetaProvider.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::MetaProvider; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/MintingProfile.pm b/lib/Dist/Zilla/Role/MintingProfile.pm index 1e827e534..b86c106b9 100644 --- a/lib/Dist/Zilla/Role/MintingProfile.pm +++ b/lib/Dist/Zilla/Role/MintingProfile.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Role::MintingProfile; use Moose::Role; +use Dist::Zilla::Dialect; + use namespace::autoclean; use Dist::Zilla::Path; @@ -29,9 +31,8 @@ based on your profile with the: requires 'profile_dir'; -around profile_dir => sub { - my ($orig, $self, @args) = @_; - path($self->$orig(@args)); +around profile_dir => sub ($orig, $self, @rest) { + path($self->$orig(@rest)); }; 1; diff --git a/lib/Dist/Zilla/Role/MintingProfile/ShareDir.pm b/lib/Dist/Zilla/Role/MintingProfile/ShareDir.pm index a2f33e4d9..85afe7a99 100644 --- a/lib/Dist/Zilla/Role/MintingProfile/ShareDir.pm +++ b/lib/Dist/Zilla/Role/MintingProfile/ShareDir.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::MintingProfile::ShareDir; use Moose::Role; with 'Dist::Zilla::Role::MintingProfile'; +use Dist::Zilla::Dialect; + use namespace::autoclean; use File::ShareDir; @@ -16,9 +18,7 @@ C method that looks in the I's L. =cut -sub profile_dir { - my ($self, $profile_name) = @_; - +sub profile_dir ($self, $profile_name) { my $profile_dir = path( File::ShareDir::module_dir($self->meta->name) ) ->child( $profile_name ); diff --git a/lib/Dist/Zilla/Role/ModuleMaker.pm b/lib/Dist/Zilla/Role/ModuleMaker.pm index 343c297fb..60884e3a2 100644 --- a/lib/Dist/Zilla/Role/ModuleMaker.pm +++ b/lib/Dist/Zilla/Role/ModuleMaker.pm @@ -7,6 +7,8 @@ with qw( Dist::Zilla::Role::FileInjector ); +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/MutableFile.pm b/lib/Dist/Zilla/Role/MutableFile.pm index 97389e596..cb383fc52 100644 --- a/lib/Dist/Zilla/Role/MutableFile.pm +++ b/lib/Dist/Zilla/Role/MutableFile.pm @@ -4,9 +4,13 @@ package Dist::Zilla::Role::MutableFile; use Moose::Role; use Moose::Util::TypeConstraints; -use MooseX::SetOnce; + +use Dist::Zilla::Dialect; + use namespace::autoclean; +use MooseX::SetOnce; + =head1 DESCRIPTION This role describes a file whose contents may be modified @@ -42,24 +46,21 @@ has _content => ( predicate => 'has_content', ); -sub content { - my $self = shift; - if ( ! @_ ) { +sub content ($self, @rest) { + if ( ! @rest ) { # if we have it or we're tasked to provide it, return it (possibly lazily # generated from a builder); otherwise, get it from the encoded_content if ( $self->has_content || $self->_content_source eq 'content' ) { return $self->_content; - } - else { + } else { return $self->_content($self->_decode($self->encoded_content)); } - } - else { + } else { my ($pkg, $line) = $self->_caller_of('content'); $self->_content_source('content'); $self->_push_added_by(sprintf("content set by %s (%s line %s)", $self->_caller_plugin_name, $pkg, $line)); $self->clear_encoded_content; - return $self->_content(@_); + return $self->_content(@rest); } } @@ -76,9 +77,8 @@ has _encoded_content => ( predicate => 'has_encoded_content', ); -sub encoded_content { - my $self = shift; - if ( ! @_ ) { +sub encoded_content ($self, @rest) { + if ( ! @rest ) { # if we have it or we're tasked to provide it, return it (possibly lazily # generated from a builder); otherwise, get it from the content if ($self->has_encoded_content || $self->_content_source eq 'encoded_content') { @@ -92,7 +92,7 @@ sub encoded_content { $self->_content_source('encoded_content'); $self->_push_added_by(sprintf("encoded_content set by %s (%s line %s)", $self->_caller_plugin_name, $pkg, $line)); $self->clear_content; - $self->_encoded_content(@_); + $self->_encoded_content(@rest); } has _content_source => ( @@ -102,8 +102,7 @@ has _content_source => ( builder => '_build_content_source', ); -sub _set_added_by { - my ($self, $value) = @_; +sub _set_added_by ($self, $value) { return $self->_push_added_by(sprintf("%s added by %s", $self->_content_source, $value)); }; diff --git a/lib/Dist/Zilla/Role/PPI.pm b/lib/Dist/Zilla/Role/PPI.pm index 369b3b630..43857e0d1 100644 --- a/lib/Dist/Zilla/Role/PPI.pm +++ b/lib/Dist/Zilla/Role/PPI.pm @@ -2,9 +2,13 @@ package Dist::Zilla::Role::PPI; # ABSTRACT: a role for plugins which use PPI use Moose::Role; -use Digest::MD5 qw(md5); + +use Dist::Zilla::Dialect; + use namespace::autoclean; +use Digest::MD5 qw(md5); + =head1 DESCRIPTION This role provides some common utilities for plugins which use L. @@ -23,9 +27,7 @@ document for the same file, this avoids reparsing it. my %CACHE; -sub ppi_document_for_file { - my ($self, $file) = @_; - +sub ppi_document_for_file ($self, $file) { my $encoded_content = $file->encoded_content; # We cache on the MD5 checksum to detect if the document has been modified @@ -54,9 +56,7 @@ It also updates the internal PPI document cache with the new document. =cut -sub save_ppi_document_to_file { - my ($self, $document, $file) = @_; - +sub save_ppi_document_to_file ($self, $document, $file) { my $new_content = $document->serialize; $file->content($new_content); @@ -75,18 +75,14 @@ sigil must be included). =cut -sub document_assigns_to_variable { - my ($self, $document, $variable) = @_; - +sub document_assigns_to_variable ($self, $document, $variable) { my $package_stmts = $document->find('PPI::Statement::Package'); - my @namespaces = map { $_->namespace } @{ $package_stmts || []}; + my @namespaces = map { $_->namespace } $package_stmts->@*; my ($sigil, $varname) = ($variable =~ m'^([$@%*])(.+)$'); my $package; - my $finder = sub { - my $node = $_[1]; - + my $finder = sub ($top, $node) { if ($node->isa('PPI::Statement') && !$node->isa('PPI::Statement::End') && !$node->isa('PPI::Statement::Data')) { diff --git a/lib/Dist/Zilla/Role/Plugin.pm b/lib/Dist/Zilla/Role/Plugin.pm index 44888d523..d3a2c732e 100644 --- a/lib/Dist/Zilla/Role/Plugin.pm +++ b/lib/Dist/Zilla/Role/Plugin.pm @@ -4,11 +4,14 @@ package Dist::Zilla::Role::Plugin; use Moose::Role; with 'Dist::Zilla::Role::ConfigDumper'; -use Params::Util qw(_HASHLIKE); use Moose::Util::TypeConstraints 'class_type'; +use Dist::Zilla::Dialect; + use namespace::autoclean; +use Params::Util qw(_HASHLIKE); + =head1 DESCRIPTION The Plugin role should be applied to all plugin classes. It provides a few key @@ -51,9 +54,9 @@ has logger => ( is => 'ro', lazy => 1, handles => [ qw(log log_debug log_fatal) ], - default => sub { - $_[0]->zilla->chrome->logger->proxy({ - proxy_prefix => '[' . $_[0]->plugin_name . '] ', + default => sub ($self, @) { + $self->zilla->chrome->logger->proxy({ + proxy_prefix => '[' . $self->plugin_name . '] ', }); }, ); @@ -63,9 +66,7 @@ has logger => ( sub mvp_multivalue_args {}; sub mvp_aliases { return {} }; -sub plugin_from_config { - my ($class, $name, $arg, $section) = @_; - +sub plugin_from_config ($class, $name, $arg, $section) { my $self = $class->new({ %$arg, plugin_name => $name, @@ -73,18 +74,27 @@ sub plugin_from_config { }); } -sub register_component { - my ($class, $name, $arg, $section) = @_; - +sub register_component ($class, $name, $arg, $section) { my $self = $class->plugin_from_config($name, $arg, $section); my $version = $self->VERSION || 0; $self->log_debug([ 'online, %s v%s', $self->meta->name, $version ]); - push @{ $self->zilla->plugins }, $self; + $self->zilla->_add_plugin($self); return; } +around dump_config => sub { + my ($orig, $self) = @_; + my $config = $self->$orig; + + $config->{'' . __PACKAGE__} = { + version => $self->VERSION, + }; + + return $config; +}; + 1; diff --git a/lib/Dist/Zilla/Role/PluginBundle.pm b/lib/Dist/Zilla/Role/PluginBundle.pm index e8b4bd1b8..a1dd073d2 100644 --- a/lib/Dist/Zilla/Role/PluginBundle.pm +++ b/lib/Dist/Zilla/Role/PluginBundle.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Role::PluginBundle; use Moose::Role; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -14,8 +16,7 @@ configure the bundle. =cut -sub register_component { - my ($class, $name, $arg, $self) = @_; +sub register_component ($class, $name, $arg, $self) { # ... we should register a placeholder so MetaConfig can tell us about the # pluginbundle that was loaded } diff --git a/lib/Dist/Zilla/Role/PluginBundle/Easy.pm b/lib/Dist/Zilla/Role/PluginBundle/Easy.pm index a593bb8c4..e5bbc3827 100644 --- a/lib/Dist/Zilla/Role/PluginBundle/Easy.pm +++ b/lib/Dist/Zilla/Role/PluginBundle/Easy.pm @@ -5,6 +5,8 @@ package Dist::Zilla::Role::PluginBundle::Easy; use Moose::Role; with 'Dist::Zilla::Role::PluginBundle'; +use Dist::Zilla::Dialect; + use Module::Runtime 'use_module'; use namespace::autoclean; @@ -88,19 +90,21 @@ C and C methods. =cut has plugins => ( - is => 'ro', isa => ArrayRef, default => sub { [] }, + reader => '_plugins', + traits => [ 'Array' ], + handles => { + plugins => 'elements', + }, ); -sub bundle_config { - my ($class, $section) = @_; - +sub bundle_config ($class, $section) { my $self = $class->new($section); $self->configure; - return @{ $self->plugins }; + return $self->plugins; } =method add_plugins @@ -122,11 +126,9 @@ The plugins are added to the config in the order given. =cut -sub add_plugins { - my ($self, @plugin_specs) = @_; - +sub add_plugins ($self, @plugin_specs) { my $prefix = $self->name . '/'; - my $plugins = $self->plugins; + my $plugins = $self->_plugins; foreach my $this_spec (@plugin_specs) { my $moniker; @@ -158,9 +160,7 @@ you omit C<%bundle_config>, an empty hashref will be supplied. =cut -sub add_bundle { - my ($self, $bundle, $payload) = @_; - +sub add_bundle ($self, $bundle, $payload) { my $package = _bundle_class($bundle); $payload ||= {}; @@ -171,7 +171,7 @@ sub add_bundle { $bundle = "\@$bundle" unless $bundle =~ /^@/; - push @{ $self->plugins }, + push $self->_plugins->@*, $package->bundle_config({ name => $self->name . '/' . $bundle, package => $package, @@ -194,14 +194,12 @@ key does not exist in C, then it is omitted from the result. =cut -sub config_slice { - my $self = shift; - +sub config_slice ($self, @rest) { my $payload = $self->payload; my %arg; - foreach my $arg (@_) { + foreach my $arg (@rest) { if (ref $arg) { while (my ($in, $out) = each %$arg) { $arg{$out} = $payload->{$in} if exists $payload->{$in}; diff --git a/lib/Dist/Zilla/Role/PrereqScanner.pm b/lib/Dist/Zilla/Role/PrereqScanner.pm index 382f10c31..c3dcb8199 100644 --- a/lib/Dist/Zilla/Role/PrereqScanner.pm +++ b/lib/Dist/Zilla/Role/PrereqScanner.pm @@ -23,7 +23,7 @@ with( }, ); -use MooseX::Types; +use Dist::Zilla::Dialect; =attr finder @@ -59,25 +59,22 @@ be registered as prerequisites. has skips => ( is => 'ro', isa => 'ArrayRef[Str]', + default => sub { [] }, ); -around mvp_multivalue_args => sub { - my ($orig, $self) = @_; +around mvp_multivalue_args => sub ($orig, $self) { ($self->$orig, 'skips') }; -around mvp_aliases => sub { - my ($orig, $self) = @_; + +around mvp_aliases => sub ($orig, $self) { my $aliases = $self->$orig; - $aliases->{skip} = 'skips'; + $aliases->{skip} = 'skips'; return $aliases }; - requires 'scan_file_reqs'; -sub scan_prereqs { - my $self = shift; - +sub scan_prereqs ($self) { require CPAN::Meta::Requirements; require List::Util; List::Util->VERSION(1.45); # uniq @@ -138,7 +135,7 @@ sub scan_prereqs { } # remove prereqs from skiplist - for my $skip (@{ $self->skips || [] }) { + for my $skip ($self->skips->@*) { my $re = qr/$skip/; foreach my $k ($req->required_modules) { @@ -158,7 +155,8 @@ sub scan_prereqs { $req->clear_requirement($_) for qw(Config DB Errno NEXT Pod::Functions); # never indexed # we're done, return what we've found - my %got = %{ $req->as_string_hash }; + my %got = $req->as_string_hash->%*; + if ($phase eq 'runtime') { %runtime_final = %got; } else { @@ -174,6 +172,20 @@ sub scan_prereqs { return \%reqs_by_phase } +requires 'dump_config'; # via Dist::Zilla::Role::Plugin +around dump_config => sub { + my $orig = shift; + my $self = shift; + + my $config = $self->$orig; + + $config->{+__PACKAGE__} = { + (map { $_ => [ sort @{ $self->$_ // [] } ] } qw(finder test_finder configure_finder skips)), + }; + + return $config; +}; + 1; __END__ diff --git a/lib/Dist/Zilla/Role/PrereqSource.pm b/lib/Dist/Zilla/Role/PrereqSource.pm index b41f4def7..cc4bbc861 100644 --- a/lib/Dist/Zilla/Role/PrereqSource.pm +++ b/lib/Dist/Zilla/Role/PrereqSource.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::PrereqSource; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/ReleaseStatusProvider.pm b/lib/Dist/Zilla/Role/ReleaseStatusProvider.pm index ffbca6e8a..a18cb0887 100644 --- a/lib/Dist/Zilla/Role/ReleaseStatusProvider.pm +++ b/lib/Dist/Zilla/Role/ReleaseStatusProvider.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::ReleaseStatusProvider; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/Releaser.pm b/lib/Dist/Zilla/Role/Releaser.pm index c7246b29d..629e83003 100644 --- a/lib/Dist/Zilla/Role/Releaser.pm +++ b/lib/Dist/Zilla/Role/Releaser.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::Releaser; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION diff --git a/lib/Dist/Zilla/Role/ShareDir.pm b/lib/Dist/Zilla/Role/ShareDir.pm index 995203c1f..c8b9118a5 100644 --- a/lib/Dist/Zilla/Role/ShareDir.pm +++ b/lib/Dist/Zilla/Role/ShareDir.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::ShareDir; use Moose::Role; with 'Dist::Zilla::Role::FileFinder'; +use Dist::Zilla::Dialect; + use namespace::autoclean; # Must return a hashref with any of the keys 'dist' and 'module'. The 'dist' diff --git a/lib/Dist/Zilla/Role/Stash.pm b/lib/Dist/Zilla/Role/Stash.pm index 444984950..e6944c0fd 100644 --- a/lib/Dist/Zilla/Role/Stash.pm +++ b/lib/Dist/Zilla/Role/Stash.pm @@ -3,11 +3,11 @@ package Dist::Zilla::Role::Stash; use Moose::Role; -use namespace::autoclean; +use Dist::Zilla::Dialect; -sub register_component { - my ($class, $name, $arg, $section) = @_; +use namespace::autoclean; +sub register_component ($class, $name, $arg, $section) { # $self->log_debug([ 'online, %s v%s', $self->meta->name, $version ]); my $entry = $class->stash_from_config($name, $arg, $section); @@ -16,9 +16,7 @@ sub register_component { return; } -sub stash_from_config { - my ($class, $name, $arg, $section) = @_; - +sub stash_from_config ($class, $name, $arg, $section) { my $self = $class->new($arg); return $self; } diff --git a/lib/Dist/Zilla/Role/TestRunner.pm b/lib/Dist/Zilla/Role/TestRunner.pm index 64c9061a8..5a513705f 100644 --- a/lib/Dist/Zilla/Role/TestRunner.pm +++ b/lib/Dist/Zilla/Role/TestRunner.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Role::TestRunner; use Moose::Role; with 'Dist::Zilla::Role::Plugin'; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -36,8 +38,7 @@ has default_jobs => ( default => 1, ); -around dump_config => sub { - my ($orig, $self) = @_; +around dump_config => sub ($orig, $self) { my $config = $self->$orig; $config->{'' . __PACKAGE__} = { default_jobs => $self->default_jobs }; diff --git a/lib/Dist/Zilla/Role/TextTemplate.pm b/lib/Dist/Zilla/Role/TextTemplate.pm index 2e535eaa6..672a136e7 100644 --- a/lib/Dist/Zilla/Role/TextTemplate.pm +++ b/lib/Dist/Zilla/Role/TextTemplate.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Role::TextTemplate; use Moose::Role; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 DESCRIPTION @@ -44,9 +46,7 @@ C routine. =cut -sub fill_in_string { - my ($self, $string, $stash, $arg) = @_; - +sub fill_in_string ($self, $string, $stash = {}, $arg = {}) { $self->log_fatal("Cannot use undef as a template string") unless defined $string; diff --git a/lib/Dist/Zilla/Stash/Mint.pm b/lib/Dist/Zilla/Stash/Mint.pm index 466c2eea9..992ed98c0 100644 --- a/lib/Dist/Zilla/Stash/Mint.pm +++ b/lib/Dist/Zilla/Stash/Mint.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Stash::Mint; use Moose; with 'Dist::Zilla::Role::Stash'; +use Dist::Zilla::Dialect; + use namespace::autoclean; has provider => ( diff --git a/lib/Dist/Zilla/Stash/PAUSE.pm b/lib/Dist/Zilla/Stash/PAUSE.pm index 5849fe290..b10227cf7 100644 --- a/lib/Dist/Zilla/Stash/PAUSE.pm +++ b/lib/Dist/Zilla/Stash/PAUSE.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Stash::PAUSE; use Moose; +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 OVERVIEW diff --git a/lib/Dist/Zilla/Stash/Rights.pm b/lib/Dist/Zilla/Stash/Rights.pm index 15d2f60b0..5ce8a0ef3 100644 --- a/lib/Dist/Zilla/Stash/Rights.pm +++ b/lib/Dist/Zilla/Stash/Rights.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Stash::Rights; use Moose; with 'Dist::Zilla::Role::Stash'; +use Dist::Zilla::Dialect; + use namespace::autoclean; has license_class => ( diff --git a/lib/Dist/Zilla/Stash/User.pm b/lib/Dist/Zilla/Stash/User.pm index 168331113..6d5f760ff 100644 --- a/lib/Dist/Zilla/Stash/User.pm +++ b/lib/Dist/Zilla/Stash/User.pm @@ -3,6 +3,8 @@ package Dist::Zilla::Stash::User; use Moose; +use Dist::Zilla::Dialect; + use namespace::autoclean; has name => ( @@ -17,9 +19,17 @@ has email => ( required => 1, ); -sub authors { - my ($self) = @_; - return [ sprintf "%s <%s>", $self->name, $self->email ]; +sub authors ($self) { + my $string = sprintf "%s <%s>", $self->name, $self->email; + return $string if wantarray; + + state %warned; + + my ($package, $pmfile, $line) = caller; + Carp::carp('in v7, $zilla->authors should only be called in list context; scalar context behavior will change in Dist::Zilla v8') + unless $warned{ $pmfile, $line }++; + + return [ $string ]; } with 'Dist::Zilla::Role::Stash::Authors'; diff --git a/lib/Dist/Zilla/Tester.pm b/lib/Dist/Zilla/Tester.pm index d3f4c2b00..8f788db90 100644 --- a/lib/Dist/Zilla/Tester.pm +++ b/lib/Dist/Zilla/Tester.pm @@ -4,6 +4,8 @@ package Dist::Zilla::Tester; use Moose; extends 'Dist::Zilla::Dist::Builder'; +use Dist::Zilla::Dialect; + # XXX: Adding this autoclean causes problem. "Builder" and "Minter" do not # show in tests. I'm really not sure why. -- rjbs, 2011-08-19 # use namespace::autoclean; @@ -25,9 +27,7 @@ use Sub::Exporter -setup => { groups => [ default => [ qw(Builder Minter) ] ], }; -sub from_config { - my ($self, @arg) = @_; - +sub from_config ($self, @arg) { # The only thing using a local time zone should be NextRelease. Normally it # defaults to "local," but since some users won't have an automatically # determinable time zone, we'll switch to not-local times for testing. @@ -47,6 +47,8 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } use Moose::Role; + use Dist::Zilla::Dialect; + has tempdir_root => ( is => 'rw', isa => 'Str|Undef', writer => '_set_tempdir_root', @@ -58,15 +60,12 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } ); sub DEMOLISH {} - around DEMOLISH => sub { - my $orig = shift; - my $self = shift; - + around DEMOLISH => sub ($orig, $self, @rest) { # File::Temp deletes the directory when it goes out of scope $self->_clear_tempdir_obj; rmdir $self->tempdir_root if $self->tempdir_root; - return $self->$orig(@_); + return $self->$orig(@rest); }; has tempdir => ( @@ -75,32 +74,25 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } init_arg => undef, ); - sub clear_log_events { - my ($self) = @_; + sub clear_log_events ($self) { $self->chrome->logger->clear_events; } - sub log_events { - my ($self) = @_; + sub log_events ($self) { $self->chrome->logger->events; } - sub log_messages { - my ($self) = @_; - [ map {; $_->{message} } @{ $self->chrome->logger->events } ]; + sub log_messages ($self) { + [ map {; $_->{message} } $self->chrome->logger->events->@* ]; } - sub slurp_file { - my ($self, $filename) = @_; - + sub slurp_file ($self, $filename) { Dist::Zilla::Path::path( $self->tempdir->child($filename) )->slurp_utf8; } - sub slurp_file_raw { - my ($self, $filename) = @_; - + sub slurp_file_raw ($self, $filename) { Dist::Zilla::Path::path( $self->tempdir->child($filename) )->slurp_raw; @@ -118,17 +110,17 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } extends 'Dist::Zilla::Dist::Builder'; with 'Dist::Zilla::Tester::_Role'; + use Dist::Zilla::Dialect; + use File::Copy::Recursive 0.41 qw(dircopy); use Dist::Zilla::Path; our $Log_Events = []; sub most_recent_log_events { - return @{ $Log_Events } + return @$Log_Events; } - around from_config => sub { - my ($orig, $self, $arg, $tester_arg) = @_; - + around from_config => sub ($orig, $self, $arg = {}, $tester_arg = {}) { confess "dist_root required for from_config" unless $arg->{dist_root}; my $source = $arg->{dist_root}; @@ -152,7 +144,7 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } dircopy($source, $root); if ($tester_arg->{also_copy}) { - while (my ($src, $dest) = each %{ $tester_arg->{also_copy} }) { + while (my ($src, $dest) = each $tester_arg->{also_copy}->%*) { dircopy($src, $tempdir->child($dest)); } } @@ -202,13 +194,7 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } return $zilla; }; - around build_in => sub { - my ($orig, $self, $target) = @_; - - # XXX: We *must eliminate* the need for this! It's only here because right - # now building a dist with (root <> cwd) doesn't work. -- rjbs, 2010-03-08 - my $wd = File::pushd::pushd($self->root); - + around build_in => sub ($orig, $self, $target = undef) { $target ||= do { my $target = path($self->tempdir)->child('build'); $target->mkpath; @@ -218,13 +204,7 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } return $self->$orig($target); }; - around ['test', 'release'] => sub { - my ($orig, $self) = @_; - - # XXX: We *must eliminate* the need for this! It's only here because right - # now building a dist with (root <> cwd) doesn't work. -- rjbs, 2010-03-08 - my $wd = File::pushd::pushd($self->root); - + around ['test', 'release'] => sub ($orig, $self) { return $self->$orig; }; @@ -256,17 +236,17 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } extends 'Dist::Zilla::Dist::Minter'; with 'Dist::Zilla::Tester::_Role'; + use Dist::Zilla::Dialect; + use File::Copy::Recursive 0.41 qw(dircopy); use Dist::Zilla::Path; our $Log_Events = []; sub most_recent_log_events { - return @{ $Log_Events } + return @$Log_Events; } - sub _mint_target_dir { - my ($self) = @_; - + sub _mint_target_dir ($self) { my $name = $self->name; my $dir = $self->tempdir->child('mint')->absolute; @@ -275,9 +255,7 @@ sub minter { 'Dist::Zilla::Tester::_Minter' } return $dir; } - sub _setup_global_config { - my ($self, $dir, $arg) = @_; - + sub _setup_global_config ($self, $dir, $arg) { my $config_base = path($dir)->child('config'); my $stash_registry = {}; diff --git a/lib/Dist/Zilla/Types.pm b/lib/Dist/Zilla/Types.pm index 3b2d6bfcc..a1c88d5da 100644 --- a/lib/Dist/Zilla/Types.pm +++ b/lib/Dist/Zilla/Types.pm @@ -1,6 +1,8 @@ package Dist::Zilla::Types; # ABSTRACT: dzil-specific type library +use Dist::Zilla::Dialect; + use namespace::autoclean; =head1 OVERVIEW @@ -17,6 +19,7 @@ use MooseX::Types -declare => [qw( License OneZero YesNoStr ReleaseStatus Path ArrayRefOfPaths _Filename + VersionStr )]; use MooseX::Types::Moose qw(Str Int Defined ArrayRef); use Path::Tiny; @@ -47,4 +50,10 @@ subtype _Filename, as Str, where { $_ !~ qr/(?:\x{0a}|\x{0b}|\x{0c}|\x{0d}|\x{85}|\x{2028}|\x{2029})/ }, message { "Filename not a Str, or contains a newline or other vertical whitespace" }; +use MooseX::Types::Perl qw(LaxVersionStr); +subtype VersionStr, as LaxVersionStr, + # non-decimal versions cannot use underscores + where { /_/ && (/^v/ || tr/././ > 1) ? 0 : 1 }, + message { 'Only decimal versions can contain underscores' }; + 1; diff --git a/lib/Dist/Zilla/Util.pm b/lib/Dist/Zilla/Util.pm index c1bb08574..deaf0f3e0 100644 --- a/lib/Dist/Zilla/Util.pm +++ b/lib/Dist/Zilla/Util.pm @@ -3,6 +3,8 @@ use warnings; package Dist::Zilla::Util; # ABSTRACT: random snippets of code that Dist::Zilla wants +use Dist::Zilla::Dialect; + use Carp (); use Encode (); @@ -19,15 +21,13 @@ use Encode (); bless {} => shift; } - sub handle_nonpod { - my ($self, $event) = @_; + sub handle_nonpod ($self, $event) { return if $self->{abstract}; return $self->{abstract} = $1 if $event->{content}=~ /^\s*#+\s*ABSTRACT:[ \t]*(\S.*)$/m; return; } - sub handle_event { - my ($self, $event) = @_; + sub handle_event ($self, $event) { return if $self->{abstract}; if ( ! $self->{in_name} @@ -102,13 +102,16 @@ sub expand_config_package_name { shift; goto &_expand_config_package_name } +sub homedir { + (glob('~'))[0]; +} + sub _global_config_root { require Dist::Zilla::Path; return Dist::Zilla::Path::path($ENV{DZIL_GLOBAL_CONFIG_ROOT}) if $ENV{DZIL_GLOBAL_CONFIG_ROOT}; - require File::HomeDir; - my $homedir = File::HomeDir->my_home - or Carp::croak("couldn't determine home directory"); + my $homedir = homedir(); + Carp::croak("couldn't determine home directory") if not $homedir; return Dist::Zilla::Path::path($homedir)->child('.dzil'); } diff --git a/lib/Dist/Zilla/Util/AuthorDeps.pm b/lib/Dist/Zilla/Util/AuthorDeps.pm index 359d6ed43..d736701a2 100644 --- a/lib/Dist/Zilla/Util/AuthorDeps.pm +++ b/lib/Dist/Zilla/Util/AuthorDeps.pm @@ -3,26 +3,23 @@ use warnings; package Dist::Zilla::Util::AuthorDeps; # ABSTRACT: Utils for listing your distribution's author dependencies +use Dist::Zilla::Dialect; + use Dist::Zilla::Util; use Path::Tiny; use List::Util 1.45 (); - -sub format_author_deps { - my ($reqs, $versions) = @_; - +sub format_author_deps ($reqs, $versions) { my $formatted = ''; - foreach my $rec (@{ $reqs }) { - my ($mod, $ver) = each(%{ $rec }); + foreach my $rec (@$reqs) { + my ($mod, $ver) = each %$rec; $formatted .= $versions ? "$mod = $ver\n" : "$mod\n"; } chomp($formatted); return $formatted; } -sub extract_author_deps { - my ($root, $missing) = @_; - +sub extract_author_deps ($root, $missing) { my $ini = path($root, 'dist.ini'); die "dzil authordeps only works on dist.ini files, and you don't have one\n" @@ -91,7 +88,7 @@ sub extract_author_deps { my $vermap = $reqs->as_string_hash; # Add the other requirements - push(@packages, sort keys %{ $vermap }); + push @packages, sort keys %$vermap; # Move inc:: first in list as they may impact the loading of other # plugins (in particular local ones). diff --git a/lib/Test/DZil.pm b/lib/Test/DZil.pm index 5d9a8e91f..24e13c9f1 100644 --- a/lib/Test/DZil.pm +++ b/lib/Test/DZil.pm @@ -3,6 +3,8 @@ use warnings; package Test::DZil; # ABSTRACT: tools for testing Dist::Zilla plugins +use Dist::Zilla::Dialect; + use Params::Util qw(_HASH0); use JSON::MaybeXS; use Scalar::Util qw(blessed); @@ -60,9 +62,7 @@ do L. =cut -sub is_filelist { - my ($have, $want, $comment) = @_; - +sub is_filelist ($have, $want, $comment = undef) { my @want = @$want; my @have = map { my $str = (blessed $_ and $_->DOES('Dist::Zilla::Role::File')) @@ -83,9 +83,7 @@ C>. =cut -sub is_yaml { - my ($yaml, $want, $comment) = @_; - +sub is_yaml ($yaml, $want, $comment = undef) { my $have = YAML::Tiny->read_string($yaml) or die "Cannot decode YAML"; @@ -102,9 +100,7 @@ C>. =cut -sub is_json { - my ($json, $want, $comment) = @_; - +sub is_json ($json, $want, $comment = undef) { my $have = JSON::MaybeXS->new(ascii => 1)->decode($json) or die "Cannot decode JSON"; @@ -112,10 +108,7 @@ sub is_json { Test::Deep::cmp_deeply($have, $want, $comment); } -sub _build_ini_builder { - my ($starting_core) = @_; - $starting_core ||= {}; - +sub _build_ini_builder ($starting_core = {}) { sub { my (@arg) = @_; my $new_core = _HASH0($arg[0]) ? shift(@arg) : {}; @@ -126,7 +119,7 @@ sub _build_ini_builder { for my $key (sort keys %$core_config) { my @values = ref $core_config->{ $key } - ? @{ $core_config->{ $key } } + ? $core_config->{ $key }->@* : $core_config->{ $key }; $config .= "$key = $_\n" for grep {defined} @values; @@ -148,7 +141,7 @@ sub _build_ini_builder { for my $key (sort keys %$payload) { my @values = ref $payload->{ $key } - ? @{ $payload->{ $key } } + ? $payload->{ $key }->@* : $payload->{ $key }; $config .= "$key = $_\n" for grep {defined} @values; diff --git a/t/commands/authordeps.t b/t/commands/authordeps.t index eb46dca6b..33c78b6d8 100644 --- a/t/commands/authordeps.t +++ b/t/commands/authordeps.t @@ -21,7 +21,7 @@ cmp_deeply( +{ 'Foo::Bar' => '1.23' }, +{ 'Dist::Zilla' => '5.001' }, ( map { +{"Dist::Zilla::Plugin::$_" => '5.0'} } qw ), - ( map { +{"Dist::Zilla::Plugin::$_" => 0} } qw ), + ( map { +{"Dist::Zilla::Plugin::$_" => 0} } qw ), +{ 'Software::License::Perl_5' => '0' }, ], "authordeps in corpus/dist/AuthorDeps" diff --git a/t/commands/listdeps.t b/t/commands/listdeps.t index 341f5c390..131ae333a 100644 --- a/t/commands/listdeps.t +++ b/t/commands/listdeps.t @@ -3,6 +3,7 @@ use warnings; use Test::More 0.88; use Test::Deep; +use Dist::Zilla::Dialect; use Dist::Zilla::App::Tester; # see also t/plugins/autoprereqs.t @@ -60,7 +61,7 @@ for my $how ( my $map = $how->[1]; my $desc = @opt ? "@opt" : "default"; - my $make_bag = sub { bag(map {; $map->() } grep {; $_ ne 'perl' } @_) }; + my sub nonperl_bag { bag(map {; $map->() } grep {; $_ ne 'perl' } @_) }; subtest "$desc output" => sub { { @@ -71,7 +72,7 @@ for my $how ( cmp_deeply( [ split("\n", $output) ], - $make_bag->(@default_prereqs), + nonperl_bag(@default_prereqs), "all prereqs listed as output", ); } @@ -84,7 +85,7 @@ for my $how ( cmp_deeply( [ split("\n", $output) ], - $make_bag->(keys %{$prereqs{recommends}}), + nonperl_bag(keys %{$prereqs{recommends}}), "no recommended prereqs listed as output, --no-requires", ); } @@ -97,7 +98,7 @@ for my $how ( cmp_deeply( [ split("\n", $output) ], - $make_bag->(keys %{$prereqs{requires}}), + nonperl_bag(keys %{$prereqs{requires}}), 'no recommended prereqs listed as output, --no-recommends', ); } @@ -110,7 +111,7 @@ for my $how ( cmp_deeply( [ split("\n", $output) ], - $make_bag->(@default_prereqs, keys %{$prereqs{suggests}}), + nonperl_bag(@default_prereqs, keys %{$prereqs{suggests}}), 'no recommended prereqs listed as output, --suggests', ); } @@ -123,7 +124,7 @@ for my $how ( cmp_deeply( [ split("\n", $output) ], - $make_bag->('String::Formatter', @default_prereqs), + nonperl_bag('String::Formatter', @default_prereqs), 'develop prereqs included in output for ' . $arg, ); } diff --git a/t/file.t b/t/file.t index 5947903ef..d39376d75 100644 --- a/t/file.t +++ b/t/file.t @@ -40,7 +40,8 @@ my $tzil = Builder->from_config( { # this trickery is so the caller appears to be whatever called new_file() - my $gatherdir = first { $_->isa('Dist::Zilla::Plugin::GatherDir') } @{ $tzil->plugins }; + my $gatherdir = first { $_->isa('Dist::Zilla::Plugin::GatherDir') } + $tzil->plugins; my $add_file = $gatherdir->can('add_file'); my $i = 0; diff --git a/t/lib/Dist/Zilla/Stash/Heap.pm b/t/lib/Dist/Zilla/Stash/Heap.pm index dd74b8234..756758189 100644 --- a/t/lib/Dist/Zilla/Stash/Heap.pm +++ b/t/lib/Dist/Zilla/Stash/Heap.pm @@ -9,14 +9,11 @@ has payload => ( required => 1, ); -sub value { - my ($self, $name) = @_; +sub value ($self, $name) { $self->payload->{ $name }; } -sub stash_from_config { - my ($class, $name, $arg, $section) = @_; - +sub stash_from_config ($class, $name, $arg, $section) { my $self = $class->new({ payload => $arg }); return $self; } diff --git a/t/plugins/autoprereqs.t b/t/plugins/autoprereqs.t index 3f5977036..1287bbeec 100644 --- a/t/plugins/autoprereqs.t +++ b/t/plugins/autoprereqs.t @@ -63,6 +63,7 @@ $tzil = Builder->from_config( qw(GatherDir ExecDir), [ AutoPrereqs => { skip => '^DZPA::Skip', configure_finder => ':IncModules' } ], + [ MetaConfig => ], ), 'source/inc/DZPA.pm' => "use DZPA::NotInDist;\n use DZPA::Configure;\n", }, @@ -178,6 +179,7 @@ $tzil = Builder->from_config( 'source/dist.ini' => simple_ini( qw(GatherDir ExecDir), [ AutoPrereqs => { scanner => 'Perl5', extra_scanner => 'Aliased' } ], + [ MetaConfig => ], ), 'source/lib/DZPA/Aliased.pm' => "use aliased 'Long::Class::Name';\n", }, diff --git a/t/plugins/autoversion.t b/t/plugins/autoversion.t index a4e4c6d90..bd252d48b 100644 --- a/t/plugins/autoversion.t +++ b/t/plugins/autoversion.t @@ -16,6 +16,7 @@ delete $ENV{V}; { version => undef }, 'GatherDir', [ AutoVersion => { major => 6, format => '{{$major}}.{{$^T}}' } ], + [ MetaConfig => ], ), }, }, diff --git a/t/plugins/confirmrelease.t b/t/plugins/confirmrelease.t index 5338de101..25290696f 100644 --- a/t/plugins/confirmrelease.t +++ b/t/plugins/confirmrelease.t @@ -11,7 +11,7 @@ sub new_tzil { { add_files => { 'source/dist.ini' => - simple_ini(qw(GatherDir ConfirmRelease FakeRelease)), + simple_ini(qw(GatherDir ConfirmRelease FakeRelease MetaConfig)), }, }, ); diff --git a/t/plugins/extratests.t b/t/plugins/extratests.t index cd64aedd3..442d5f9de 100644 --- a/t/plugins/extratests.t +++ b/t/plugins/extratests.t @@ -27,7 +27,7 @@ my $tzil = Builder->from_config( { dist_root => 'corpus/dist/DZT' }, { add_files => { - 'source/dist.ini' => simple_ini(qw), + 'source/dist.ini' => simple_ini(qw), (map {; "source/xt/$_/huffer.t" => sprintf($generic_test, $_) } @xt_types, qw(blort)) }, diff --git a/t/plugins/fakerelease.t b/t/plugins/fakerelease.t index 7f0912c3f..1c07ba20a 100644 --- a/t/plugins/fakerelease.t +++ b/t/plugins/fakerelease.t @@ -10,7 +10,7 @@ use Test::Fatal qw(exception); { dist_root => 'corpus/dist/DZT' }, { add_files => { - 'source/dist.ini' => simple_ini(qw(GatherDir FakeRelease)), + 'source/dist.ini' => simple_ini(qw(GatherDir FakeRelease MetaConfig)), }, }, ); @@ -32,7 +32,8 @@ use Test::Fatal qw(exception); [ '@Filter' => { bundle => '@FakeClassic', remove => 'ConfirmRelease', - } ] + } ], + 'MetaConfig', ), }, }, @@ -52,7 +53,7 @@ use Test::Fatal qw(exception); { dist_root => 'corpus/dist/DZT' }, { add_files => { - 'source/dist.ini' => simple_ini(qw(GatherDir FakeRelease)), + 'source/dist.ini' => simple_ini(qw(GatherDir FakeRelease MetaConfig)), }, }, ); diff --git a/t/plugins/ffbyname.t b/t/plugins/ffbyname.t index 4bf9118ec..4be639aa2 100644 --- a/t/plugins/ffbyname.t +++ b/t/plugins/ffbyname.t @@ -77,7 +77,8 @@ sub make_tzil { #--------------------------------------------------------------------- make_tzil([ 'FileFinder::ByName' => {qw(dir corpus skip archives)}], - [ 'FileFinder::Filter' => {qw(finder FileFinder::ByName skip DZT)}]); + [ 'FileFinder::Filter' => {qw(finder FileFinder::ByName skip DZT)}], + [ 'MetaConfig']); is_found('FileFinder::ByName' => [qw( corpus/DZT/README @@ -105,6 +106,7 @@ make_tzil( { finder => [qw(InBin AllPerl Plugins Synopsis)] }], [ 'FileFinder::Filter' => NoPluginM => { finder => 'AllPerl', skip => 'Plugin/M' }], + [ 'MetaConfig'], ); is_found(InBin => [qw( @@ -176,7 +178,9 @@ is_found(NoPluginM => [qw( #--------------------------------------------------------------------- make_tzil([ 'FileFinder::ByName' => 'Everything' ], [ 'FileFinder::ByName' => 'EverythingButPerl' => - {skip => [qw( \.t$ (?i)\.p[lm]$ )]} ]); + {skip => [qw( \.t$ (?i)\.p[lm]$ )]} ], + [ 'MetaConfig'], +); is_found(Everything => [ map { $_->name } @dist_files ]); diff --git a/t/plugins/filefinders.t b/t/plugins/filefinders.t index 20ff79899..8b31d03c0 100644 --- a/t/plugins/filefinders.t +++ b/t/plugins/filefinders.t @@ -34,6 +34,7 @@ my $tzil = Builder->from_config( [ ExecDir => ], [ ShareDir => ], 'Manifest', + 'MetaConfig', ), (map {; "source/xt${_}more.t" => $generic_test } qw(/author/ /smoke/ /release/ /)), diff --git a/t/plugins/generatefile.t b/t/plugins/generatefile.t index ec55177e9..1c7d2002a 100644 --- a/t/plugins/generatefile.t +++ b/t/plugins/generatefile.t @@ -30,6 +30,7 @@ my $tzil = Builder->from_config( ], } ], + 'MetaConfig', ) }, }, @@ -96,6 +97,7 @@ $tzil = Builder->from_config( ], } ], + 'MetaConfig', ) }, }, diff --git a/t/plugins/misctests.t b/t/plugins/misctests.t index 92b630b0a..ef25e496d 100644 --- a/t/plugins/misctests.t +++ b/t/plugins/misctests.t @@ -19,7 +19,7 @@ my $tzil = Builder->from_config( $tzil->build; -my $meta_test = $tzil->slurp_file('build/xt/release/distmeta.t'); +my $meta_test = $tzil->slurp_file('build/xt/author/distmeta.t'); like($meta_test, qr{meta_yaml_ok}, "we have a distmeta file that tests it"); my $pod_test = $tzil->slurp_file('build/xt/author/pod-syntax.t'); diff --git a/t/plugins/nextrelease.t b/t/plugins/nextrelease.t index 036039234..2beb576a9 100644 --- a/t/plugins/nextrelease.t +++ b/t/plugins/nextrelease.t @@ -25,7 +25,7 @@ END_CHANGES with 'Dist::Zilla::Role::AfterRelease'; sub after_release { - Path::Tiny::path('Changes')->spew('OHHAI'); + Path::Tiny::path(shift->zilla->root, 'Changes')->spew('OHHAI'); } } diff --git a/t/types.t b/t/types.t new file mode 100644 index 000000000..f81355d03 --- /dev/null +++ b/t/types.t @@ -0,0 +1,12 @@ +use strict; +use warnings; + +use Test::More 0.88; + +use Dist::Zilla::Types qw(VersionStr); + +ok(is_VersionStr($_), "$_ isa VersionStr") foreach qw(1.23 1.23000 1.004_002 v1.23 v1.23.45); + +ok(!is_VersionStr($_), "$_ is not a VersionStr") foreach qw(v1.23_01 v1.23.45_01 1.23.45_01); + +done_testing;