File Coverage

blib/lib/Dist/Zilla/Plugin/InstallRelease.pm
Criterion Covered Total %
statement 13 15 86.6
branch n/a
condition n/a
subroutine 5 5 100.0
pod n/a
total 18 20 90.0


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::InstallRelease;
2 1     1   673 use strict;
  1         1  
  1         34  
3 1     1   5 use warnings;
  1         1  
  1         39  
4             # ABSTRACT: installs your dist after releasing
5             our $VERSION = '0.008'; # VERSION
6              
7 1     1   4 use Carp ();
  1         2  
  1         12  
8 1     1   2071 use autodie;
  1         34101  
  1         19  
9 1     1   9015 use Moose;
  0            
  0            
10             with 'Dist::Zilla::Role::Plugin';
11             with 'Dist::Zilla::Role::AfterRelease';
12              
13              
14             has install_command => (
15             is => 'ro',
16             isa => 'Str',
17             predicate => 'has_install_command',
18             );
19              
20             sub after_release {
21             my $self = shift;
22              
23             eval {
24             require File::pushd;
25             my $wd = File::pushd::pushd($self->zilla->built_in);
26             if ($self->has_install_command) {
27             system($self->install_command)
28             && $self->log_fatal([ 'error running %s', [$self->install_command] ]);
29             }
30             else {
31             my @cmd = ($^X, '-MCPAN',
32             $^O eq 'MSWin32' ? q(-e"install '.'") : q(-einstall '.')
33             );
34             system(@cmd) && $self->log_fatal([ 'error running %s', \@cmd ]);
35             }
36             };
37              
38             if ($@) {
39             $self->log($@);
40             $self->log('Install failed.');
41             }
42             else {
43             $self->log('Install OK');
44             }
45              
46             return;
47             }
48              
49              
50             __PACKAGE__->meta->make_immutable;
51             no Moose;
52              
53             1;
54              
55             __END__
56             =pod
57              
58             =encoding utf-8
59              
60             =head1 NAME
61              
62             Dist::Zilla::Plugin::InstallRelease - installs your dist after releasing
63              
64             =head1 VERSION
65              
66             version 0.008
67              
68             =head1 DESCRIPTION
69              
70             After doing C<dzil release>, this plugin will install your dist so you
71             are always the first person to have the latest and greatest version. It's
72             like getting first post, only useful.
73              
74             To use it, add the following in F<dist.ini>:
75              
76             [InstallRelease]
77              
78             You can specify an alternate install command:
79              
80             [InstallRelease]
81             install_command = cpanm .
82              
83             This plugin must always come before L<Dist::Zilla::Plugin::Clean>.
84              
85             =for Pod::Coverage after_release
86              
87             =head1 AVAILABILITY
88              
89             The project homepage is L<http://p3rl.org/Dist::Zilla::Plugin::InstallRelease>.
90              
91             The latest version of this module is available from the Comprehensive Perl
92             Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
93             site near you, or see L<https://metacpan.org/module/Dist::Zilla::Plugin::InstallRelease/>.
94              
95             =head1 SOURCE
96              
97             The development version is on github at L<http://github.com/doherty/Dist-Zilla-Plugin-InstallRelease>
98             and may be cloned from L<git://github.com/doherty/Dist-Zilla-Plugin-InstallRelease.git>
99              
100             =head1 BUGS AND LIMITATIONS
101              
102             You can make new bug reports, and view existing ones, through the
103             web interface at L<https://github.com/doherty/Dist-Zilla-Plugin-InstallRelease/issues>.
104              
105             =head1 AUTHOR
106              
107             Mike Doherty <doherty@cpan.org>
108              
109             =head1 COPYRIGHT AND LICENSE
110              
111             This software is copyright (c) 2100 by Mike Doherty.
112              
113             This is free software; you can redistribute it and/or modify it under
114             the same terms as the Perl 5 programming language system itself.
115              
116             =cut
117