line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::CPANfile::Prereqs; |
2
|
6
|
|
|
6
|
|
23
|
use strict; |
|
6
|
|
|
|
|
8
|
|
|
6
|
|
|
|
|
141
|
|
3
|
6
|
|
|
6
|
|
24
|
use Carp (); |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
123
|
|
4
|
6
|
|
|
6
|
|
3001
|
use CPAN::Meta::Feature; |
|
6
|
|
|
|
|
54431
|
|
|
6
|
|
|
|
|
199
|
|
5
|
6
|
|
|
6
|
|
2830
|
use Module::CPANfile::Prereq; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
4186
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub from_cpan_meta { |
8
|
1
|
|
|
1
|
0
|
1
|
my($class, $prereqs) = @_; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
3
|
my $self = $class->new; |
11
|
|
|
|
|
|
|
|
12
|
1
|
|
|
|
|
3
|
for my $phase (keys %$prereqs) { |
13
|
2
|
|
|
|
|
2
|
for my $type (keys %{ $prereqs->{$phase} }) { |
|
2
|
|
|
|
|
4
|
|
14
|
2
|
|
|
|
|
2
|
while (my($module, $requirement) = each %{ $prereqs->{$phase}{$type} }) { |
|
6
|
|
|
|
|
18
|
|
15
|
4
|
|
|
|
|
8
|
$self->add_prereq( |
16
|
|
|
|
|
|
|
phase => $phase, |
17
|
|
|
|
|
|
|
type => $type, |
18
|
|
|
|
|
|
|
module => $module, |
19
|
|
|
|
|
|
|
requirement => Module::CPANfile::Requirement->new(name => $module, version => $requirement), |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
3
|
$self; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
13
|
|
|
13
|
0
|
22
|
my $class = shift; |
30
|
13
|
|
|
|
|
118
|
bless { |
31
|
|
|
|
|
|
|
prereqs => [], |
32
|
|
|
|
|
|
|
features => {}, |
33
|
|
|
|
|
|
|
}, $class; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub add_feature { |
37
|
2
|
|
|
2
|
0
|
4
|
my($self, $identifier, $description) = @_; |
38
|
2
|
|
|
|
|
10
|
$self->{features}{$identifier} = { description => $description }; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub add_prereq { |
42
|
31
|
|
|
31
|
0
|
96
|
my($self, %args) = @_; |
43
|
31
|
|
|
|
|
143
|
$self->add( Module::CPANfile::Prereq->new(%args) ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub add { |
47
|
31
|
|
|
31
|
0
|
37
|
my($self, $prereq) = @_; |
48
|
31
|
|
|
|
|
30
|
push @{$self->{prereqs}}, $prereq; |
|
31
|
|
|
|
|
228
|
|
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub as_cpan_meta { |
52
|
22
|
|
|
22
|
0
|
27
|
my $self = shift; |
53
|
22
|
|
66
|
|
|
122
|
$self->{cpanmeta} ||= $self->build_cpan_meta; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub build_cpan_meta { |
57
|
15
|
|
|
15
|
0
|
29
|
my($self, $identifier) = @_; |
58
|
|
|
|
|
|
|
|
59
|
15
|
|
|
|
|
25
|
my $prereq_spec = {}; |
60
|
|
|
|
|
|
|
$self->prereq_each($identifier, sub { |
61
|
33
|
|
|
33
|
|
39
|
my $prereq = shift; |
62
|
33
|
|
|
|
|
77
|
$prereq_spec->{$prereq->phase}{$prereq->type}{$prereq->module} = $prereq->requirement->version; |
63
|
15
|
|
|
|
|
104
|
}); |
64
|
|
|
|
|
|
|
|
65
|
15
|
|
|
|
|
142
|
CPAN::Meta::Prereqs->new($prereq_spec); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub prereq_each { |
69
|
15
|
|
|
15
|
0
|
26
|
my($self, $identifier, $code) = @_; |
70
|
|
|
|
|
|
|
|
71
|
15
|
|
|
|
|
20
|
for my $prereq (@{$self->{prereqs}}) { |
|
15
|
|
|
|
|
49
|
|
72
|
39
|
100
|
|
|
|
105
|
next unless $prereq->match_feature($identifier); |
73
|
33
|
|
|
|
|
61
|
$code->($prereq); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub merged_requirements { |
78
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
79
|
|
|
|
|
|
|
|
80
|
0
|
|
|
|
|
0
|
my $reqs = CPAN::Meta::Requirements->new; |
81
|
0
|
|
|
|
|
0
|
for my $prereq (@{$self->{prereqs}}) { |
|
0
|
|
|
|
|
0
|
|
82
|
0
|
|
|
|
|
0
|
$reqs->add_string_requirement($prereq->module, $prereq->requirement->version); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
0
|
$reqs; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub find { |
89
|
4
|
|
|
4
|
0
|
8
|
my($self, $module) = @_; |
90
|
|
|
|
|
|
|
|
91
|
4
|
|
|
|
|
5
|
for my $prereq (@{$self->{prereqs}}) { |
|
4
|
|
|
|
|
14
|
|
92
|
4
|
50
|
|
|
|
16
|
return $prereq if $prereq->module eq $module; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
0
|
return; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub identifiers { |
99
|
8
|
|
|
8
|
0
|
12
|
my $self = shift; |
100
|
8
|
|
|
|
|
10
|
keys %{$self->{features}}; |
|
8
|
|
|
|
|
40
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub feature { |
104
|
6
|
|
|
6
|
0
|
10
|
my($self, $identifier) = @_; |
105
|
|
|
|
|
|
|
|
106
|
6
|
100
|
|
|
|
236
|
my $data = $self->{features}{$identifier} |
107
|
|
|
|
|
|
|
or Carp::croak("Unknown feature '$identifier'"); |
108
|
|
|
|
|
|
|
|
109
|
5
|
|
|
|
|
17
|
my $prereqs = $self->build_cpan_meta($identifier); |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
CPAN::Meta::Feature->new($identifier, { |
112
|
|
|
|
|
|
|
description => $data->{description}, |
113
|
5
|
|
|
|
|
739
|
prereqs => $prereqs->as_string_hash, |
114
|
|
|
|
|
|
|
}); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |