diff options
author | Jesse Luehrs <doy@tozt.net> | 2011-01-08 13:57:42 -0600 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2011-01-08 13:57:42 -0600 |
commit | 03eb354e07941dbab5306a7c89a1b5bda07d7c30 (patch) | |
tree | fd6f10f063bff5fc01dfe500e87b4b786d28dd21 | |
parent | 49a8beb1ba8d07be5c2dd6c7e7d793790e665406 (diff) | |
download | extutils-makemaker-dist-zilla-develop-03eb354e07941dbab5306a7c89a1b5bda07d7c30.tar.gz extutils-makemaker-dist-zilla-develop-03eb354e07941dbab5306a7c89a1b5bda07d7c30.zip |
turn this into a dzil plugin
-rw-r--r-- | dist.ini | 5 | ||||
-rw-r--r-- | lib/Dist/Zilla/Plugin/MakefilePL/Lite.pm | 77 |
2 files changed, 80 insertions, 2 deletions
@@ -1,10 +1,11 @@ -name = ExtUtils-MakeMaker-Dist-Zilla +name = Dist-Zilla-Plugin-MakefilePL-Lite author = Jesse Luehrs <doy at tozt dot net> license = Perl_5 copyright_holder = Jesse Luehrs [@DOY] -dist = ExtUtils-MakeMaker-Dist-Zilla +dist = Dist-Zilla-Plugin-MakefilePL-Lite [Prereqs] +Dist::Zilla = 0 ExtUtils::MakeMaker = 0 diff --git a/lib/Dist/Zilla/Plugin/MakefilePL/Lite.pm b/lib/Dist/Zilla/Plugin/MakefilePL/Lite.pm new file mode 100644 index 0000000..bf06005 --- /dev/null +++ b/lib/Dist/Zilla/Plugin/MakefilePL/Lite.pm @@ -0,0 +1,77 @@ +package Dist::Zilla::Plugin::MakefilePL::Lite; +use Moose; + +with qw( + Dist::Zilla::Role::FileGatherer + Dist::Zilla::Role::FileMunger + Dist::Zilla::Role::FilePruner +); + +sub gather_files { + my $self = shift; + return unless $self->zilla->isa('Dist::Zilla::Dist::Minter'); + + (my $mod_name = $self->zilla->name) =~ s/-/::/g; + my $content = <<CONTENTS; +# This module uses Dist::Zilla for development. This Makefile.PL will let you +# run the tests, but you are encouraged to install Dist::Zilla and the needed +# plugins if you intend on doing any serious hacking. + +use strict; +use warnings; + +use ExtUtils::MakeMaker::Dist::Zilla; + +WriteMakefile( + NAME => '$mod_name', +); +CONTENTS + + $self->add_file( + Dist::Zilla::File::InMemory->new( + name => 'Makefile.PL', + content => $content, + ) + ); +} + +sub munge_files { + my $self = shift; + return unless $self->zilla->isa('Dist::Zilla::Dist::Minter'); + + my ($dist_ini) = grep { $_->name eq 'dist.ini' } @{ $self->zilla->files }; + return unless $dist_ini; + + if ($dist_ini->isa('Dist::Zilla::File::OnDisk')) { + my $content = $dist_ini->content; + Dist::Zilla::File::InMemory->meta->rebless_instance( + $dist_ini, + content => $content . "\n[MakefilePL::Lite]\n", + ); + } + elsif ($dist_ini->isa('Dist::Zilla::File::InMemory')) { + $dist_ini->content($dist_ini->content . "\n[MakefilePL::Lite]\n"); + } + elsif ($dist_ini->isa('Dist::Zilla::File::FromCode')) { + my $code = $dist_ini->code; + my $weak_dist_ini = $dist_ini; + Scalar::Util::weaken($weak_dist_ini); + $dist_ini->code(sub { + $weak_dist_ini->$code . "\n[MakefilePL::Lite]\n" + }); + } +} + +sub prune_files { + my $self = shift; + return unless $self->zilla->isa('Dist::Zilla::Dist::Builder'); + for my $file (@{ $self->zilla->files }) { + next unless $file->name eq 'Makefile.PL'; + $self->zilla->prune_file($file); + } +} + +__PACKAGE__->meta->make_immutable; +no Moose; + +1; |