line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perl::PrereqScanner::NotQuiteLite::Util::CPANfile; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
881
|
use strict; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
93
|
|
4
|
3
|
|
|
3
|
|
16
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
85
|
|
5
|
3
|
|
|
3
|
|
423
|
use parent 'Module::CPANfile'; |
|
3
|
|
|
|
|
354
|
|
|
3
|
|
|
|
|
28
|
|
6
|
3
|
|
|
3
|
|
20529
|
use Perl::PrereqScanner::NotQuiteLite::Util::Prereqs; |
|
3
|
|
|
|
|
39
|
|
|
3
|
|
|
|
|
2720
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub load_and_merge { |
9
|
15
|
|
|
15
|
0
|
60
|
my ($class, $file, $prereqs, $features) = @_; |
10
|
|
|
|
|
|
|
|
11
|
15
|
50
|
|
|
|
91
|
$prereqs = $prereqs->as_string_hash unless ref $prereqs eq 'HASH'; |
12
|
|
|
|
|
|
|
|
13
|
15
|
|
|
|
|
9845
|
my $self; |
14
|
15
|
100
|
|
|
|
310
|
if (-f $file) { |
15
|
6
|
|
|
|
|
50
|
$self = $class->load($file); |
16
|
6
|
|
|
|
|
482
|
$self->_merge_prereqs($prereqs); |
17
|
|
|
|
|
|
|
} else { |
18
|
9
|
|
|
|
|
73
|
$self = $class->from_prereqs($prereqs); |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
|
21
|
15
|
100
|
|
|
|
1101
|
if ($features) { |
22
|
9
|
|
|
|
|
29
|
for my $identifier (keys %$features) { |
23
|
9
|
|
|
|
|
23
|
my $feature = $features->{$identifier}; |
24
|
9
|
100
|
|
|
|
28
|
next unless $feature->{prereqs}; |
25
|
8
|
100
|
|
|
|
71
|
$self->_merge_prereqs($feature->{prereqs}, $identifier) or next; |
26
|
7
|
|
|
|
|
39
|
$self->{_prereqs}->add_feature($identifier, $feature->{description}); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
15
|
|
|
|
|
103
|
$self->_dedupe; |
31
|
|
|
|
|
|
|
|
32
|
15
|
|
|
|
|
74
|
$self; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub features { |
36
|
15
|
|
|
15
|
1
|
84
|
my $self = shift; |
37
|
15
|
|
|
|
|
60
|
map $self->feature($_), sort $self->{_prereqs}->identifiers; # TWEAKED |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub _merge_prereqs { |
41
|
14
|
|
|
14
|
|
41
|
my ($self, $prereqs, $feature_id) = @_; |
42
|
14
|
100
|
|
|
|
66
|
$prereqs = $prereqs->as_string_hash unless ref $prereqs eq 'HASH'; |
43
|
|
|
|
|
|
|
|
44
|
14
|
|
|
|
|
4829
|
my $current = CPAN::Meta::Prereqs->new($self->{_prereqs}->specs($feature_id)); |
45
|
14
|
|
|
|
|
1980
|
my $merged = $current->with_merged_prereqs(CPAN::Meta::Prereqs->new($prereqs)); |
46
|
|
|
|
|
|
|
|
47
|
14
|
|
|
|
|
9622
|
$self->__replace_prereqs($merged, $feature_id); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub __replace_prereqs { |
51
|
37
|
|
|
37
|
|
95
|
my ($self, $prereqs, $feature_id) = @_; |
52
|
37
|
50
|
|
|
|
145
|
$prereqs = $prereqs->as_string_hash unless ref $prereqs eq 'HASH'; |
53
|
|
|
|
|
|
|
|
54
|
37
|
|
100
|
|
|
6871
|
@{$self->{_prereqs}{prereqs}{$feature_id || ''}} = (); |
|
37
|
|
|
|
|
302
|
|
55
|
37
|
|
|
|
|
80
|
my $added = 0; |
56
|
37
|
|
|
|
|
117
|
for my $phase (keys %$prereqs) { |
57
|
33
|
|
|
|
|
64
|
for my $type (keys %{$prereqs->{$phase}}) { |
|
33
|
|
|
|
|
85
|
|
58
|
33
|
|
|
|
|
61
|
while (my($module, $requirement) = each %{$prereqs->{$phase}{$type}}) { |
|
98
|
|
|
|
|
359
|
|
59
|
|
|
|
|
|
|
$self->{_prereqs}->add( |
60
|
65
|
|
|
|
|
221
|
feature => $feature_id, |
61
|
|
|
|
|
|
|
phase => $phase, |
62
|
|
|
|
|
|
|
type => $type, |
63
|
|
|
|
|
|
|
module => $module, |
64
|
|
|
|
|
|
|
requirement => Module::CPANfile::Requirement->new(name => $module, version => $requirement), |
65
|
|
|
|
|
|
|
); |
66
|
65
|
|
|
|
|
1595
|
$added++ |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
37
|
100
|
|
|
|
108
|
delete $self->{_prereqs}{cpanmeta} unless $feature_id; # to rebuild cpanmeta |
71
|
37
|
|
|
|
|
243
|
$added; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
sub _dedupe { |
75
|
15
|
|
|
15
|
|
34
|
my $self = shift; |
76
|
15
|
|
|
|
|
71
|
my $prereqs = $self->prereqs; |
77
|
15
|
|
|
|
|
3557
|
my %features = map {$_ => $self->feature($_)->{prereqs} } $self->{_prereqs}->identifiers; |
|
8
|
|
|
|
|
104
|
|
78
|
|
|
|
|
|
|
|
79
|
15
|
|
|
|
|
4589
|
dedupe_prereqs_and_features($prereqs, \%features); |
80
|
|
|
|
|
|
|
|
81
|
15
|
|
|
|
|
95
|
$self->__replace_prereqs($prereqs); |
82
|
15
|
|
|
|
|
80
|
for my $feature_id (keys %features) { |
83
|
8
|
|
|
|
|
24
|
$self->__replace_prereqs($features{$feature_id}, $feature_id); |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub _dump_prereqs { |
88
|
23
|
|
|
23
|
|
29485
|
my($self, $prereqs, $include_empty, $base_indent) = @_; |
89
|
|
|
|
|
|
|
|
90
|
23
|
|
|
|
|
50
|
my $code = ''; |
91
|
23
|
|
|
|
|
73
|
my @x_phases = sort grep {/^x_/i} keys %$prereqs; # TWEAKED |
|
21
|
|
|
|
|
99
|
|
92
|
23
|
|
|
|
|
65
|
for my $phase (qw(runtime configure build test develop), @x_phases) { |
93
|
116
|
100
|
|
|
|
294
|
my $indent = $phase eq 'runtime' ? '' : ' '; |
94
|
116
|
|
100
|
|
|
390
|
$indent = (' ' x ($base_indent || 0)) . $indent; |
95
|
|
|
|
|
|
|
|
96
|
116
|
|
|
|
|
225
|
my($phase_code, $requirements); |
97
|
116
|
100
|
|
|
|
297
|
$phase_code .= "on $phase => sub {\n" unless $phase eq 'runtime'; |
98
|
|
|
|
|
|
|
|
99
|
116
|
|
|
|
|
177
|
my @x_types = sort grep {/^x_/i} keys %{$prereqs->{$phase}}; # TWEAKED |
|
21
|
|
|
|
|
72
|
|
|
116
|
|
|
|
|
361
|
|
100
|
116
|
|
|
|
|
247
|
for my $type (qw(requires recommends suggests conflicts), @x_types) { |
101
|
464
|
|
|
|
|
732
|
for my $mod (sort keys %{$prereqs->{$phase}{$type}}) { |
|
464
|
|
|
|
|
1323
|
|
102
|
43
|
|
|
|
|
101
|
my $ver = $prereqs->{$phase}{$type}{$mod}; |
103
|
43
|
100
|
|
|
|
136
|
$phase_code .= $ver eq '0' |
104
|
|
|
|
|
|
|
? "${indent}$type '$mod';\n" |
105
|
|
|
|
|
|
|
: "${indent}$type '$mod', '$ver';\n"; |
106
|
43
|
|
|
|
|
100
|
$requirements++; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
116
|
100
|
|
|
|
276
|
$phase_code .= "\n" unless $requirements; |
111
|
116
|
100
|
|
|
|
257
|
$phase_code .= "};\n" unless $phase eq 'runtime'; |
112
|
|
|
|
|
|
|
|
113
|
116
|
100
|
66
|
|
|
402
|
$code .= $phase_code . "\n" if $requirements or $include_empty; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
23
|
|
|
|
|
145
|
$code =~ s/\n+$/\n/s; |
117
|
23
|
|
|
|
|
88
|
$code; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
__END__ |