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