« blib/lib/Dist/Zilla/PluginBundle/Author/Plicease.pm
↑ Summary
blib/lib/Dist/Zilla/Plugin/Author/Plicease/Init2.pm »
| 1 | 3 | package Dist::Zilla::Plugin::Author::Plicease::SpecialPrereqs 2.81 { | |||||||||||
| 2 | |||||||||||||
| 3 | 3 | ▶ | use 5.022; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 3 | ▶ | use Moose; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 3 | ▶ | use experimental qw( postderef ); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 6 | 3 | ▶ | use Dist::Zilla::Plugin::Author::Plicease; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 3 | ▶ | use Config::INI::Reader; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 3 | ▶ | use Dist::Zilla::Util::AuthorDeps; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | |||||||||||||
| 10 | # ABSTRACT: Special prereq handling | ||||||||||||
| 11 | |||||||||||||
| 12 | |||||||||||||
| 13 | 3 | with 'Dist::Zilla::Role::BeforeRelease'; | |||||||||||
| 14 | 3 | with 'Dist::Zilla::Role::PrereqSource'; | |||||||||||
| 15 | 3 | with 'Dist::Zilla::Role::InstallTool'; | |||||||||||
| 16 | |||||||||||||
| 17 | 8 | ▶ | sub mvp_multivalue_args { qw( upgrade preamble ) } | ||||||||||
|
Subroutine
mvp_multivalue_args: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 18 | |||||||||||||
| 19 | has preamble => ( | ||||||||||||
| 20 | is => 'ro', | ||||||||||||
| 21 | 7 | ▶ | default => sub { [] }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | 3 | ); | |||||||||||
| 23 | |||||||||||||
| 24 | has upgrade => ( | ||||||||||||
| 25 | is => 'ro', | ||||||||||||
| 26 | 6 | ▶ | default => sub { [] }, | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | 3 | ); | |||||||||||
| 28 | |||||||||||||
| 29 | 3 | has win32 => ( | |||||||||||
| 30 | is => 'ro', | ||||||||||||
| 31 | default => 0, | ||||||||||||
| 32 | ); | ||||||||||||
| 33 | |||||||||||||
| 34 | 3 | has git => ( | |||||||||||
| 35 | is => 'ro', | ||||||||||||
| 36 | default => 0, | ||||||||||||
| 37 | ); | ||||||||||||
| 38 | |||||||||||||
| 39 | sub register_prereqs | ||||||||||||
| 40 | 7 | ▶ | { | ||||||||||
|
Subroutine
register_prereqs: called CC=21 SCAR=30.4
Pod
undocumented
| |||||||||||||
| 41 | 7 | my($self) = @_; | |||||||||||
| 42 | |||||||||||||
| 43 | 7 | my $prereqs = $self->zilla->prereqs->as_string_hash; | |||||||||||
| 44 | |||||||||||||
| 45 | 7 | my %upgrades = qw( | |||||||||||
| 46 | Moo 2.0 | ||||||||||||
| 47 | PerlX::Maybe 0.003 | ||||||||||||
| 48 | AnyEvent::Open3::Simple 0.83 | ||||||||||||
| 49 | Path::Class 0.26 | ||||||||||||
| 50 | Path::Tiny 0.130 | ||||||||||||
| 51 | Mojolicious 4.31 | ||||||||||||
| 52 | Role::Tiny 1.003001 | ||||||||||||
| 53 | Test::More 0.98 | ||||||||||||
| 54 | Test::Exit 0.11 | ||||||||||||
| 55 | Clustericious 1.20 | ||||||||||||
| 56 | Test::Clustericious::Cluster 0.31 | ||||||||||||
| 57 | ExtUtils::ParseXS 3.30 | ||||||||||||
| 58 | ); | ||||||||||||
| 59 | |||||||||||||
| 60 | 7 | $upgrades{$_} = '1.302015' for ( | |||||||||||
| 61 | 49 | (map { "Test2::$_" } qw( API Event Formatter Formatter::TAP Hub IPC Util )), | |||||||||||
| 62 | 28 | (map { "Test2::API::$_" } qw( Breakage Context Instance Stack )), | |||||||||||
| 63 | 63 | (map { "Test2::Event::$_" } qw( Bail Diag Exception Note Ok Plan Skp Subtest Waiting )), | |||||||||||
| 64 | 21 | (map { "Test2::Hub::$_" } qw( Interceptor Interceptor::Terminator Subtest )), | |||||||||||
| 65 | 14 | (map { "Test2::IPC::$_" } qw( Driver Driver::Files )), | |||||||||||
| 66 | 21 | (map { "Test2::Util::$_" } qw( ExternalMeta HashBase Trace )), | |||||||||||
| 67 | 'Test2', | ||||||||||||
| 68 | ); | ||||||||||||
| 69 | |||||||||||||
| 70 | 7 | $upgrades{$_} = '0.000121' for qw( | |||||||||||
| 71 | Test2::V0 | ||||||||||||
| 72 | Test2::Bundle | ||||||||||||
| 73 | Test2::Bundle::Extended | ||||||||||||
| 74 | Test2::Bundle::More | ||||||||||||
| 75 | Test2::Bundle::Simple | ||||||||||||
| 76 | Test2::Compare | ||||||||||||
| 77 | Test2::Compare::Array | ||||||||||||
| 78 | Test2::Compare::Base | ||||||||||||
| 79 | Test2::Compare::Custom | ||||||||||||
| 80 | Test2::Compare::Delta | ||||||||||||
| 81 | Test2::Compare::Event | ||||||||||||
| 82 | Test2::Compare::EventMeta | ||||||||||||
| 83 | Test2::Compare::Hash | ||||||||||||
| 84 | Test2::Compare::Meta | ||||||||||||
| 85 | Test2::Compare::Number | ||||||||||||
| 86 | Test2::Compare::Object | ||||||||||||
| 87 | Test2::Compare::OrderedSubset | ||||||||||||
| 88 | Test2::Compare::Pattern | ||||||||||||
| 89 | Test2::Compare::Ref | ||||||||||||
| 90 | Test2::Compare::Regex | ||||||||||||
| 91 | Test2::Compare::Scalar | ||||||||||||
| 92 | Test2::Compare::Set | ||||||||||||
| 93 | Test2::Compare::String | ||||||||||||
| 94 | Test2::Compare::Undef | ||||||||||||
| 95 | Test2::Compare::Wildcard | ||||||||||||
| 96 | Test2::Mock | ||||||||||||
| 97 | Test2::Plugin | ||||||||||||
| 98 | Test2::Plugin::BailOnFail | ||||||||||||
| 99 | Test2::Plugin::DieOnFail | ||||||||||||
| 100 | Test2::Plugin::ExitSummary | ||||||||||||
| 101 | Test2::Plugin::SRand | ||||||||||||
| 102 | Test2::Plugin::UTF8 | ||||||||||||
| 103 | Test2::Require | ||||||||||||
| 104 | Test2::Require::AuthorTesting | ||||||||||||
| 105 | Test2::Require::EnvVar | ||||||||||||
| 106 | Test2::Require::Fork | ||||||||||||
| 107 | Test2::Require::Module | ||||||||||||
| 108 | Test2::Require::Perl | ||||||||||||
| 109 | Test2::Require::RealFork | ||||||||||||
| 110 | Test2::Require::Threads | ||||||||||||
| 111 | Test2::Suite | ||||||||||||
| 112 | Test2::Todo | ||||||||||||
| 113 | Test2::Tools | ||||||||||||
| 114 | Test2::Tools::Basic | ||||||||||||
| 115 | Test2::Tools::Class | ||||||||||||
| 116 | Test2::Tools::ClassicCompare | ||||||||||||
| 117 | Test2::Tools::Compare | ||||||||||||
| 118 | Test2::Tools::Defer | ||||||||||||
| 119 | Test2::Tools::Encoding | ||||||||||||
| 120 | Test2::Tools::Event | ||||||||||||
| 121 | Test2::Tools::Exception | ||||||||||||
| 122 | Test2::Tools::Exports | ||||||||||||
| 123 | Test2::Tools::Grab | ||||||||||||
| 124 | Test2::Tools::Mock | ||||||||||||
| 125 | Test2::Tools::Ref | ||||||||||||
| 126 | Test2::Tools::Subtest | ||||||||||||
| 127 | Test2::Tools::Target | ||||||||||||
| 128 | Test2::Tools::Warnings | ||||||||||||
| 129 | Test2::Util::Grabber | ||||||||||||
| 130 | Test2::Util::Ref | ||||||||||||
| 131 | Test2::Util::Stash | ||||||||||||
| 132 | Test2::Util::Sub | ||||||||||||
| 133 | Test2::Util::Table | ||||||||||||
| 134 | Test2::Util::Table::LineBreak | ||||||||||||
| 135 | ); | ||||||||||||
| 136 | |||||||||||||
| 137 | 7 | foreach my $upgrade ($self->upgrade->@*) | |||||||||||
| 138 | { | ||||||||||||
| 139 | 2 | ▶ | if($upgrade =~ /^\s*(\S+)\s*=\s*(\S+)\s*$/) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 140 | { | ||||||||||||
| 141 | 1 | $upgrades{$1} = $2; | |||||||||||
| 142 | } | ||||||||||||
| 143 | else | ||||||||||||
| 144 | { | ||||||||||||
| 145 | 1 | $self->log_fatal("upgrade failed: $upgrade"); | |||||||||||
| 146 | } | ||||||||||||
| 147 | } | ||||||||||||
| 148 | |||||||||||||
| 149 | 6 | foreach my $phase (keys %$prereqs) | |||||||||||
| 150 | { | ||||||||||||
| 151 | 16 | foreach my $type (keys $prereqs->{$phase}->%*) | |||||||||||
| 152 | { | ||||||||||||
| 153 | 16 | foreach my $module (sort keys $prereqs->{$phase}->{$type}->%*) | |||||||||||
| 154 | { | ||||||||||||
| 155 | 66 | my $value = $prereqs->{$phase}->{$type}->{$module}; | |||||||||||
| 156 | 66 | ▶ | next unless $value == 0; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 157 | 56 | ▶ | if($upgrades{$module}) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 158 | { | ||||||||||||
| 159 | $self->zilla->register_prereqs({ | ||||||||||||
| 160 | type => $type, | ||||||||||||
| 161 | phase => $phase, | ||||||||||||
| 162 | 26 | }, $module => $upgrades{$module} ); | |||||||||||
| 163 | } | ||||||||||||
| 164 | } | ||||||||||||
| 165 | } | ||||||||||||
| 166 | } | ||||||||||||
| 167 | |||||||||||||
| 168 | 6 | foreach my $phase (keys %$prereqs) | |||||||||||
| 169 | { | ||||||||||||
| 170 | 16 | foreach my $type (keys $prereqs->{$phase}->%*) | |||||||||||
| 171 | { | ||||||||||||
| 172 | 16 | foreach my $module (keys $prereqs->{$phase}->{$type}->%*) | |||||||||||
| 173 | { | ||||||||||||
| 174 | 66 | ▶ | if($module =~ /^(JSON|PerlX::Maybe)$/) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 175 | { | ||||||||||||
| 176 | 10 | $self->zilla->register_prereqs({ | |||||||||||
| 177 | type => 'recommends', | ||||||||||||
| 178 | phase => $phase, | ||||||||||||
| 179 | }, join('::', $module, 'XS') => 0 ); | ||||||||||||
| 180 | } | ||||||||||||
| 181 | 66 | ▶ | if($module eq 'JSON::MaybeXS') | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 182 | { | ||||||||||||
| 183 | 5 | $self->zilla->register_prereqs({ | |||||||||||
| 184 | type => 'recommends', | ||||||||||||
| 185 | phase => $phase, | ||||||||||||
| 186 | }, "Cpanel::JSON::XS" => 0); | ||||||||||||
| 187 | } | ||||||||||||
| 188 | 66 | my($first) = split /::/, $module; | |||||||||||
| 189 | 66 | ▶ | if($first =~ /^(AnyEvent|Mojo|Mojolicious)$/) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 190 | { | ||||||||||||
| 191 | 5 | $self->zilla->register_prereqs({ | |||||||||||
| 192 | type => 'recommends', | ||||||||||||
| 193 | phase => $phase, | ||||||||||||
| 194 | }, EV => 0); | ||||||||||||
| 195 | } | ||||||||||||
| 196 | } | ||||||||||||
| 197 | } | ||||||||||||
| 198 | } | ||||||||||||
| 199 | |||||||||||||
| 200 | 6 | ▶ | if(my($perlcritic_file) = grep { $_->name eq 'perlcriticrc' } $self->zilla->files->@*) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 201 | { | ||||||||||||
| 202 | 1 | foreach my $policy (grep { $_ ne '_' } sort keys Config::INI::Reader->read_string($perlcritic_file->content)->%*) | |||||||||||
| 203 | { | ||||||||||||
| 204 | 3 | ▶ | next if $policy =~ /^-/; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 205 | 2 | $self->zilla->register_prereqs({ | |||||||||||
| 206 | type => 'recommends', | ||||||||||||
| 207 | phase => 'develop', | ||||||||||||
| 208 | }, "Perl::Critic::Policy::$policy" => 0); | ||||||||||||
| 209 | } | ||||||||||||
| 210 | } | ||||||||||||
| 211 | |||||||||||||
| 212 | 6 | foreach my $pairs (Dist::Zilla::Util::AuthorDeps::extract_author_deps('.',0)->@*) | |||||||||||
| 213 | { | ||||||||||||
| 214 | 29 | foreach my $module (sort keys $pairs->%*) | |||||||||||
| 215 | { | ||||||||||||
| 216 | 29 | my $version = $pairs->{$module}; | |||||||||||
| 217 | 29 | $self->zilla->register_prereqs({ | |||||||||||
| 218 | type => 'recommends', | ||||||||||||
| 219 | phase => 'develop', | ||||||||||||
| 220 | }, $module => $version); | ||||||||||||
| 221 | } | ||||||||||||
| 222 | } | ||||||||||||
| 223 | |||||||||||||
| 224 | } | ||||||||||||
| 225 | |||||||||||||
| 226 | sub before_release | ||||||||||||
| 227 | 3 | ▶ | { | ||||||||||
|
Subroutine
before_release: called CC=5 SCAR=16.4
Pod
undocumented
| |||||||||||||
| 228 | 3 | my $self = shift; | |||||||||||
| 229 | |||||||||||||
| 230 | 3 | ▶ | if($self->win32) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 231 | { | ||||||||||||
| 232 | 1 | ▶ | if($^O ne 'MSWin32') | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 233 | { | ||||||||||||
| 234 | 1 | $self->log_fatal("This dist must be released on MSWin32"); | |||||||||||
| 235 | } | ||||||||||||
| 236 | } | ||||||||||||
| 237 | else | ||||||||||||
| 238 | { | ||||||||||||
| 239 | 2 | ▶ | if($^O eq 'MSWin32') | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 240 | { | ||||||||||||
| 241 | 1 | $self->log_fatal("This dist is not releasable on MSWin32"); | |||||||||||
| 242 | } | ||||||||||||
| 243 | } | ||||||||||||
| 244 | |||||||||||||
| 245 | 1 | ▶ | unless(Dist::Zilla::Plugin::Author::Plicease->git) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 246 | { | ||||||||||||
| 247 | 0 | $self->log_fatal("release requires git and Dist::Zilla::Plugin::Git to be installed"); | |||||||||||
| 248 | } | ||||||||||||
| 249 | |||||||||||||
| 250 | 1 | $self->log("Okay to release this dist on $^O"); | |||||||||||
| 251 | } | ||||||||||||
| 252 | |||||||||||||
| 253 | sub setup_installer | ||||||||||||
| 254 | 6 | ▶ | { | ||||||||||
|
Subroutine
setup_installer: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||
| 255 | 6 | my($self) = @_; | |||||||||||
| 256 | |||||||||||||
| 257 | 6 | my $prereqs = $self->zilla->prereqs->as_string_hash; | |||||||||||
| 258 | |||||||||||||
| 259 | 6 | ▶ | my $perl_version = $prereqs->{runtime}->{requires}->{perl} // '5.006'; | ||||||||||
|
Condition100%2/2
$prereqs->{"runtime"}{"requires"}{"perl"} // "5.006"
MC/DC100%1/1
$prereqs->{"runtime"}{"requires"}{"perl"} // "5.006"
$prereqs->{"runtime"}{"requires"}{"perl"}
Truth table100%2/2
A
A= $prereqs->{"runtime"}{"requires"}{"perl"}
| |||||||||||||
| 260 | |||||||||||||
| 261 | 6 | $self->log("perl version required = $perl_version"); | |||||||||||
| 262 | |||||||||||||
| 263 | 6 | foreach my $file (grep { $_->name =~ /^(Makefile\.PL|Build\.PL)$/ } $self->zilla->files->@*) | |||||||||||
| 264 | { | ||||||||||||
| 265 | 6 | my $content = $file->content; | |||||||||||
| 266 | $content = join "\n", | ||||||||||||
| 267 | "BEGIN {", | ||||||||||||
| 268 | " use strict; use warnings;", | ||||||||||||
| 269 | 6 | (map { s/^\| / /r } $self->preamble->@*), | |||||||||||
| 270 | " unless(eval q{ use $perl_version; 1}) {", | ||||||||||||
| 271 | " print \"Perl $perl_version or better required\\n\";", | ||||||||||||
| 272 | " exit;", | ||||||||||||
| 273 | " }", | ||||||||||||
| 274 | "}", | ||||||||||||
| 275 | $content; | ||||||||||||
| 276 | 6 | $file->content($content); | |||||||||||
| 277 | } | ||||||||||||
| 278 | } | ||||||||||||
| 279 | |||||||||||||
| 280 | 3 | __PACKAGE__->meta->make_immutable; | |||||||||||
| 281 | } | ||||||||||||
| 282 | |||||||||||||
| 283 | 3 | 1; | |||||||||||
| 284 | |||||||||||||
| 285 | __END__ | ||||||||||||