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.017'; |
4
|
2
|
|
|
2
|
|
209685
|
use strict; |
|
2
|
|
|
|
|
18
|
|
|
2
|
|
|
|
|
61
|
|
5
|
2
|
|
|
2
|
|
10
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
57
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
11
|
use base 'Exporter'; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
420
|
|
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
|
|
15
|
use CPAN::Meta::Prereqs '2.132830'; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
103
|
|
13
|
2
|
|
|
2
|
|
13
|
use CPAN::Meta::Requirements 2.121; |
|
2
|
|
|
|
|
32
|
|
|
2
|
|
|
|
|
89
|
|
14
|
2
|
|
|
2
|
|
1391
|
use Module::Metadata 1.000023; |
|
2
|
|
|
|
|
12660
|
|
|
2
|
|
|
|
|
799
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _check_dep { |
17
|
13
|
|
|
13
|
|
30
|
my ($reqs, $module, $dirs) = @_; |
18
|
|
|
|
|
|
|
|
19
|
13
|
50
|
|
|
|
41
|
$module eq 'perl' and return ($reqs->accepts_module($module, $]) ? () : sprintf "Your Perl (%s) is not in the range '%s'", $], $reqs->requirements_for_module($module)); |
|
|
100
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
11
|
|
|
|
|
53
|
my $metadata = Module::Metadata->new_from_module($module, inc => $dirs); |
22
|
11
|
100
|
|
|
|
36792
|
return "Module '$module' is not installed" if not defined $metadata; |
23
|
|
|
|
|
|
|
|
24
|
10
|
|
|
|
|
50
|
my $version = eval { $metadata->version }; |
|
10
|
|
|
|
|
34
|
|
25
|
10
|
100
|
100
|
|
|
233
|
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
|
|
|
|
|
385
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _check_conflict { |
32
|
5
|
|
|
5
|
|
16
|
my ($reqs, $module, $dirs) = @_; |
33
|
5
|
|
|
|
|
42
|
my $metadata = Module::Metadata->new_from_module($module, inc => $dirs); |
34
|
5
|
50
|
|
|
|
40346
|
return if not defined $metadata; |
35
|
|
|
|
|
|
|
|
36
|
5
|
|
|
|
|
13
|
my $version = eval { $metadata->version }; |
|
5
|
|
|
|
|
23
|
|
37
|
5
|
100
|
|
|
|
73
|
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
|
|
|
|
|
110
|
return; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub requirements_for { |
44
|
1
|
|
|
1
|
1
|
4
|
my ($meta, $phases, $type) = @_; |
45
|
1
|
50
|
|
|
|
9
|
my $prereqs = ref($meta) eq 'CPAN::Meta' ? $meta->effective_prereqs : $meta; |
46
|
1
|
50
|
|
|
|
1343
|
return $prereqs->merged_requirements(ref($phases) ? $phases : [ $phases ], [ $type ]); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub check_requirements { |
50
|
8
|
|
|
8
|
1
|
14878
|
my ($reqs, $type, $dirs) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return +{ |
53
|
|
|
|
|
|
|
map { |
54
|
8
|
100
|
|
|
|
35
|
$_ => $type ne 'conflicts' |
|
18
|
|
|
|
|
255
|
|
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
|
8712
|
my ($meta, $phases, $type, $dirs) = @_; |
63
|
1
|
|
|
|
|
7
|
my $reqs = requirements_for($meta, $phases, $type); |
64
|
1
|
|
|
|
|
373
|
my $issues = check_requirements($reqs, $type, $dirs); |
65
|
1
|
|
|
|
|
62
|
return grep { defined } values %{ $issues }; |
|
4
|
|
|
|
|
22
|
|
|
1
|
|
|
|
|
5
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
1; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#ABSTRACT: Verify requirements in a CPAN::Meta object |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |