| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::Midgen::Role::Heuristics; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.33_05'; |
|
4
|
|
|
|
|
|
|
$VERSION = eval $VERSION; ## no critic |
|
5
|
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1059
|
use constant {TRUE => 1, FALSE => 0, ONE => 1, TWO => 2}; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
166
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use Types::Standard qw( Bool ); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
11
|
|
|
9
|
2
|
|
|
2
|
|
643
|
use Moo::Role; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
12
|
|
|
10
|
|
|
|
|
|
|
requires qw( debug meta2 format ); |
|
11
|
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
3526
|
use Try::Tiny; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
112
|
|
|
13
|
2
|
|
|
2
|
|
9
|
use Data::Printer {caller_info => 1,}; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
14
|
|
|
14
|
2
|
|
|
2
|
|
1556
|
use Term::ANSIColor qw( :constants colored colorstrip ); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
1938
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
####### |
|
18
|
|
|
|
|
|
|
# correct incorrectly cast modules as RuntimeRecommends and re-cast as RuntimeRequires |
|
19
|
|
|
|
|
|
|
# recast_to_runtimerequires |
|
20
|
|
|
|
|
|
|
####### |
|
21
|
|
|
|
|
|
|
sub recast_to_runtimerequires { |
|
22
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
23
|
0
|
|
0
|
|
|
|
my $requires_ref = shift || return; |
|
24
|
0
|
|
0
|
|
|
|
my $recommends_ref = shift || return; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
#extract module names to check from RuntimeRecommends bucket |
|
27
|
0
|
|
|
|
|
|
my @runtime_recommends; |
|
28
|
0
|
|
|
|
|
|
foreach my $current_recommends (sort keys %{$recommends_ref}) { |
|
|
0
|
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
push @runtime_recommends, $current_recommends; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
foreach my $module (@runtime_recommends) { |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
#2nd part of mro - MRO::Compat catch |
|
35
|
0
|
0
|
0
|
|
|
|
if ( $module eq 'MRO::Compat' and $self->meta2 == FALSE ) { |
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
0
|
|
|
|
|
print "recasting - $module\n" if ($self->verbose == TWO); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# add to RuntimeRequires bucket |
|
40
|
0
|
|
|
|
|
|
$requires_ref->{$module} = $recommends_ref->{$module}; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# delete from RuntimeRecommends bucket |
|
43
|
0
|
|
|
|
|
|
delete $recommends_ref->{$module}; |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# update modules bucket |
|
46
|
0
|
|
|
|
|
|
$self->{modules}{$module}{prereqs} = 'RuntimeRequires'; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# an ode to negitave logic :) |
|
50
|
|
|
|
|
|
|
try { |
|
51
|
0
|
0
|
0
|
0
|
|
|
unless ($self->{modules}{$module}{dual_life} |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
52
|
|
|
|
|
|
|
or $self->{modules}{$module}{corelist} == 1 |
|
53
|
|
|
|
|
|
|
or $self->{modules}{$module}{version} eq '!mcpan' |
|
54
|
|
|
|
|
|
|
or $self->{modules}{$module}{count} == 1) |
|
55
|
|
|
|
|
|
|
{ |
|
56
|
0
|
0
|
|
|
|
|
if ($self->_rc_requires($module, $self->{modules}{$module}{infiles})) |
|
57
|
|
|
|
|
|
|
{ |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# add to RuntimeRequires bucket |
|
60
|
0
|
|
|
|
|
|
$requires_ref->{$module} = $recommends_ref->{$module}; |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# delete from RuntimeRecommends bucket |
|
63
|
0
|
|
|
|
|
|
delete $recommends_ref->{$module}; |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# update modules bucket |
|
66
|
0
|
|
|
|
|
|
$self->{modules}{$module}{prereqs} = 'RuntimeRequires'; |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
|
print BRIGHT_BLACK |
|
69
|
|
|
|
|
|
|
. 'Info: re-cast module ' |
|
70
|
|
|
|
|
|
|
. $module |
|
71
|
|
|
|
|
|
|
. ' to RuntimeRequires' |
|
72
|
|
|
|
|
|
|
. CLEAR . "\n" if ($self->verbose >= ONE); |
|
73
|
0
|
0
|
|
|
|
|
p $self->{modules}{$module} if ($self->verbose == TWO); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
|
}; |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
return; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
## this may help for future hacking |
|
83
|
|
|
|
|
|
|
# [0] "/lib/Module/Install/Admin/Metadata.pm", |
|
84
|
|
|
|
|
|
|
# [1] 0, |
|
85
|
|
|
|
|
|
|
# [2] "Perl::PrereqScanner", |
|
86
|
|
|
|
|
|
|
# [3] "RuntimeRequires" |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
####### |
|
90
|
|
|
|
|
|
|
# composed method _rc_requires |
|
91
|
|
|
|
|
|
|
####### |
|
92
|
|
|
|
|
|
|
sub _rc_requires { |
|
93
|
0
|
|
|
0
|
|
|
my ($self, $module, $infile) = @_; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
foreach my $index (0 .. $#{$infile}) { |
|
|
0
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
# next if in a test dir |
|
98
|
0
|
0
|
|
|
|
|
next if $infile->[$index][0] =~ m/\A\/x?t/; |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
# ignore RuntimeRecommends |
|
101
|
0
|
0
|
|
|
|
|
next if $infile->[$index][3] eq 'RuntimeRecommends'; |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# find RuntimeRequires which are not from same file |
|
104
|
0
|
0
|
0
|
|
|
|
if ($infile->[$index][3] eq 'RuntimeRequires' |
|
105
|
|
|
|
|
|
|
and ($infile->[$index][0] ne $infile->[$index - 1][0])) |
|
106
|
|
|
|
|
|
|
{ |
|
107
|
0
|
0
|
|
|
|
|
p $module if $self->debug; |
|
108
|
0
|
0
|
|
|
|
|
p $infile->[$index] if $self->debug; |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
# found |
|
111
|
0
|
|
|
|
|
|
return TRUE; |
|
112
|
|
|
|
|
|
|
} |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
0
|
|
|
|
|
|
return FALSE; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
####### |
|
121
|
|
|
|
|
|
|
# correct incorrectly cast modules as TestSuggests and re-cast as TestRequires |
|
122
|
|
|
|
|
|
|
# recast_to_testrequires |
|
123
|
|
|
|
|
|
|
####### |
|
124
|
|
|
|
|
|
|
sub recast_to_testrequires { |
|
125
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
126
|
0
|
|
0
|
|
|
|
my $requires_ref = shift || return; |
|
127
|
0
|
|
0
|
|
|
|
my $suggests_ref = shift || return; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
#extract module names to check from RuntimeRecommends bucket |
|
130
|
0
|
|
|
|
|
|
my @test_suggests; |
|
131
|
0
|
|
|
|
|
|
foreach my $current_suggests (sort keys %{$suggests_ref}) { |
|
|
0
|
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
push @test_suggests, $current_suggests; |
|
133
|
|
|
|
|
|
|
} |
|
134
|
|
|
|
|
|
|
|
|
135
|
0
|
|
|
|
|
|
foreach my $module (@test_suggests) { |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# an ode to negitave logic :) |
|
138
|
|
|
|
|
|
|
try { |
|
139
|
0
|
0
|
0
|
0
|
|
|
unless ($self->{modules}{$module}{dual_life} |
|
|
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
140
|
|
|
|
|
|
|
or $self->{modules}{$module}{corelist} == 1 |
|
141
|
|
|
|
|
|
|
or $self->{modules}{$module}{version} eq '!mcpan' |
|
142
|
|
|
|
|
|
|
or $self->{modules}{$module}{count} == 1) |
|
143
|
|
|
|
|
|
|
{ |
|
144
|
0
|
0
|
|
|
|
|
if ($self->_rc_tests($module, $self->{modules}{$module}{infiles})) { |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# add to RuntimeRequires bucket |
|
147
|
0
|
|
|
|
|
|
$requires_ref->{$module} = $suggests_ref->{$module}; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
# delete from RuntimeRecommends bucket |
|
150
|
0
|
|
|
|
|
|
delete $suggests_ref->{$module}; |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
# update modules bucket |
|
153
|
0
|
|
|
|
|
|
$self->{modules}{$module}{prereqs} = 'TestRequires'; |
|
154
|
|
|
|
|
|
|
|
|
155
|
0
|
0
|
|
|
|
|
print BRIGHT_BLACK |
|
156
|
|
|
|
|
|
|
. 'Info: re-cast module ' |
|
157
|
|
|
|
|
|
|
. $module |
|
158
|
|
|
|
|
|
|
. ' to TestRequires' |
|
159
|
|
|
|
|
|
|
. CLEAR . "\n" if ($self->verbose >= ONE); |
|
160
|
0
|
0
|
|
|
|
|
p $self->{modules}{$module} if $self->debug; |
|
161
|
|
|
|
|
|
|
} |
|
162
|
|
|
|
|
|
|
} |
|
163
|
0
|
|
|
|
|
|
}; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
0
|
|
|
|
|
|
return; |
|
167
|
|
|
|
|
|
|
} |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
## this may help for future hacking |
|
170
|
|
|
|
|
|
|
# [0] "/lib/Module/Install/Admin/Metadata.pm", |
|
171
|
|
|
|
|
|
|
# [1] 0, |
|
172
|
|
|
|
|
|
|
# [2] "Perl::PrereqScanner", |
|
173
|
|
|
|
|
|
|
# [3] "RuntimeRequires" |
|
174
|
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
####### |
|
177
|
|
|
|
|
|
|
# composed method _rc_requires |
|
178
|
|
|
|
|
|
|
####### |
|
179
|
|
|
|
|
|
|
sub _rc_tests { |
|
180
|
0
|
|
|
0
|
|
|
my ($self, $module, $infile) = @_; |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
foreach my $index (0 .. $#{$infile}) { |
|
|
0
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# next if in a test dir |
|
185
|
0
|
0
|
|
|
|
|
next if $infile->[$index][0] !~ m/\At/; |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# ignore RuntimeRecommends |
|
188
|
0
|
0
|
|
|
|
|
next if $infile->[$index][3] eq 'TestSuggests'; |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# find RuntimeRequires which are not from same file |
|
191
|
0
|
0
|
0
|
|
|
|
if ($infile->[$index][3] eq 'TestRequires' |
|
192
|
|
|
|
|
|
|
and ($infile->[$index][0] ne $infile->[$index - 1][0])) |
|
193
|
|
|
|
|
|
|
{ |
|
194
|
0
|
0
|
|
|
|
|
p $module if $self->debug; |
|
195
|
0
|
0
|
|
|
|
|
p $infile->[$index] if $self->debug; |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
# found |
|
198
|
0
|
|
|
|
|
|
return TRUE; |
|
199
|
|
|
|
|
|
|
} |
|
200
|
|
|
|
|
|
|
} |
|
201
|
|
|
|
|
|
|
|
|
202
|
0
|
|
|
|
|
|
return FALSE; |
|
203
|
|
|
|
|
|
|
} |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
####### |
|
206
|
|
|
|
|
|
|
# remove_inc_mi |
|
207
|
|
|
|
|
|
|
# just some belt n braces tidying up |
|
208
|
|
|
|
|
|
|
####### |
|
209
|
|
|
|
|
|
|
sub remove_inc_mi { |
|
210
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
211
|
|
|
|
|
|
|
|
|
212
|
0
|
0
|
|
|
|
|
if ($self->{format} eq 'dsl') { |
|
213
|
0
|
|
|
|
|
|
delete $self->{modules}{'inc::Module::Install::DSL'}; |
|
214
|
|
|
|
|
|
|
} |
|
215
|
0
|
0
|
|
|
|
|
if ($self->{format} eq 'mi') { |
|
216
|
0
|
|
|
|
|
|
delete $self->{modules}{'inc::Module::Install'}; |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
|
return; |
|
220
|
|
|
|
|
|
|
} |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
|
|
223
|
2
|
|
|
2
|
|
11
|
no Moo::Role; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
10
|
|
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
1; |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
__END__ |
|
228
|
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=pod |
|
230
|
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=encoding UTF-8 |
|
232
|
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=head1 NAME |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
App::Midgen::Roles::Heuristics - used by L<App::Midgen> |
|
236
|
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=head1 VERSION |
|
238
|
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
version: 0.33_05 |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 METHODS |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=over 4 |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=item * recast_to_runtimerequires |
|
246
|
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
Correct incorrectly cast modules as RuntimeRecommends and re-cast as RuntimeRequires |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item * recast_to_testrequires |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
Correct incorrectly cast modules as TestSuggests and re-cast as TestRequires |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
=item * remove_inc_mi |
|
254
|
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=back |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=head1 AUTHOR |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
See L<App::Midgen> |
|
260
|
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=head2 CONTRIBUTORS |
|
262
|
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
See L<App::Midgen> |
|
264
|
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
See L<App::Midgen> |
|
268
|
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
=head1 LICENSE |
|
270
|
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
|
272
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=cut |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
|