line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Meta::Prereqs::Filter; |
2
|
|
|
|
|
|
|
$CPAN::Meta::Prereqs::Filter::VERSION = '0.004'; |
3
|
1
|
|
|
1
|
|
45021
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
23
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
4
|
use Exporter 5.57 'import'; |
|
1
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
50
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw/filter_prereqs/; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
4
|
use Carp 'croak'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
10
|
1
|
|
|
1
|
|
4
|
use Scalar::Util 'isvstring'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
705
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my @phases = qw/configure build test runtime develop/; |
13
|
|
|
|
|
|
|
my @relationships = qw/requires recommends suggests/; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my %dependents_for = ( |
16
|
|
|
|
|
|
|
runtime => [ qw/build test develop/ ], |
17
|
|
|
|
|
|
|
configure => [ qw/build test/ ], |
18
|
|
|
|
|
|
|
build => [ 'test' ], |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub _normalize_version { |
22
|
1
|
|
|
1
|
|
3
|
my $raw = shift; |
23
|
1
|
50
|
|
|
|
8
|
if (isvstring($raw)) { |
24
|
0
|
|
|
|
|
0
|
$raw = sprintf 'v%vd', $raw; |
25
|
|
|
|
|
|
|
} |
26
|
1
|
50
|
|
|
|
23
|
if ($raw =~ / \A v5 (?> \. \d+)* \z /x) { |
|
|
50
|
|
|
|
|
|
27
|
0
|
|
|
|
|
0
|
require version; |
28
|
0
|
|
|
|
|
0
|
return sprintf '%7.6f', version->new($raw)->numify; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
elsif ($raw eq 'latest') { |
31
|
0
|
|
|
|
|
0
|
require Module::CoreList; |
32
|
0
|
|
|
|
|
0
|
return (reverse sort keys %Module::CoreList::version)[0]; |
33
|
|
|
|
|
|
|
} |
34
|
1
|
|
|
|
|
12
|
return sprintf '%7.6f', $raw; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub filter_prereqs { |
38
|
3
|
|
|
3
|
1
|
4103
|
my ($prereqs, %args) = @_; |
39
|
3
|
50
|
|
|
|
10
|
return $prereqs if not grep { $_ } values %args; |
|
3
|
|
|
|
|
13
|
|
40
|
3
|
|
|
|
|
13
|
$prereqs = $prereqs->clone; |
41
|
3
|
100
|
|
|
|
3242
|
my $core_version = defined $args{omit_core} ? _normalize_version($args{omit_core}) : undef; |
42
|
3
|
100
|
|
|
|
10
|
if ($core_version) { |
43
|
1
|
|
|
|
|
3972
|
require Module::CoreList; |
44
|
1
|
50
|
|
|
|
50637
|
croak "$core_version is not a known perl version" if not exists $Module::CoreList::version{$core_version}; |
45
|
1
|
|
|
|
|
5
|
for my $phase (@phases) { |
46
|
5
|
|
|
|
|
28
|
for my $relation (@relationships) { |
47
|
15
|
|
|
|
|
101
|
my $req = $prereqs->requirements_for($phase, $relation); |
48
|
|
|
|
|
|
|
|
49
|
15
|
50
|
|
|
|
576
|
$req->clear_requirement('perl') if $req->accepts_module('perl', $core_version); |
50
|
15
|
|
|
|
|
1378
|
for my $module ($req->required_modules) { |
51
|
2
|
100
|
|
|
|
107
|
next if not exists $Module::CoreList::version{$core_version}{$module}; |
52
|
1
|
50
|
|
|
|
18
|
next if not $req->accepts_module($module, $Module::CoreList::version{$core_version}{$module}); |
53
|
1
|
50
|
|
|
|
81
|
next if Module::CoreList->is_deprecated($module, $core_version); |
54
|
1
|
|
|
|
|
32
|
$req->clear_requirement($module); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
} |
59
|
3
|
50
|
|
|
|
12
|
if ($args{sanitize}) { |
60
|
0
|
|
|
|
|
0
|
for my $parent (qw/runtime configure build/) { |
61
|
0
|
|
|
|
|
0
|
for my $child ( @{ $dependents_for{$parent} } ) { |
|
0
|
|
|
|
|
0
|
|
62
|
0
|
|
|
|
|
0
|
for my $relationship (@relationships) { |
63
|
0
|
|
|
|
|
0
|
my $source = $prereqs->requirements_for($parent, $relationship); |
64
|
0
|
|
|
|
|
0
|
my $sink = $prereqs->requirements_for($child, $relationship); |
65
|
0
|
|
|
|
|
0
|
for my $module ($source->required_modules) { |
66
|
0
|
0
|
|
|
|
0
|
next if not defined(my $right = $sink->requirements_for_module($module)); |
67
|
0
|
|
|
|
|
0
|
my $left = $source->requirements_for_module($module); |
68
|
0
|
0
|
0
|
|
|
0
|
$sink->clear_requirement($module) if $left eq $right || $right eq '0'; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
3
|
100
|
|
|
|
10
|
if ($args{only_missing}) { |
75
|
1
|
|
|
|
|
1082
|
require Module::Metadata; |
76
|
1
|
|
|
|
|
5526
|
for my $phase (@phases) { |
77
|
5
|
|
|
|
|
26
|
for my $relation (@relationships) { |
78
|
15
|
|
|
|
|
172
|
my $req = $prereqs->requirements_for($phase, $relation); |
79
|
15
|
50
|
|
|
|
602
|
$req->clear_requirement('perl') if $req->accepts_module('perl', $]); |
80
|
15
|
|
|
|
|
699
|
for my $module ($req->required_modules) { |
81
|
3
|
100
|
|
|
|
630
|
if ($req->requirements_for_module($module)) { |
82
|
1
|
|
|
|
|
16
|
my $metadata = Module::Metadata->new_from_module($module); |
83
|
1
|
50
|
0
|
|
|
524
|
if ($metadata && $req->accepts_module($module, $metadata->version($module) || 0)) { |
|
|
|
33
|
|
|
|
|
84
|
0
|
|
|
|
|
0
|
$req->clear_requirement($module); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else { |
88
|
2
|
50
|
|
|
|
38
|
$req->clear_requirement($module) if Module::Metadata->find_module_by_name($module); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
3
|
|
|
|
|
20
|
return $prereqs; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
1; |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
# ABSTRACT: Filtering various things out of CPAN::Meta::Prereqs |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |