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