line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::CpanfileSlipstop::Resolver; |
2
|
3
|
|
|
3
|
|
443447
|
use strict; |
|
3
|
|
|
|
|
20
|
|
|
3
|
|
|
|
|
74
|
|
3
|
3
|
|
|
3
|
|
14
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
70
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
13
|
use CPAN::Meta::Requirements; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1173
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub new { |
8
|
17
|
|
|
17
|
0
|
1031861
|
my ($class, %args) = @_; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $self = bless +{ |
11
|
|
|
|
|
|
|
reqs => CPAN::Meta::Requirements->new, |
12
|
|
|
|
|
|
|
cpanfile => $args{cpanfile}, # Module::CPANfile |
13
|
|
|
|
|
|
|
snapshot => $args{snapshot}, # Carton::Snapshot |
14
|
17
|
|
|
|
|
69
|
}, $class; |
15
|
|
|
|
|
|
|
|
16
|
17
|
|
|
|
|
269
|
return $self; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
231
|
|
|
231
|
0
|
569
|
sub reqs { $_[0]->{reqs} } |
20
|
150
|
|
|
150
|
0
|
380
|
sub cpanfile { $_[0]->{cpanfile} } |
21
|
65
|
|
|
65
|
0
|
207
|
sub snapshot { $_[0]->{snapshot} } |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub read_cpanfile_requirements { |
24
|
17
|
|
|
17
|
0
|
143
|
my ($self) = @_; |
25
|
|
|
|
|
|
|
|
26
|
17
|
|
|
|
|
44
|
for my $phase (qw(configure build runtime test develop)) { |
27
|
85
|
|
|
|
|
14572
|
$self->reqs->add_requirements( |
28
|
|
|
|
|
|
|
$self->cpanfile->prereqs->requirements_for($phase, 'requires') |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
# `carton install` only treats 'requires'. |
32
|
|
|
|
|
|
|
# https://metacpan.org/source/MIYAGAWA/Carton-v1.0.34/lib/Carton/CPANfile.pm#L38 |
33
|
|
|
|
|
|
|
|
34
|
17
|
|
|
|
|
875
|
return; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub merge_snapshot_versions { |
38
|
18
|
|
|
18
|
0
|
118
|
my ($self, $merge_method, $with_core) = @_; |
39
|
|
|
|
|
|
|
|
40
|
18
|
100
|
|
|
|
55
|
my $find_method = $with_core ? 'find_or_core' : 'find'; |
41
|
|
|
|
|
|
|
|
42
|
18
|
|
|
|
|
24
|
my $cpanfile_modules = [ keys %{$self->reqs->as_string_hash} ]; |
|
18
|
|
|
|
|
39
|
|
43
|
|
|
|
|
|
|
|
44
|
18
|
|
|
|
|
2038
|
for my $module (@$cpanfile_modules) { |
45
|
65
|
50
|
|
|
|
3372
|
next if $self->ignore_module($module); # skip modules url specified |
46
|
|
|
|
|
|
|
|
47
|
65
|
|
|
|
|
123
|
my $installed_dist = $self->snapshot->$find_method($module); |
48
|
65
|
100
|
|
|
|
44786
|
if ($installed_dist) { |
49
|
59
|
|
|
|
|
146
|
my $version = $installed_dist->version_for($module); |
50
|
59
|
50
|
|
|
|
1183
|
$self->reqs->$merge_method($module, $version) if $version; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub ignore_module { |
56
|
65
|
|
|
65
|
0
|
140
|
my ($self, $module) = @_; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# ignore like this. |
59
|
|
|
|
|
|
|
# |
60
|
|
|
|
|
|
|
# requires 'Class::Enumemon', |
61
|
|
|
|
|
|
|
# mirror => 'https://cpan.metacpan.org/', |
62
|
|
|
|
|
|
|
# dist => 'POKUTUNA/Class-Enumemon-0.01.tar.gz'; |
63
|
|
|
|
|
|
|
|
64
|
65
|
|
50
|
|
|
112
|
my $opts = $self->cpanfile->options_for_module($module) || {}; |
65
|
65
|
50
|
|
|
|
1957
|
return 1 if $opts->{dist}; |
66
|
65
|
50
|
|
|
|
154
|
return 1 if $opts->{url}; |
67
|
65
|
|
|
|
|
119
|
return 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub get_version_range { |
71
|
69
|
|
|
69
|
0
|
708
|
my ($self, $module) = @_; |
72
|
|
|
|
|
|
|
|
73
|
69
|
|
|
|
|
135
|
my $version_range = $self->reqs->requirements_for_module($module); |
74
|
|
|
|
|
|
|
|
75
|
69
|
100
|
66
|
|
|
2259
|
return undef if !$version_range || $version_range eq '0'; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# Remove noisy '>= 0'. |
78
|
|
|
|
|
|
|
# This causes when setting version by "add_maximum" |
79
|
59
|
|
|
|
|
128
|
$version_range =~ s/\A>= 0, //; |
80
|
|
|
|
|
|
|
|
81
|
59
|
|
|
|
|
157
|
return $version_range; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |