| 1 | 2 | ▶ | use 5.006; # our | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | package Dist::Zilla::Plugin::ModuleInstall; | ||||||||||||
| 6 | |||||||||||||
| 7 | 2 | our $VERSION = '1.001002'; | |||||||||||
| 8 | |||||||||||||
| 9 | # ABSTRACT: (DEPRECATED) Build Module::Install based Distributions with Dist::Zilla | ||||||||||||
| 10 | |||||||||||||
| 11 | 2 | our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY | |||||||||||
| 12 | |||||||||||||
| 13 | 2 | ▶ | use Moose qw( has with around ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 14 | 2 | ▶ | use Config; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 15 | 2 | ▶ | use Carp qw( carp croak ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 16 | 2 | ▶ | use Dist::Zilla::Plugin::MakeMaker::Runner; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 17 | 2 | ▶ | use Dist::Zilla::File::FromCode; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | |||||||||||||
| 19 | has 'make_path' => ( | ||||||||||||
| 20 | isa => 'Str', | ||||||||||||
| 21 | is => 'ro', | ||||||||||||
| 22 | 2 | ▶ | default => $Config{make} || 'make', | ||||||||||
|
Condition50%1/2
$Dist::Zilla::Plugin::ModuleInstall::Config{'make'} || 'make'
MC/DC0%0/1
$Dist::Zilla::Plugin::ModuleInstall::Config{'make'} || 'make'
$Dist::Zilla::Plugin::ModuleInstall::Config{'make'}
Truth table50%1/2
A
A= $Dist::Zilla::Plugin::ModuleInstall::Config{'make'}
| |||||||||||||
| 23 | ); | ||||||||||||
| 24 | |||||||||||||
| 25 | has '_runner' => ( | ||||||||||||
| 26 | is => 'ro', | ||||||||||||
| 27 | lazy => 1, | ||||||||||||
| 28 | handles => [qw(build test)], | ||||||||||||
| 29 | 0 | ▶ | default => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||
| 30 | 0 | my ($self) = @_; | |||||||||||
| 31 | 0 | Dist::Zilla::Plugin::MakeMaker::Runner->new( | |||||||||||
| 32 | { | ||||||||||||
| 33 | zilla => $self->zilla, | ||||||||||||
| 34 | plugin_name => $self->plugin_name . '::Runner', | ||||||||||||
| 35 | make_path => $self->make_path, | ||||||||||||
| 36 | }, | ||||||||||||
| 37 | ); | ||||||||||||
| 38 | }, | ||||||||||||
| 39 | 2 | ); | |||||||||||
| 40 | |||||||||||||
| 41 | 2 | with 'Dist::Zilla::Role::BuildRunner'; | |||||||||||
| 42 | 2 | with 'Dist::Zilla::Role::InstallTool'; | |||||||||||
| 43 | 2 | with 'Dist::Zilla::Role::TextTemplate'; | |||||||||||
| 44 | |||||||||||||
| 45 | # no broken tempdir, keepalive_fail helper | ||||||||||||
| 46 | 2 | ▶ | use Dist::Zilla::Role::Tempdir 1.001000; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 47 | 2 | with 'Dist::Zilla::Role::Tempdir'; | |||||||||||
| 48 | |||||||||||||
| 49 | 2 | with 'Dist::Zilla::Role::PrereqSource'; | |||||||||||
| 50 | 2 | with 'Dist::Zilla::Role::TestRunner'; | |||||||||||
| 51 | |||||||||||||
| 52 | 0 | ▶ | around dump_config => sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||
| 53 | 0 | my ( $orig, $self, @args ) = @_; | |||||||||||
| 54 | 0 | my $config = $self->$orig(@args); | |||||||||||
| 55 | 0 | my $payload = $config->{ +__PACKAGE__ } = {}; | |||||||||||
| 56 | 0 | $payload->{make_path} = $self->make_path; | |||||||||||
| 57 | |||||||||||||
| 58 | ## no critic (RequireInterpolationOfMetachars) | ||||||||||||
| 59 | 0 | ▶ | $payload->{ q[$] . __PACKAGE__ . q[::VERSION] } = $VERSION unless __PACKAGE__ eq ref $self; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 60 | 0 | ▶ | $payload->{q[$Module::Install::VERSION]} = $Module::Install::VERSION if $INC{'Module/Install.pm'}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 61 | 0 | return $config; | |||||||||||
| 62 | 2 | }; | |||||||||||
| 63 | |||||||||||||
| 64 | 2 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 65 | 2 | ▶ | no Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 66 | |||||||||||||
| 67 | 2 | ▶ | use Dist::Zilla::File::InMemory; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 68 | |||||||||||||
| 69 | 2 | ▶ | use namespace::autoclean; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 70 | |||||||||||||
| 71 | 2 | require inc::Module::Install; | |||||||||||
| 72 | |||||||||||||
| 73 | 0 | ▶ | sub _doc_template { | ||||||||||
|
Subroutine
_doc_template: not called CC=2 SCAR=17.9
| |||||||||||||
| 74 | 0 | my ( $self, $args ) = @_; | |||||||||||
| 75 | 0 | my $package = __PACKAGE__; | |||||||||||
| 76 | 0 | ▶ | my $version = ( __PACKAGE__->VERSION() || 'undefined ( self-build? )' ); | ||||||||||
|
Condition0%0/2
__PACKAGE__->VERSION || 'undefined ( self-build? )'
MC/DC0%0/1
__PACKAGE__->VERSION || 'undefined ( self-build? )'
__PACKAGE__->VERSION
Truth table0%0/2
A
A= __PACKAGE__->VERSION
| |||||||||||||
| 77 | |||||||||||||
| 78 | 0 | my $t = <<"EOF"; | |||||||||||
| 79 | use strict; | ||||||||||||
| 80 | use warnings; | ||||||||||||
| 81 | use lib './'; # Required for -Ddefault_inc_excludes_dot | ||||||||||||
| 82 | # Warning: This code was generated by ${package} Version ${version} | ||||||||||||
| 83 | # As part of Dist::Zilla's build generation. | ||||||||||||
| 84 | # Do not modify this file, instead, modify the dist.ini that configures its generation. | ||||||||||||
| 85 | use inc::Module::Install {{ \$miver }}; | ||||||||||||
| 86 | {{ \$headings }} | ||||||||||||
| 87 | {{ \$requires }} | ||||||||||||
| 88 | {{ \$feet }} | ||||||||||||
| 89 | WriteAll(); | ||||||||||||
| 90 | EOF | ||||||||||||
| 91 | 0 | return $self->fill_in_string( $t, $args ); | |||||||||||
| 92 | } | ||||||||||||
| 93 | |||||||||||||
| 94 | 0 | ▶ | sub _label_value_template { | ||||||||||
|
Subroutine
_label_value_template: not called CC=1 SCAR=6.9
| |||||||||||||
| 95 | 0 | my ( $self, $args ) = @_; | |||||||||||
| 96 | 0 | my $t = <<"EOF"; | |||||||||||
| 97 | {{ \$label }} '{{ \$value }}'; | ||||||||||||
| 98 | EOF | ||||||||||||
| 99 | 0 | return $self->fill_in_string( $t, $args ); | |||||||||||
| 100 | } | ||||||||||||
| 101 | |||||||||||||
| 102 | 0 | ▶ | sub _label_string_template { | ||||||||||
|
Subroutine
_label_string_template: not called CC=1 SCAR=6.9
| |||||||||||||
| 103 | 0 | my ( $self, $args ) = @_; | |||||||||||
| 104 | 0 | my $t = <<"EOF"; | |||||||||||
| 105 | {{ \$label }} "{{ quotemeta( \$string ) }}"; | ||||||||||||
| 106 | EOF | ||||||||||||
| 107 | 0 | return $self->fill_in_string( $t, $args ); | |||||||||||
| 108 | } | ||||||||||||
| 109 | |||||||||||||
| 110 | 0 | ▶ | sub _label_string_string_template { | ||||||||||
|
Subroutine
_label_string_string_template: not called CC=1 SCAR=6.9
| |||||||||||||
| 111 | 0 | my ( $self, $args ) = @_; | |||||||||||
| 112 | 0 | my $t = <<"EOF"; | |||||||||||
| 113 | {{ \$label }} "{{ quotemeta(\$stringa) }}" => "{{ quotemeta(\$stringb) }}"; | ||||||||||||
| 114 | EOF | ||||||||||||
| 115 | 0 | return $self->fill_in_string( $t, $args ); | |||||||||||
| 116 | } | ||||||||||||
| 117 | |||||||||||||
| 118 | 0 | ▶ | sub _generate_makefile_pl { | ||||||||||
|
Subroutine
_generate_makefile_pl: not called CC=2 SCAR=17.9
| |||||||||||||
| 119 | 0 | my ($self) = @_; | |||||||||||
| 120 | 0 | my ( @headings, @requires, @feet ); | |||||||||||
| 121 | |||||||||||||
| 122 | 0 | push @headings, _label_value_template( $self, { label => 'name', value => $self->zilla->name } ), | |||||||||||
| 123 | _label_string_template( $self, { label => 'abstract', string => $self->zilla->abstract } ), | ||||||||||||
| 124 | _label_string_template( $self, { label => 'author', string => $self->zilla->authors->[0] } ), | ||||||||||||
| 125 | _label_string_template( $self, { label => 'version', string => $self->zilla->version } ), | ||||||||||||
| 126 | _label_string_template( $self, { label => 'license', string => $self->zilla->license->meta_yml_name } ); | ||||||||||||
| 127 | |||||||||||||
| 128 | 0 | my $prereqs = $self->zilla->prereqs; | |||||||||||
| 129 | |||||||||||||
| 130 | 0 | ▶ | my $doreq = sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||
| 131 | 0 | my ( $key, $target ) = @_; | |||||||||||
| 132 | 0 | push @requires, qq{\n# @$key => $target}; | |||||||||||
| 133 | 0 | my $hash = $prereqs->requirements_for( @{$key} )->as_string_hash; | |||||||||||
| 134 | 0 | for ( sort keys %{$hash} ) { | |||||||||||
| 135 | 0 | ▶ | if ( 'perl' eq $_ ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 136 | 0 | push @requires, _label_string_template( $self, { label => 'perl_version', string => $hash->{$_} } ); | |||||||||||
| 137 | 0 | next; | |||||||||||
| 138 | } | ||||||||||||
| 139 | push @requires, | ||||||||||||
| 140 | $self->_label_string_string_template( | ||||||||||||
| 141 | { | ||||||||||||
| 142 | label => $target, | ||||||||||||
| 143 | stringa => $_, | ||||||||||||
| 144 | 0 | stringb => $hash->{$_}, | |||||||||||
| 145 | }, | ||||||||||||
| 146 | ); | ||||||||||||
| 147 | } | ||||||||||||
| 148 | 0 | }; | |||||||||||
| 149 | |||||||||||||
| 150 | 0 | $doreq->( [qw(configure requires)], 'configure_requires' ); | |||||||||||
| 151 | 0 | $doreq->( [qw(build requires)], 'requires' ); | |||||||||||
| 152 | 0 | $doreq->( [qw(runtime requires)], 'requires' ); | |||||||||||
| 153 | 0 | $doreq->( [qw(runtime recommends)], 'recommends' ); | |||||||||||
| 154 | 0 | $doreq->( [qw(test requires)], 'test_requires' ); | |||||||||||
| 155 | |||||||||||||
| 156 | 0 | push @feet, qq{\n# :ExecFiles}; | |||||||||||
| 157 | 0 | my @found_files = @{ $self->zilla->find_files(':ExecFiles') }; | |||||||||||
| 158 | 0 | for my $execfile ( map { $_->name } @found_files ) { | |||||||||||
| 159 | 0 | push @feet, _label_string_template( $self, $execfile ); | |||||||||||
| 160 | } | ||||||||||||
| 161 | 0 | my $content = _doc_template( | |||||||||||
| 162 | $self, | ||||||||||||
| 163 | { | ||||||||||||
| 164 | miver => "$Module::Install::VERSION", | ||||||||||||
| 165 | headings => join( qq{\n}, @headings ), | ||||||||||||
| 166 | requires => join( qq{\n}, @requires ), | ||||||||||||
| 167 | feet => join( qq{\n}, @feet ), | ||||||||||||
| 168 | }, | ||||||||||||
| 169 | ); | ||||||||||||
| 170 | 0 | return $content; | |||||||||||
| 171 | } | ||||||||||||
| 172 | |||||||||||||
| 173 | |||||||||||||
| 174 | |||||||||||||
| 175 | |||||||||||||
| 176 | |||||||||||||
| 177 | |||||||||||||
| 178 | |||||||||||||
| 179 | 1 | ▶ | sub register_prereqs { | ||||||||||
|
Subroutine
register_prereqs: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 180 | 1 | my ($self) = @_; | |||||||||||
| 181 | 1 | $self->zilla->register_prereqs( { phase => 'configure' }, 'ExtUtils::MakeMaker' => 6.42 ); | |||||||||||
| 182 | 1 | $self->zilla->register_prereqs( { phase => 'build' }, 'ExtUtils::MakeMaker' => 6.42 ); | |||||||||||
| 183 | 1 | return; | |||||||||||
| 184 | } | ||||||||||||
| 185 | |||||||||||||
| 186 | |||||||||||||
| 187 | |||||||||||||
| 188 | |||||||||||||
| 189 | |||||||||||||
| 190 | |||||||||||||
| 191 | |||||||||||||
| 192 | |||||||||||||
| 193 | 2 | my $error_load = 'Error running Makefile.PL for Module::Install. '; | |||||||||||
| 194 | 2 | my $no_keepalive = $error_load . 'Set MI_KEEPALIVE=1 if you want to retain the directory for analysis'; | |||||||||||
| 195 | 2 | my $keepalive = $error_load . 'Inspect the temporary directory to determine cause'; | |||||||||||
| 196 | |||||||||||||
| 197 | 1 | ▶ | sub setup_installer { | ||||||||||
|
Subroutine
setup_installer: called CC=5 SCAR=29.5
Pod
documented
| |||||||||||||
| 198 | 1 | my ( $self, ) = @_; | |||||||||||
| 199 | |||||||||||||
| 200 | 0 | ▶ | my $file = Dist::Zilla::File::FromCode->new( { name => 'Makefile.PL', code => sub { _generate_makefile_pl($self) }, } ); | ||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=1.2
| |||||||||||||
| 201 | |||||||||||||
| 202 | 1 | $self->add_file($file); | |||||||||||
| 203 | |||||||||||||
| 204 | 0 | ▶ | my $code = sub { | ||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||
| 205 | 0 | my ($dir) = @_; | |||||||||||
| 206 | 0 | ▶ | system $^X, 'Makefile.PL' and do { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 207 | |||||||||||||
| 208 | 0 | ▶ | croak($no_keepalive) unless $ENV{MI_KEEPALIVE}; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 209 | |||||||||||||
| 210 | 0 | $dir->keepalive_fail($keepalive); | |||||||||||
| 211 | }; | ||||||||||||
| 212 | 1 | }; | |||||||||||
| 213 | |||||||||||||
| 214 | 1 | my (@generated) = $self->capture_tempdir($code); | |||||||||||
| 215 | |||||||||||||
| 216 | 0 | for (@generated) { | |||||||||||
| 217 | 0 | ▶ | if ( $_->is_new ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 218 | 0 | $self->log( 'ModuleInstall created: ' . $_->name ); | |||||||||||
| 219 | 0 | ▶ | if ( $_->name =~ /\Ainc\/Module\/Install/msx ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 220 | 0 | $self->log( 'ModuleInstall added : ' . $_->name ); | |||||||||||
| 221 | 0 | $self->add_file( $_->file ); | |||||||||||
| 222 | } | ||||||||||||
| 223 | } | ||||||||||||
| 224 | 0 | ▶ | if ( $_->is_modified ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 225 | 0 | $self->log( 'ModuleInstall modified: ' . $_->name ); | |||||||||||
| 226 | } | ||||||||||||
| 227 | } | ||||||||||||
| 228 | 0 | return; | |||||||||||
| 229 | } | ||||||||||||
| 230 | |||||||||||||
| 231 | 2 | 1; | |||||||||||
| 232 | |||||||||||||
| 233 | __END__ | ||||||||||||