line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Util::MergePrereqsFromDistInis; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2015-05-15'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
516
|
use 5.010001; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
498
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(merge_prereqs_from_dist_inis); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our %SPEC; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$SPEC{merge_prereqs_from_dist_inis} = { |
17
|
|
|
|
|
|
|
v => 1.1, |
18
|
|
|
|
|
|
|
summary => "Merge prereqs from several dzil dist.ini's", |
19
|
|
|
|
|
|
|
description => <<'_', |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
This routine tries to merge prereqs from several Dist::Zilla's `dist.ini` |
22
|
|
|
|
|
|
|
files. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
An application of this routine is for `Dist::Zilla::Plugin::MergeDists`. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
_ |
27
|
|
|
|
|
|
|
args_rels => { |
28
|
|
|
|
|
|
|
req_one => [qw/paths srcs/], |
29
|
|
|
|
|
|
|
}, |
30
|
|
|
|
|
|
|
args => { |
31
|
|
|
|
|
|
|
paths => { |
32
|
|
|
|
|
|
|
summary => "Paths to dist.ini's", |
33
|
|
|
|
|
|
|
schema => ['array*', of=>'str*', min_len=>1], |
34
|
|
|
|
|
|
|
'x.schema.element_entity' => 'filename', |
35
|
|
|
|
|
|
|
}, |
36
|
|
|
|
|
|
|
srcs => { |
37
|
|
|
|
|
|
|
summary => "Content of dist.ini's", |
38
|
|
|
|
|
|
|
schema => ['array*', of=>'str*', min_len=>1], |
39
|
|
|
|
|
|
|
}, |
40
|
|
|
|
|
|
|
}, |
41
|
|
|
|
|
|
|
result_naked => 1, |
42
|
|
|
|
|
|
|
}; |
43
|
|
|
|
|
|
|
sub merge_prereqs_from_dist_inis { |
44
|
1
|
|
|
1
|
1
|
495
|
require Dist::Zilla::Util::ParsePrereqsFromDistIni; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
424
|
my %args = @_; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
2
|
my @prereqs_list; |
49
|
1
|
50
|
|
|
|
3
|
if ($args{paths}) { |
50
|
0
|
|
|
|
|
0
|
push @prereqs_list, Dist::Zilla::Util::ParsePrereqsFromDistIni::parse_prereqs_from_dist_ini(path=>$_) |
51
|
0
|
|
|
|
|
0
|
for @{$args{paths}}; |
52
|
|
|
|
|
|
|
} else { |
53
|
1
|
|
|
|
|
7
|
push @prereqs_list, Dist::Zilla::Util::ParsePrereqsFromDistIni::parse_prereqs_from_dist_ini(src=>$_) |
54
|
1
|
|
|
|
|
1
|
for @{$args{srcs}}; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
1
|
50
|
|
|
|
4887
|
return $prereqs_list[0] if @prereqs_list == 1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# merge the keys |
60
|
1
|
|
|
|
|
2
|
my $res; |
61
|
1
|
|
|
|
|
3
|
for my $prereqs (@prereqs_list) { |
62
|
3
|
|
|
|
|
7
|
for my $phase (keys %$prereqs) { |
63
|
3
|
|
|
|
|
3
|
my $phase_prereqs = $prereqs->{$phase}; |
64
|
3
|
|
|
|
|
5
|
for my $rel (keys %$phase_prereqs) { |
65
|
3
|
|
|
|
|
4
|
my $mods = $phase_prereqs->{$rel}; |
66
|
3
|
|
|
|
|
4
|
for my $mod (keys %$mods) { |
67
|
6
|
100
|
100
|
|
|
56
|
$res->{$phase}{$rel}{$mod} = $mods->{$mod} |
68
|
|
|
|
|
|
|
unless exists($res->{$phase}{$rel}{$mod}) && |
69
|
|
|
|
|
|
|
version->parse($res->{$phase}{$rel}{$mod}) > |
70
|
|
|
|
|
|
|
version->parse($mods->{$mod}); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# upgrade suggests to recommends/requires |
77
|
1
|
|
|
|
|
4
|
for my $phase (keys %$res) { |
78
|
1
|
|
|
|
|
3
|
my $phase_res = $res->{$phase}; |
79
|
1
|
50
|
|
|
|
7
|
my $suggests = $phase_res->{suggests} or next; |
80
|
0
|
|
|
|
|
0
|
for my $mod (keys %$suggests) { |
81
|
0
|
0
|
|
|
|
0
|
delete $suggests->{$mod} if $phase_res->{recommends}{$mod}; |
82
|
0
|
0
|
|
|
|
0
|
delete $suggests->{$mod} if $phase_res->{requires}{$mod}; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
# upgrade recommends to requires |
87
|
1
|
|
|
|
|
3
|
for my $phase (keys %$res) { |
88
|
1
|
|
|
|
|
3
|
my $phase_res = $res->{$phase}; |
89
|
1
|
50
|
|
|
|
6
|
my $recommends = $phase_res->{recommends} or next; |
90
|
1
|
|
|
|
|
3
|
for my $mod (keys %$recommends) { |
91
|
2
|
100
|
|
|
|
12
|
delete $recommends->{$mod} if $phase_res->{requires}{$mod}; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
1
|
|
|
|
|
9
|
$res; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
# ABSTRACT: Merge prereqs from several dzil dist.ini's |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
__END__ |