line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::cpmfile::Prereqs; |
2
|
3
|
|
|
3
|
|
24
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
94
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
71
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
1471
|
use CPAN::Meta::Prereqs; |
|
3
|
|
|
|
|
29007
|
|
|
3
|
|
|
|
|
118
|
|
6
|
3
|
|
|
3
|
|
1495
|
use Module::cpmfile::Util '_yaml_hash'; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
210
|
|
7
|
3
|
|
|
3
|
|
22
|
use Scalar::Util 'blessed'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
2804
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my @PHASE = qw(runtime configure build test develop); |
10
|
|
|
|
|
|
|
my @TYPE = qw(requires recommends suggests); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
8
|
|
|
8
|
0
|
33
|
my $class = shift; |
14
|
8
|
|
50
|
|
|
30
|
my $hash = shift || +{}; |
15
|
8
|
|
|
|
|
17
|
my $self = +{}; |
16
|
8
|
|
|
|
|
20
|
for my $phase (@PHASE) { |
17
|
40
|
|
|
|
|
62
|
for my $type (@TYPE) { |
18
|
120
|
100
|
100
|
|
|
303
|
next if !$hash->{$phase} || !$hash->{$phase}{$type}; |
19
|
15
|
|
|
|
|
25
|
for my $package (sort keys %{$hash->{$phase}{$type}}) { |
|
15
|
|
|
|
|
73
|
|
20
|
|
|
|
|
|
|
$self->{$phase}{$type}{$package} |
21
|
20
|
|
100
|
|
|
91
|
= $hash->{$phase}{$type}{$package} || +{}; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
} |
25
|
8
|
|
|
|
|
35
|
bless $self, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub from_cpanmeta { |
29
|
2
|
|
|
2
|
0
|
641
|
my ($class, $cpanmeta) = @_; |
30
|
2
|
|
|
|
|
5
|
my $hash = $cpanmeta; |
31
|
2
|
50
|
33
|
|
|
21
|
if (blessed $cpanmeta and $cpanmeta->isa('CPAN::Meta::Prereqs')) { |
32
|
2
|
|
|
|
|
6
|
$hash = $cpanmeta->as_string_hash; |
33
|
|
|
|
|
|
|
} |
34
|
2
|
|
|
|
|
597
|
my $out = {}; |
35
|
2
|
|
|
|
|
8
|
for my $phase (sort keys %$hash) { |
36
|
3
|
|
|
|
|
5
|
for my $type (sort keys %{ $hash->{$phase} }) { |
|
3
|
|
|
|
|
19
|
|
37
|
5
|
|
|
|
|
10
|
for my $package (sort keys %{ $hash->{$phase}{$type} }) { |
|
5
|
|
|
|
|
12
|
|
38
|
6
|
|
|
|
|
12
|
my $version = $hash->{$phase}{$type}{$package}; |
39
|
6
|
100
|
|
|
|
15
|
my $options = +{ $version ? (version => $version) : () }; |
40
|
6
|
|
|
|
|
16
|
$out->{$phase}{$type}{$package} = $options; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
} |
44
|
2
|
|
|
|
|
6
|
$class->new($out); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub cpanmeta { |
48
|
1
|
|
|
1
|
0
|
1188
|
my $self = shift; |
49
|
1
|
|
|
|
|
3
|
my $hash = +{}; |
50
|
1
|
|
|
|
|
5
|
for my $phase (sort keys %$self) { |
51
|
1
|
|
|
|
|
2
|
for my $type (sort keys %{$self->{$phase}}) { |
|
1
|
|
|
|
|
4
|
|
52
|
1
|
|
|
|
|
2
|
for my $package (sort keys %{$self->{$phase}{$type}}) { |
|
1
|
|
|
|
|
3
|
|
53
|
1
|
|
|
|
|
3
|
my $options = $self->{$phase}{$type}{$package}; |
54
|
1
|
|
50
|
|
|
9
|
$hash->{$phase}{$type}{$package} = $options->{version} || 0; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
} |
58
|
1
|
|
|
|
|
8
|
CPAN::Meta::Prereqs->new($hash); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub walk { |
62
|
6
|
|
|
6
|
0
|
15
|
my ($self, $phases, $types, $cb) = @_; |
63
|
6
|
|
100
|
|
|
29
|
$phases ||= \@PHASE; |
64
|
6
|
|
100
|
|
|
22
|
$types ||= \@TYPE; |
65
|
6
|
|
|
|
|
15
|
for my $phase (@$phases) { |
66
|
26
|
|
|
|
|
46
|
for my $type (@$types) { |
67
|
76
|
100
|
100
|
|
|
219
|
next if !$self->{$phase} || !$self->{$phase}{$type}; |
68
|
13
|
|
|
|
|
18
|
for my $package (sort keys %{$self->{$phase}{$type}}) { |
|
13
|
|
|
|
|
48
|
|
69
|
19
|
|
|
|
|
43
|
my $options = $self->{$phase}{$type}{$package}; |
70
|
19
|
|
|
|
|
44
|
my $ret = $cb->($phase, $type, $package, $options); |
71
|
19
|
50
|
33
|
|
|
73
|
return if ref($ret) eq 'SCALAR' && !$$ret; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub to_string { |
78
|
3
|
|
|
3
|
0
|
6
|
my $self = shift; |
79
|
3
|
|
100
|
|
|
14
|
my $indent = shift || ""; |
80
|
3
|
|
|
|
|
5
|
my @out; |
81
|
3
|
|
|
|
|
6
|
push @out, "prereqs:"; |
82
|
3
|
|
|
|
|
7
|
for my $phase (@PHASE) { |
83
|
15
|
100
|
|
|
|
46
|
my $spec1 = $self->{$phase} or next; |
84
|
4
|
|
|
|
|
14
|
push @out, " $phase:"; |
85
|
4
|
|
|
|
|
9
|
for my $type (@TYPE) { |
86
|
12
|
100
|
|
|
|
39
|
my $spec2 = $spec1->{$type} or next; |
87
|
5
|
|
|
|
|
16
|
push @out, " $type:"; |
88
|
5
|
|
|
|
|
9
|
for my $package (sort keys %{$spec2}) { |
|
5
|
|
|
|
|
26
|
|
89
|
7
|
50
|
|
|
|
12
|
if (my %option = %{ $spec2->{$package} || +{} }) { |
|
7
|
100
|
|
|
|
45
|
|
90
|
5
|
|
|
|
|
14
|
my @key = keys %option; |
91
|
5
|
100
|
100
|
|
|
28
|
if (@key == 1 && $key[0] eq "version") { |
92
|
3
|
|
|
|
|
19
|
push @out, " $package: { version: '$option{version}' }"; |
93
|
|
|
|
|
|
|
} else { |
94
|
2
|
|
|
|
|
8
|
push @out, " $package:"; |
95
|
2
|
|
|
|
|
12
|
push @out, _yaml_hash(\%option, " "); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} else { |
98
|
2
|
|
|
|
|
9
|
push @out, " $package:"; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
} |
103
|
3
|
|
|
|
|
10
|
join "\n", map { "$indent$_" } @out; |
|
23
|
|
|
|
|
60
|
|
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |