line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Tangerine::hook::testrequires; |
2
|
|
|
|
|
|
|
$Tangerine::hook::testrequires::VERSION = '0.19'; |
3
|
15
|
|
|
15
|
|
996
|
use 5.010; |
|
15
|
|
|
|
|
43
|
|
4
|
15
|
|
|
15
|
|
66
|
use strict; |
|
15
|
|
|
|
|
22
|
|
|
15
|
|
|
|
|
317
|
|
5
|
15
|
|
|
15
|
|
59
|
use warnings; |
|
15
|
|
|
|
|
21
|
|
|
15
|
|
|
|
|
445
|
|
6
|
15
|
|
|
15
|
|
63
|
use parent 'Tangerine::Hook'; |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
97
|
|
7
|
15
|
|
|
15
|
|
925
|
use List::MoreUtils qw(any); |
|
15
|
|
|
|
|
37
|
|
|
15
|
|
|
|
|
104
|
|
8
|
15
|
|
|
15
|
|
5213
|
use Tangerine::HookData; |
|
15
|
|
|
|
|
24
|
|
|
15
|
|
|
|
|
306
|
|
9
|
15
|
|
|
15
|
|
62
|
use Tangerine::Occurence; |
|
15
|
|
|
|
|
18
|
|
|
15
|
|
|
|
|
384
|
|
10
|
15
|
|
|
15
|
|
60
|
use Tangerine::Utils qw(stripquotelike); |
|
15
|
|
|
|
|
19
|
|
|
15
|
|
|
|
|
6530
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub run { |
13
|
133
|
|
|
133
|
1
|
161
|
my ($self, $s) = @_; |
14
|
133
|
|
|
|
|
130
|
my %found; |
15
|
133
|
100
|
100
|
|
|
285
|
if ($self->type eq 'compile' && |
|
|
100
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
66
|
|
|
|
|
16
|
181
|
|
|
181
|
|
912
|
(any { $s->[0] eq $_ } qw(use no)) && scalar(@$s) > 2 && |
17
|
|
|
|
|
|
|
$s->[1] eq 'Test::Requires') { |
18
|
3
|
|
|
|
|
61
|
my ($version) = $s->[2] =~ /^(\d.*)$/o; |
19
|
3
|
|
50
|
|
|
93
|
$version //= ''; |
20
|
3
|
50
|
33
|
|
|
15
|
return if !$version && stripquotelike($s->[2]) =~ /^v?5(\..*)?$/; |
21
|
3
|
50
|
|
|
|
5
|
my $voffset = $version ? 3 : 2; |
22
|
3
|
|
|
|
|
3
|
my @args; |
23
|
3
|
50
|
|
|
|
7
|
if (scalar(@$s) > $voffset) { |
24
|
3
|
50
|
|
|
|
7
|
return if $s->[$voffset] eq ';'; |
25
|
3
|
|
|
|
|
110
|
@args = @$s; |
26
|
3
|
|
|
|
|
8
|
@args = @args[($voffset) .. $#args]; |
27
|
3
|
|
|
|
|
7
|
@args = stripquotelike(@args); |
28
|
|
|
|
|
|
|
} |
29
|
3
|
100
|
|
|
|
10
|
if (substr($s->[$voffset], 0, 1) eq '{') { |
30
|
1
|
|
|
|
|
45
|
%found = @args; |
31
|
|
|
|
|
|
|
} else { |
32
|
2
|
|
|
|
|
49
|
%found = map { $_ => '' } @args; |
|
6
|
|
|
|
|
18
|
|
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
} elsif ($self->type eq 'runtime' && |
35
|
|
|
|
|
|
|
$s->[0] eq 'test_requires' && scalar(@$s) > 1) { |
36
|
2
|
50
|
|
|
|
22
|
return if $s->[1] eq ';'; |
37
|
2
|
|
|
|
|
45
|
my @args = stripquotelike((@$s)[1..$#$s]); |
38
|
2
|
100
|
66
|
|
|
14
|
$found{$args[0]} = $args[1] && $args[1] ne ';' ? $args[1] : ''; |
39
|
|
|
|
|
|
|
} else { |
40
|
|
|
|
|
|
|
return |
41
|
128
|
|
|
|
|
577
|
} |
42
|
|
|
|
|
|
|
return Tangerine::HookData->new( |
43
|
|
|
|
|
|
|
modules => { |
44
|
|
|
|
|
|
|
map { |
45
|
5
|
|
|
|
|
17
|
( $_ => Tangerine::Occurence->new(version => $found{$_}) ) |
|
10
|
|
|
|
|
27
|
|
46
|
|
|
|
|
|
|
} keys %found, |
47
|
|
|
|
|
|
|
}, |
48
|
|
|
|
|
|
|
) |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
__END__ |