line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Version::App; |
2
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:XSAWYERX'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Application implementation for Module::Version |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
33097
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
62
|
|
6
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
60
|
|
7
|
2
|
|
|
2
|
|
9
|
use Carp qw< croak >; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
100
|
|
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
1466
|
use Getopt::Long qw( :config no_ignore_case ); |
|
2
|
|
|
|
|
21391
|
|
|
2
|
|
|
|
|
9
|
|
10
|
2
|
|
|
2
|
|
1450
|
use Module::Version 'get_version'; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
1455
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
1
|
1079
|
sub new { return bless {}, $_[0] } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub run { |
17
|
12
|
|
|
12
|
1
|
15488
|
my $self = shift; |
18
|
12
|
|
|
|
|
22
|
my @modules; |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
|
|
32
|
$self->parse_opts; |
21
|
|
|
|
|
|
|
|
22
|
12
|
50
|
33
|
|
|
6546
|
if( $self->{local_lib} and -d $self->{local_lib} ) { |
23
|
0
|
|
|
|
|
0
|
require local::lib; |
24
|
0
|
|
|
|
|
0
|
local::lib->import( $self->{local_lib} ); |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$self->{'modules'} |
28
|
12
|
100
|
|
|
|
34
|
and push @modules, @{ $self->{'modules'} }; |
|
9
|
|
|
|
|
20
|
|
29
|
|
|
|
|
|
|
|
30
|
12
|
100
|
|
|
|
35
|
if ( my $file = $self->{'input'} ) { |
31
|
2
|
100
|
|
|
|
259
|
open my $fh, '<', $file |
32
|
|
|
|
|
|
|
or croak("Cannot open '$file': $!"); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
22
|
chomp( my @extra_modules = <$fh> ); |
35
|
1
|
|
|
|
|
4
|
push @modules, @extra_modules; |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
14
|
close $fh |
38
|
|
|
|
|
|
|
or croak("Cannot close '$file': $!"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
11
|
100
|
|
|
|
25
|
if ( $self->{'include'} ) { |
42
|
2
|
|
|
|
|
4
|
my $include = $self->{'include'}; |
43
|
|
|
|
|
|
|
|
44
|
2
|
100
|
|
|
|
13
|
ref $include eq 'ARRAY' |
45
|
|
|
|
|
|
|
or die "Error: include must be an ARRAY ref\n"; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
3
|
unshift @INC, @{$include}; |
|
1
|
|
|
|
|
3
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
@modules |
51
|
10
|
100
|
|
|
|
28
|
or die "Error: no modules to check\n"; |
52
|
|
|
|
|
|
|
|
53
|
9
|
|
|
|
|
16
|
foreach my $module (@modules) { |
54
|
9
|
|
|
|
|
27
|
my $version = get_version($module); |
55
|
9
|
100
|
|
|
|
2139
|
if ( !$version ) { |
56
|
3
|
100
|
|
|
|
41
|
$self->{'quiet'} |
57
|
|
|
|
|
|
|
or warn "Warning: module '$module' does not seem to be installed.\n"; |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
22
|
next; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
6
|
100
|
|
|
|
61
|
$self->{'dev'} or $version =~ s/_(.+)$/$1/xms; |
63
|
|
|
|
|
|
|
|
64
|
6
|
100
|
|
|
|
26
|
my $output = $self->{'full'} ? "$module $version\n" : "$version\n"; |
65
|
6
|
|
|
|
|
201
|
print $output; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub parse_opts { |
70
|
15
|
|
|
15
|
1
|
1069
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
GetOptions( |
73
|
1
|
|
|
1
|
|
845
|
'h|help' => sub { $self->help }, |
74
|
|
|
|
|
|
|
'f|full!' => \$self->{'full'}, |
75
|
|
|
|
|
|
|
'i|input=s' => \$self->{'input'}, |
76
|
|
|
|
|
|
|
'l|local-lib=s'=> \$self->{'local_lib'}, |
77
|
|
|
|
|
|
|
'I|include=s@' => \$self->{'include'}, |
78
|
|
|
|
|
|
|
'd|dev!' => \$self->{'dev'}, |
79
|
|
|
|
|
|
|
'q|quiet!' => \$self->{'quiet'}, |
80
|
1
|
|
|
1
|
|
522
|
'<>' => sub { $self->process(@_) }, |
81
|
15
|
100
|
|
|
|
136
|
) or $self->error('could not parse options'); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub process { |
85
|
1
|
|
|
1
|
1
|
861
|
my ( $self, @args ) = @_; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# force stringify Getopt::Long input |
88
|
1
|
|
|
|
|
3
|
push @{ $self->{'modules'} }, "$_" for @args; |
|
3
|
|
|
|
|
13
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub help { |
92
|
1
|
|
|
1
|
1
|
1711
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
41
|
print << "_END_HEREDOC"; |
95
|
|
|
|
|
|
|
$0 [ OPTIONS ] Module Module Module... |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
Provide a module's version, comfortably. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
OPTIONS |
100
|
|
|
|
|
|
|
-f | --full Output name and version (a la Module::Version 0.05) |
101
|
|
|
|
|
|
|
-I | --include Include any number of directories to include as well |
102
|
|
|
|
|
|
|
-i | --input Input file to read module names from |
103
|
|
|
|
|
|
|
-l | --local-lib Additional local::lib dir to search |
104
|
|
|
|
|
|
|
-d | --dev Show developer versions as 0.01_01 instead of 0.0101 |
105
|
|
|
|
|
|
|
-q | --quiet Do not error out if module doesn't exist |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
_END_HEREDOC |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
1; |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__END__ |