line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::Midgen::Role::Experimental; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.33_05'; |
4
|
|
|
|
|
|
|
$VERSION = eval $VERSION; ## no critic |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
1035
|
use constant {THREE => 3,}; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
154
|
|
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
9
|
use Types::Standard qw( Bool ); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
19
|
|
9
|
2
|
|
|
2
|
|
871
|
use Moo::Role; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
10
|
|
10
|
|
|
|
|
|
|
#requires qw( debug ); |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
3498
|
use Try::Tiny; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
101
|
|
13
|
2
|
|
|
2
|
|
7
|
use Data::Printer {caller_info => 1,}; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
16
|
|
14
|
2
|
|
|
2
|
|
1555
|
use Term::ANSIColor qw( :constants colored colorstrip ); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
590
|
|
15
|
2
|
|
|
2
|
|
11
|
use List::MoreUtils qw(firstidx); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
18
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
####### |
19
|
|
|
|
|
|
|
# composed method degree of separation |
20
|
|
|
|
|
|
|
# parent A::B - child A::B::C |
21
|
|
|
|
|
|
|
####### |
22
|
|
|
|
|
|
|
sub degree_separation { |
23
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
24
|
0
|
|
|
|
|
|
my $parent = shift; |
25
|
0
|
|
|
|
|
|
my $child = shift; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Use of implicit split to @_ is deprecated |
28
|
0
|
|
|
|
|
|
my $parent_score = @{[split /::/, $parent]}; |
|
0
|
|
|
|
|
|
|
29
|
0
|
|
|
|
|
|
my $child_score = @{[split /::/, $child]}; |
|
0
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
warn 'parent - ' . $parent . ' score - ' . $parent_score if $self->debug; |
31
|
0
|
0
|
|
|
|
|
warn 'child - ' . $child . ' score - ' . $child_score if $self->debug; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# switch around for a positive number |
34
|
0
|
|
|
|
|
|
return $child_score - $parent_score; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
####### |
39
|
|
|
|
|
|
|
# remove_noisy_children |
40
|
|
|
|
|
|
|
####### |
41
|
|
|
|
|
|
|
sub remove_noisy_children { |
42
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
43
|
0
|
|
0
|
|
|
|
my $required_ref = shift || return; |
44
|
0
|
|
|
|
|
|
my @sorted_modules; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
foreach my $module_name (sort keys %{$required_ref}) { |
|
0
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
push @sorted_modules, $module_name; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
0
|
|
|
|
|
p @sorted_modules if $self->debug; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
foreach my $parent_name (@sorted_modules) { |
53
|
0
|
|
|
0
|
|
|
my $outer_index = firstidx { $_ eq $parent_name } @sorted_modules; |
|
0
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# inc so we don't end up with parent eq child |
56
|
0
|
|
|
|
|
|
$outer_index++; |
57
|
0
|
|
|
|
|
|
foreach my $inner_index ($outer_index .. $#sorted_modules) { |
58
|
0
|
|
|
|
|
|
my $child_name = $sorted_modules[$inner_index]; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# we just caught an undef |
61
|
0
|
0
|
|
|
|
|
next if not defined $child_name; |
62
|
0
|
0
|
|
|
|
|
if ($child_name =~ /^ $parent_name ::/x) { |
63
|
|
|
|
|
|
|
|
64
|
0
|
|
|
|
|
|
my $valied_seperation = 1; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# as we only do this against -x, why not be extra vigilant |
67
|
0
|
0
|
|
|
|
|
$valied_seperation = THREE |
68
|
|
|
|
|
|
|
if $parent_name =~ /^Dist::Zilla|Moose|MooseX|Moo|Mouse/; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Checking for one degree of separation |
71
|
|
|
|
|
|
|
# ie A::B -> A::B::C is ok but A::B::C::D is not |
72
|
0
|
0
|
|
|
|
|
if ($self->degree_separation($parent_name, $child_name) |
73
|
|
|
|
|
|
|
<= $valied_seperation) |
74
|
|
|
|
|
|
|
{ |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Test for same version number |
77
|
0
|
0
|
|
|
|
|
if (colorstrip($required_ref->{$parent_name}) eq |
78
|
|
|
|
|
|
|
colorstrip($required_ref->{$child_name})) |
79
|
|
|
|
|
|
|
{ |
80
|
0
|
0
|
|
|
|
|
if (not $self->quiet) { |
81
|
0
|
0
|
|
|
|
|
if ($self->verbose) { |
82
|
0
|
|
|
|
|
|
print BRIGHT_BLACK; |
83
|
|
|
|
|
|
|
print 'delete miscreant noisy child ' |
84
|
|
|
|
|
|
|
. $child_name . ' => ' |
85
|
0
|
|
|
|
|
|
. $required_ref->{$child_name}; |
86
|
0
|
|
|
|
|
|
print CLEAR. "\n"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
try { |
90
|
0
|
|
|
0
|
|
|
delete $required_ref->{$child_name}; |
91
|
0
|
|
|
|
|
|
splice @sorted_modules, $inner_index, 1; |
92
|
|
|
|
|
|
|
|
93
|
0
|
0
|
|
|
|
|
unless ($self->{modules}{$parent_name}) { |
94
|
0
|
|
|
|
|
|
$self->{modules}{$parent_name}{prereqs} = 'expermental'; |
95
|
|
|
|
|
|
|
$self->{modules}{$parent_name}{version} |
96
|
0
|
|
|
|
|
|
= $required_ref->{$parent_name}; |
97
|
0
|
|
|
|
|
|
$self->{modules}{$parent_name}{count} += 1; |
98
|
|
|
|
|
|
|
} |
99
|
0
|
|
|
|
|
|
}; |
100
|
0
|
0
|
|
|
|
|
p @sorted_modules if $self->debug; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# we need to redo as we just deleted a child |
103
|
0
|
|
|
|
|
|
redo; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
else { |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# not my child so lets try the next one |
109
|
0
|
|
|
|
|
|
next; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
else { |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
# no more like the parent so lets start again |
116
|
0
|
|
|
|
|
|
last; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
} |
120
|
0
|
|
|
|
|
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
####### |
125
|
|
|
|
|
|
|
# remove_twins |
126
|
|
|
|
|
|
|
####### |
127
|
|
|
|
|
|
|
sub remove_twins { |
128
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
129
|
0
|
|
0
|
|
|
|
my $required_ref = shift || return; |
130
|
0
|
|
|
|
|
|
my @sorted_modules; |
131
|
0
|
|
|
|
|
|
foreach my $module_name (sort keys %{$required_ref}) { |
|
0
|
|
|
|
|
|
|
132
|
0
|
|
|
|
|
|
push @sorted_modules, $module_name; |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
0
|
0
|
|
|
|
|
p @sorted_modules if $self->debug; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# exit if only 1 Module found |
138
|
0
|
0
|
|
|
|
|
return if $#sorted_modules == 0; |
139
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
|
my $n = 0; |
141
|
0
|
|
|
|
|
|
while ($sorted_modules[$n]) { |
142
|
|
|
|
|
|
|
|
143
|
0
|
|
|
|
|
|
my $dum_name = $sorted_modules[$n]; |
144
|
0
|
|
|
|
|
|
my $dum_parient = $dum_name; |
145
|
0
|
|
|
|
|
|
$dum_parient =~ s/(::\w+)$//; |
146
|
|
|
|
|
|
|
|
147
|
0
|
|
|
|
|
|
my $dee_parient; |
148
|
|
|
|
|
|
|
my $dee_name; |
149
|
0
|
0
|
|
|
|
|
if (($n + 1) <= $#sorted_modules) { |
150
|
0
|
|
|
|
|
|
$n++; |
151
|
0
|
|
|
|
|
|
$dee_name = $sorted_modules[$n]; |
152
|
0
|
|
|
|
|
|
$dee_parient = $dee_name; |
153
|
0
|
|
|
|
|
|
$dee_parient =~ s/(::\w+)$//; |
154
|
|
|
|
|
|
|
} |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
# Checking for same patient and score |
157
|
0
|
0
|
0
|
|
|
|
if ( $dum_parient eq $dee_parient |
158
|
|
|
|
|
|
|
&& $self->degree_separation($dum_name, $dee_name) == 0) |
159
|
|
|
|
|
|
|
{ |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# Test for same version number |
162
|
0
|
0
|
|
|
|
|
if ($required_ref->{$sorted_modules[$n - 1]} eq |
163
|
|
|
|
|
|
|
$required_ref->{$sorted_modules[$n]}) |
164
|
|
|
|
|
|
|
{ |
165
|
0
|
0
|
|
|
|
|
if (not $self->quiet) { |
166
|
0
|
0
|
|
|
|
|
if ($self->verbose) { |
167
|
0
|
|
|
|
|
|
print BRIGHT_BLACK; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
# stdout - 'i have found twins'; |
170
|
|
|
|
|
|
|
print $dum_name . ' => ' |
171
|
0
|
|
|
|
|
|
. $required_ref->{$sorted_modules[$n - 1]}; |
172
|
|
|
|
|
|
|
print BRIGHT_BLACK ' <-twins-> ' |
173
|
|
|
|
|
|
|
. $dee_name . ' => ' |
174
|
0
|
|
|
|
|
|
. $required_ref->{$sorted_modules[$n]}; |
175
|
0
|
|
|
|
|
|
print CLEAR "\n"; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
#Check for valid parent |
180
|
0
|
|
|
|
|
|
my $version; |
181
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
$version = $self->get_module_version($dum_parient); |
183
|
|
|
|
|
|
|
|
184
|
0
|
0
|
|
|
|
|
if (version::is_lax($version)) { |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
#Check parent version against a twins version |
187
|
0
|
0
|
|
|
|
|
if ($version eq $required_ref->{$sorted_modules[$n]}) { |
188
|
0
|
0
|
|
|
|
|
print $dum_parient . ' -> ' |
189
|
|
|
|
|
|
|
. $version |
190
|
|
|
|
|
|
|
. " is the parent of these twins\n" |
191
|
|
|
|
|
|
|
if $self->verbose; |
192
|
0
|
|
|
|
|
|
$required_ref->{$dum_parient} = $version; |
193
|
0
|
|
|
|
|
|
$self->_set_found_twins(1); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
} |
196
|
|
|
|
|
|
|
} |
197
|
|
|
|
|
|
|
} |
198
|
0
|
0
|
|
|
|
|
$n++ if ($n == $#sorted_modules); |
199
|
|
|
|
|
|
|
} |
200
|
0
|
|
|
|
|
|
return; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
2
|
|
|
2
|
|
2187
|
no Moo::Role; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
11
|
|
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
1; |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
__END__ |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=pod |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=encoding UTF-8 |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=head1 NAME |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
App::Midgen::Roles::Experimental - used by L<App::Midgen> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=head1 VERSION |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
version: 0.33_05 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=head1 METHODS |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=over 4 |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * degree_separation |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
now a separate Method, returns an integer. |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * remove_noisy_children |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
Parent A::B has noisy Children A::B::C and A::B::D all with same version number. |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * remove_twins |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
Twins E::F::G and E::F::H have a parent E::F with same version number, |
236
|
|
|
|
|
|
|
so we add a parent E::F and re-test for noisy children, |
237
|
|
|
|
|
|
|
catching triplets along the way. |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=item * run |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=back |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 AUTHOR |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
See L<App::Midgen> |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=head2 CONTRIBUTORS |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
See L<App::Midgen> |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=head1 COPYRIGHT |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
See L<App::Midgen> |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head1 LICENSE |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
258
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
259
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
=cut |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
|
270
|
|
|
|
|
|
|
|