| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package My::Module::Recommend::Any; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
32
|
use 5.006002; |
|
|
1
|
|
|
|
|
3
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
3
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
13
|
|
|
6
|
1
|
|
|
1
|
|
2
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
3
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
120
|
|
|
9
|
1
|
|
|
1
|
|
5
|
use Exporter qw{ import }; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
52
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.134'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw{ __any }; |
|
14
|
|
|
|
|
|
|
|
|
15
|
1
|
|
|
1
|
|
3
|
use constant ARRAY_REF => ref []; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
73
|
|
|
16
|
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
3
|
use constant RECOMMEND_TEMPLATE_SINGLE => " * %s is not available.\n"; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
46
|
|
|
18
|
1
|
|
|
1
|
|
3
|
use constant RECOMMEND_TEMPLATE_MULTI => " * None of %s is available.\n"; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
502
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub __any { |
|
21
|
7
|
|
|
7
|
|
10
|
my ( @args ) = @_; |
|
22
|
7
|
|
|
|
|
10
|
return __PACKAGE__->new( @args ); |
|
23
|
|
|
|
|
|
|
} |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub new { |
|
26
|
7
|
|
|
7
|
1
|
8
|
my ( $class, @modules ) = @_; |
|
27
|
7
|
50
|
|
|
|
10
|
@modules > 1 |
|
28
|
|
|
|
|
|
|
or croak 'Must specify at least one module and a message'; |
|
29
|
7
|
|
|
|
|
26
|
my $msg = pop @modules; |
|
30
|
7
|
|
|
|
|
30
|
$msg =~ s/ ^\s* / /smxg; |
|
31
|
|
|
|
|
|
|
|
|
32
|
7
|
|
33
|
|
|
129
|
return bless { |
|
33
|
|
|
|
|
|
|
modules => \@modules, |
|
34
|
|
|
|
|
|
|
message => $msg, |
|
35
|
|
|
|
|
|
|
}, ref $class || $class; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub check { |
|
39
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
40
|
0
|
|
|
|
|
|
my @missing; |
|
41
|
0
|
|
|
|
|
|
foreach my $m ( @{ $self->{modules} } ) { |
|
|
0
|
|
|
|
|
|
|
|
42
|
0
|
0
|
|
|
|
|
$self->__is_module_available( $m ) |
|
43
|
|
|
|
|
|
|
and return; |
|
44
|
0
|
|
|
|
|
|
push @missing, $m; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
0
|
|
|
|
|
|
return @missing; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub __is_module_available { |
|
50
|
0
|
|
|
0
|
|
|
my ( undef, $m ) = @_; |
|
51
|
0
|
0
|
|
|
|
|
my ( $mod, $ver ) = ARRAY_REF eq ref $m ? @{ $m } : ( $m ); |
|
|
0
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my @eval = ( "require $mod;" ); |
|
53
|
0
|
0
|
|
|
|
|
defined $ver |
|
54
|
|
|
|
|
|
|
and push @eval, "$mod->VERSION( $ver );"; |
|
55
|
0
|
0
|
|
|
|
|
eval "@eval 1;" |
|
56
|
|
|
|
|
|
|
and return $m; |
|
57
|
0
|
|
|
|
|
|
return; |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub modules { |
|
61
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
62
|
|
|
|
|
|
|
return ( |
|
63
|
0
|
0
|
|
|
|
|
map { ARRAY_REF eq ref $_ ? $_->[0] : $_ } |
|
64
|
0
|
|
|
|
|
|
@{ $self->{modules} } |
|
|
0
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
*test_without = \&modules; |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub recommend { |
|
71
|
0
|
|
|
0
|
1
|
|
my ( $self ) = @_; |
|
72
|
0
|
0
|
|
|
|
|
my @missing = $self->check() |
|
73
|
|
|
|
|
|
|
or return; |
|
74
|
0
|
0
|
|
|
|
|
my $tplt = @missing > 1 ? |
|
75
|
|
|
|
|
|
|
$self->RECOMMEND_TEMPLATE_MULTI() : |
|
76
|
|
|
|
|
|
|
$self->RECOMMEND_TEMPLATE_SINGLE(); |
|
77
|
|
|
|
|
|
|
return sprintf( $tplt, join ', ', _module_stringify( @missing ) ) . |
|
78
|
0
|
|
|
|
|
|
$self->{message}; |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _module_stringify { |
|
82
|
0
|
|
|
0
|
|
|
my @arg = @_; |
|
83
|
0
|
|
|
|
|
|
my @rslt; |
|
84
|
0
|
|
|
|
|
|
foreach my $m ( @arg ) { |
|
85
|
0
|
0
|
|
|
|
|
push @rslt, ARRAY_REF eq ref $m ? "@{ $m }" : $m; |
|
|
0
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
} |
|
87
|
0
|
|
|
|
|
|
return @rslt; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
__END__ |