line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
364
|
use 5.006; # our |
|
1
|
|
|
|
|
2
|
|
2
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
15
|
|
3
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
56
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Author::KENTNL::MinimumPerl; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: The MinimumPerl Plugin with a few hacks |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '2.025021'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
411
|
use Moose qw( has extends override around ); |
|
1
|
|
|
|
|
289242
|
|
|
1
|
|
|
|
|
7
|
|
26
|
1
|
|
|
1
|
|
4745
|
use Dist::Zilla::Plugin::MinimumPerl 1.004; |
|
1
|
|
|
|
|
431359
|
|
|
1
|
|
|
|
|
46
|
|
27
|
|
|
|
|
|
|
extends 'Dist::Zilla::Plugin::MinimumPerl'; |
28
|
1
|
|
|
1
|
|
8
|
use namespace::autoclean; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
9
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
around dump_config => sub { |
31
|
|
|
|
|
|
|
my ( $orig, $self, @args ) = @_; |
32
|
|
|
|
|
|
|
my $config = $self->$orig(@args); |
33
|
|
|
|
|
|
|
my $localconf = $config->{ +__PACKAGE__ } = {}; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
if ( $self->meta->find_attribute_by_name('detected_perl')->has_value($self) ) { |
36
|
|
|
|
|
|
|
$localconf->{detected_perl} = $self->detected_perl; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
if ( $self->meta->find_attribute_by_name('fiveten')->has_value($self) ) { |
39
|
|
|
|
|
|
|
$localconf->{fiveten} = $self->fiveten; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION |
43
|
|
|
|
|
|
|
unless __PACKAGE__ eq ref $self; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return $config; |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has 'detected_perl' => ( |
49
|
|
|
|
|
|
|
is => 'rw', |
50
|
|
|
|
|
|
|
isa => 'Object', |
51
|
|
|
|
|
|
|
lazy_build => 1, |
52
|
|
|
|
|
|
|
); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
has 'fiveten' => ( |
55
|
|
|
|
|
|
|
isa => 'Bool', |
56
|
|
|
|
|
|
|
is => 'rw', |
57
|
|
|
|
|
|
|
default => sub { undef }, |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
override register_prereqs => sub { |
61
|
|
|
|
|
|
|
my ($self) = @_; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
my $minperl = $self->minperl; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->log_debug( [ 'Minimum Perl is v%s', $minperl ] ); |
66
|
|
|
|
|
|
|
$self->zilla->register_prereqs( { phase => 'runtime' }, perl => $minperl->stringify, ); |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
1
|
|
|
1
|
|
270
|
no Moose; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
7
|
|
70
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _3part_check { |
73
|
0
|
|
|
0
|
|
|
my ( $self, $file, $pmv, $minver ) = @_; |
74
|
0
|
|
|
|
|
|
my $perl_required = version->parse('5.10.0'); |
75
|
0
|
0
|
|
|
|
|
return $minver if $minver >= $perl_required; |
76
|
0
|
|
|
|
|
|
my $document = $pmv->Document; |
77
|
|
|
|
|
|
|
my $version_declaration = sub { |
78
|
0
|
0
|
|
0
|
|
|
$_[1]->isa('PPI::Token::Symbol') and $_[1]->content =~ /::VERSION\z/msx; |
79
|
0
|
|
|
|
|
|
}; |
80
|
|
|
|
|
|
|
my $version_match = sub { |
81
|
0
|
0
|
|
0
|
|
|
'PPI::Token::Quote::Single' eq $_[1]->class and $_[1]->parent->find_any($version_declaration); |
82
|
0
|
|
|
|
|
|
}; |
83
|
0
|
0
|
|
|
|
|
my (@versions) = @{ $document->find($version_match) || [] }; |
|
0
|
|
|
|
|
|
|
84
|
0
|
|
|
|
|
|
for my $versiondecl (@versions) { |
85
|
|
|
|
|
|
|
next |
86
|
0
|
0
|
|
|
|
|
if $minver >= $perl_required; |
87
|
|
|
|
|
|
|
## no critic (ProhibitStringyEval) |
88
|
0
|
|
|
|
|
|
my $v = eval $versiondecl; |
89
|
0
|
0
|
|
|
|
|
if ( $v =~ /\A\d+[.]\d+[.]/msx ) { |
90
|
0
|
|
|
|
|
|
$minver = $perl_required; |
91
|
0
|
|
|
|
|
|
$self->log_debug( [ 'Upgraded to %s due to %s having x.y.z', $minver, $file->name ] ); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
0
|
|
|
|
|
|
return $minver; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _build_detected_perl { |
98
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
99
|
0
|
|
|
|
|
|
my $minver; |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
foreach my $file ( @{ $self->found_files } ) { |
|
0
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# TODO should we scan the content for the perl shebang? |
104
|
|
|
|
|
|
|
# Only check .t and .pm/pl files, thanks RT#67355 and DOHERTY |
105
|
0
|
0
|
|
|
|
|
next unless $file->name =~ /[.](?:t|p[ml])\z/imsx; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
# TODO skip "bad" files and not die, just warn? |
108
|
0
|
|
|
|
|
|
my $pmv = Perl::MinimumVersion->new( \$file->content ); |
109
|
0
|
0
|
|
|
|
|
if ( not defined $pmv ) { |
110
|
0
|
|
|
|
|
|
$self->log_fatal( [ 'Unable to parse \'%s\'', $file->name ] ); |
111
|
|
|
|
|
|
|
} |
112
|
0
|
|
|
|
|
|
my $ver = $pmv->minimum_version; |
113
|
0
|
0
|
|
|
|
|
if ( not defined $ver ) { |
114
|
0
|
|
|
|
|
|
$self->log_fatal( [ 'Unable to extract MinimumPerl from \'%s\'', $file->name ] ); |
115
|
|
|
|
|
|
|
} |
116
|
0
|
0
|
0
|
|
|
|
if ( ( not defined $minver ) or $ver > $minver ) { |
117
|
0
|
|
|
|
|
|
$self->log_debug( [ 'Increasing perl dep to %s due to %s', $ver, $file->name ] ); |
118
|
0
|
|
|
|
|
|
$minver = $ver; |
119
|
|
|
|
|
|
|
} |
120
|
0
|
0
|
|
|
|
|
if ( $self->fiveten ) { |
121
|
0
|
|
|
|
|
|
$ver = $self->_3part_check( $file, $pmv, $minver ); |
122
|
0
|
0
|
|
|
|
|
if ( "$ver" ne "$minver" ) { |
123
|
0
|
|
|
|
|
|
$self->log_debug( [ 'Increasing perl dep to %s due to 3-part in %s', $ver, $file->name ] ); |
124
|
0
|
|
|
|
|
|
$minver = $ver; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# Write out the minimum perl found |
130
|
0
|
0
|
|
|
|
|
if ( defined $minver ) { |
131
|
0
|
|
|
|
|
|
return $minver; |
132
|
|
|
|
|
|
|
} |
133
|
0
|
|
|
|
|
|
return $self->log_fatal('Found no perl files, check your dist?'); |
134
|
|
|
|
|
|
|
} |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
sub minperl { |
143
|
0
|
|
|
0
|
1
|
|
require version; |
144
|
0
|
|
|
|
|
|
my $self = shift; |
145
|
0
|
0
|
|
|
|
|
if ( not $self->_has_perl ) { |
146
|
0
|
|
|
|
|
|
return $self->detected_perl; |
147
|
|
|
|
|
|
|
} |
148
|
0
|
|
|
|
|
|
my ($x) = version->parse( $self->perl ); |
149
|
0
|
|
|
|
|
|
my ($y) = $self->detected_perl; |
150
|
0
|
0
|
|
|
|
|
if ( $x > $y ) { |
151
|
0
|
|
|
|
|
|
return $x; |
152
|
|
|
|
|
|
|
} |
153
|
0
|
|
|
|
|
|
return $y; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
__END__ |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=pod |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=encoding UTF-8 |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=head1 NAME |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Author::KENTNL::MinimumPerl - The MinimumPerl Plugin with a few hacks |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 VERSION |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
version 2.025021 |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 METHODS |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 C<minperl> |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
Returns the maximum of either the version requested for Perl, or the version detected for Perl. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=begin MetaPOD::JSON v1.1.0 |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
{ |
181
|
|
|
|
|
|
|
"namespace":"Dist::Zilla::Plugin::Author::KENTNL::MinimumPerl", |
182
|
|
|
|
|
|
|
"interface":"class", |
183
|
|
|
|
|
|
|
"inherits":"Dist::Zilla::Plugin::MinimumPerl" |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=end MetaPOD::JSON |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=head1 AUTHOR |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
198
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=cut |