File Coverage

blib/lib/Dist/Zilla/Plugin/MakeMaker/SkipInstall.pm
Criterion Covered Total %
statement 6 15 40.0
branch 0 4 0.0
condition n/a
subroutine 2 3 66.6
pod 1 1 100.0
total 9 23 39.1


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::MakeMaker::SkipInstall;
2             $Dist::Zilla::Plugin::MakeMaker::SkipInstall::VERSION = '1.200';
3 2     2   1337218 use Moose;
  2         284133  
  2         11  
4              
5             with 'Dist::Zilla::Role::AfterBuild';
6              
7             has filename => (
8             isa => 'Str',
9             is => 'ro',
10             default => 'Makefile.PL',
11             );
12              
13             sub after_build {
14 0     0 1   my ($self, $args) = @_;
15 0           my $build_root = $args->{build_root};
16 0           my $filename = $build_root->file($self->filename);
17            
18 0           my $content = $filename->slurp;
19            
20 0           my ($pre, $post) = split(/^\s*WriteMakefile[(]/sm, $content);
21 0           $content = $pre
22             . q{
23              
24             exit 0 if $ENV{AUTOMATED_TESTING};
25             sub MY::install { "install ::\n" }
26              
27             }
28             . "\nWriteMakefile("
29             . $post;
30            
31 0           my $fh = $filename->openw;
32 0 0         $fh->print($content) or Carp::croak("error writing to $filename: $!");
33 0 0         $fh->close or Carp::croak("error closing $filename: $!");
34             }
35              
36             __PACKAGE__->meta->make_immutable;
37 2     2   8896 no Moose;
  2         2  
  2         9  
38             1;
39              
40             __END__
41              
42             =head1 NAME
43              
44             Dist::Zilla::Plugin::MakeMaker::SkipInstall - skip the install rule of MakeMaker
45              
46             =head1 VERSION
47              
48             version 1.200
49              
50             =head1 SYNOPSIS
51              
52             In your C<dist.ini> file:
53              
54             [MakeMaker::SkipInstall]
55              
56             =head1 DESCRIPTION
57              
58             This small plugin will edit the C<Makefile.PL> file, and override the
59             install target to become a no-op.
60              
61             This will make your module fail the install phase. It will be built, and
62             tested but will never be installed.
63              
64             The most common use for this techinique is for L<Task> modules. Without
65             a proper install phase, you can install your Task module repetedly.
66              
67              
68             =head1 CREDITS
69              
70             The technique was described by Marcel Gruenauer (hanekomu) in his
71             article "Repeatedly installing Task::* distributions":
72              
73             L<http://hanekomu.at/blog/dev/20091005-1227-repeatedly_installing_task_distributions.html>
74              
75             The author just wrapped the concept into a L<Dist::Zilla> plugin.
76              
77              
78             =head1 SEE ALSO
79              
80             L<Dist::Zilla>.
81              
82              
83             =head1 AUTHOR
84              
85             Pedro Melo, C<< <melo at cpan.org> >>
86              
87              
88             =head1 COPYRIGHT & LICENSE
89              
90             Copyright 2009 Pedro Melo.
91              
92             This program is free software; you can redistribute it and/or modify it
93             under the same terms as Perl itself.
94              
95              
96             =begin make-pod-coverage-happy
97              
98             =over 4
99              
100             =item after_build()
101              
102             Edits the C<Makefile.PL> in place, searches for C<WriteMakefile> and
103             prepends our override.
104              
105             =back
106              
107             =end make-pod-coverage-happy
108              
109             =cut