line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Meta::Check; |
2
|
|
|
|
|
|
|
# vi:noet:sts=2:sw=2:ts=2 |
3
|
|
|
|
|
|
|
$CPAN::Meta::Check::VERSION = '0.018'; |
4
|
2
|
|
|
2
|
|
206973
|
use strict; |
|
2
|
|
|
|
|
24
|
|
|
2
|
|
|
|
|
94
|
|
5
|
2
|
|
|
2
|
|
14
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use base 'Exporter'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
401
|
|
8
|
|
|
|
|
|
|
our @EXPORT = qw//; |
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw/check_requirements requirements_for verify_dependencies/; |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [ @EXPORT, @EXPORT_OK ] ); |
11
|
|
|
|
|
|
|
|
12
|
2
|
|
|
2
|
|
14
|
use CPAN::Meta::Prereqs 2.132830; |
|
2
|
|
|
|
|
34
|
|
|
2
|
|
|
|
|
73
|
|
13
|
2
|
|
|
2
|
|
13
|
use CPAN::Meta::Requirements 2.121; |
|
2
|
|
|
|
|
26
|
|
|
2
|
|
|
|
|
75
|
|
14
|
2
|
|
|
2
|
|
1430
|
use Module::Metadata 1.000023; |
|
2
|
|
|
|
|
12571
|
|
|
2
|
|
|
|
|
796
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _check_dep { |
17
|
13
|
|
|
13
|
|
31
|
my ($reqs, $module, $dirs) = @_; |
18
|
|
|
|
|
|
|
|
19
|
13
|
50
|
|
|
|
38
|
return $reqs->accepts_module($module, $]) ? () : sprintf "Your Perl (%s) is not in the range '%s'", $], $reqs->requirements_for_module($module) if $module eq 'perl'; |
|
|
100
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
11
|
|
|
|
|
53
|
my $metadata = Module::Metadata->new_from_module($module, inc => $dirs); |
22
|
11
|
100
|
|
|
|
36711
|
return "Module '$module' is not installed" if not defined $metadata; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
|
|
40
|
my $version = eval { $metadata->version }; |
|
10
|
|
|
|
|
45
|
|
25
|
10
|
100
|
100
|
|
|
223
|
return sprintf 'Installed version (%s) of %s is not in range \'%s\'', |
|
|
100
|
|
|
|
|
|
26
|
|
|
|
|
|
|
(defined $version ? $version : 'undef'), $module, $reqs->requirements_for_module($module) |
27
|
|
|
|
|
|
|
if not $reqs->accepts_module($module, $version || 0); |
28
|
8
|
|
|
|
|
359
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _check_conflict { |
32
|
5
|
|
|
5
|
|
15
|
my ($reqs, $module, $dirs) = @_; |
33
|
5
|
|
|
|
|
30
|
my $metadata = Module::Metadata->new_from_module($module, inc => $dirs); |
34
|
5
|
50
|
|
|
|
40321
|
return if not defined $metadata; |
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
13
|
my $version = eval { $metadata->version }; |
|
5
|
|
|
|
|
19
|
|
37
|
5
|
100
|
|
|
|
71
|
return sprintf 'Installed version (%s) of %s is in range \'%s\'', |
|
|
100
|
|
|
|
|
|
38
|
|
|
|
|
|
|
(defined $version ? $version : 'undef'), $module, $reqs->requirements_for_module($module) |
39
|
|
|
|
|
|
|
if $reqs->accepts_module($module, $version); |
40
|
2
|
|
|
|
|
107
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub requirements_for { |
44
|
1
|
|
|
1
|
1
|
5
|
my ($meta, $phases, $type) = @_; |
45
|
1
|
50
|
|
|
|
11
|
my $prereqs = ref($meta) eq 'CPAN::Meta' ? $meta->effective_prereqs : $meta; |
46
|
1
|
50
|
|
|
|
1249
|
return $prereqs->merged_requirements(ref($phases) ? $phases : [ $phases ], [ $type ]); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub check_requirements { |
50
|
8
|
|
|
8
|
1
|
15415
|
my ($reqs, $type, $dirs) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return +{ |
53
|
|
|
|
|
|
|
map { |
54
|
8
|
100
|
|
|
|
26
|
$_ => $type ne 'conflicts' |
|
18
|
|
|
|
|
242
|
|
55
|
|
|
|
|
|
|
? scalar _check_dep($reqs, $_, $dirs) |
56
|
|
|
|
|
|
|
: scalar _check_conflict($reqs, $_, $dirs) |
57
|
|
|
|
|
|
|
} $reqs->required_modules |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub verify_dependencies { |
62
|
1
|
|
|
1
|
1
|
8455
|
my ($meta, $phases, $type, $dirs) = @_; |
63
|
1
|
|
|
|
|
4
|
my $reqs = requirements_for($meta, $phases, $type); |
64
|
1
|
|
|
|
|
402
|
my $issues = check_requirements($reqs, $type, $dirs); |
65
|
1
|
|
|
|
|
64
|
return grep { defined } values %{ $issues }; |
|
4
|
|
|
|
|
18
|
|
|
1
|
|
|
|
|
5
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#ABSTRACT: Verify requirements in a CPAN::Meta object |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |