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
|
3
|
|
|
3
|
|
30825
|
use strict; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
95
|
|
6
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
93
|
|
7
|
3
|
|
|
3
|
|
16
|
use Carp qw< croak >; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
145
|
|
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
2831
|
use Getopt::Long qw( :config no_ignore_case ); |
|
3
|
|
|
|
|
28725
|
|
|
3
|
|
|
|
|
12
|
|
10
|
3
|
|
|
3
|
|
1328
|
use Module::Version 'get_version'; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
1803
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our $VERSION = '0.13'; |
13
|
|
|
|
|
|
|
|
14
|
2
|
|
|
2
|
1
|
1271
|
sub new { return bless {}, $_[0] } |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub run { |
17
|
12
|
|
|
12
|
1
|
12757
|
my $self = shift; |
18
|
12
|
|
|
|
|
19
|
my @modules; |
19
|
|
|
|
|
|
|
|
20
|
12
|
|
|
|
|
28
|
$self->parse_opts; |
21
|
|
|
|
|
|
|
|
22
|
12
|
50
|
33
|
|
|
5171
|
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
|
|
|
|
25
|
and push @modules, @{ $self->{'modules'} }; |
|
9
|
|
|
|
|
18
|
|
29
|
|
|
|
|
|
|
|
30
|
12
|
100
|
|
|
|
22
|
if ( my $file = $self->{'input'} ) { |
31
|
2
|
100
|
|
|
|
281
|
open my $fh, '<', $file |
32
|
|
|
|
|
|
|
or croak("Cannot open '$file': $!"); |
33
|
|
|
|
|
|
|
|
34
|
1
|
|
|
|
|
17
|
chomp( my @extra_modules = <$fh> ); |
35
|
1
|
|
|
|
|
4
|
push @modules, @extra_modules; |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
12
|
close $fh |
38
|
|
|
|
|
|
|
or croak("Cannot close '$file': $!"); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
11
|
100
|
|
|
|
21
|
if ( $self->{'include'} ) { |
42
|
2
|
|
|
|
|
3
|
my $include = $self->{'include'}; |
43
|
|
|
|
|
|
|
|
44
|
2
|
100
|
|
|
|
10
|
ref $include eq 'ARRAY' |
45
|
|
|
|
|
|
|
or die "Error: include must be an ARRAY ref\n"; |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
2
|
unshift @INC, @{$include}; |
|
1
|
|
|
|
|
3
|
|
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
@modules |
51
|
10
|
100
|
|
|
|
23
|
or die "Error: no modules to check\n"; |
52
|
|
|
|
|
|
|
|
53
|
9
|
|
|
|
|
14
|
foreach my $module (@modules) { |
54
|
9
|
|
|
|
|
22
|
my $version = get_version($module); |
55
|
9
|
100
|
|
|
|
1471
|
if ( !$version ) { |
56
|
3
|
100
|
|
|
|
34
|
$self->{'quiet'} |
57
|
|
|
|
|
|
|
or warn "Warning: module '$module' does not seem to be installed.\n"; |
58
|
|
|
|
|
|
|
|
59
|
3
|
|
|
|
|
17
|
next; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
6
|
100
|
|
|
|
19
|
$self->{'dev'} or $version =~ s/_(.+)$/$1/xms; |
63
|
|
|
|
|
|
|
|
64
|
6
|
100
|
|
|
|
31
|
my $output = $self->{'full'} ? "$module $version\n" : "$version\n"; |
65
|
6
|
|
|
|
|
160
|
print $output; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub parse_opts { |
70
|
15
|
|
|
15
|
1
|
1155
|
my $self = shift; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
GetOptions( |
73
|
1
|
|
|
1
|
|
831
|
'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
|
|
526
|
'<>' => sub { $self->process(@_) }, |
81
|
15
|
100
|
|
|
|
112
|
) or $self->error('could not parse options'); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub process { |
85
|
1
|
|
|
1
|
1
|
769
|
my ( $self, @args ) = @_; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# force stringify Getopt::Long input |
88
|
1
|
|
|
|
|
3
|
push @{ $self->{'modules'} }, "$_" for @args; |
|
3
|
|
|
|
|
11
|
|
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub help { |
92
|
1
|
|
|
1
|
1
|
1759
|
my $self = shift; |
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
|
|
53
|
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__ |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=pod |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=encoding UTF-8 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 NAME |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Module::Version::App - Application implementation for Module::Version |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 VERSION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
version 0.200 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 SYNOPSIS |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This is the CLI program's implementation as a module. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
use Module::Version::App; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
my $app = Module::Version::App->new; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
$app->run; |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head2 new |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Create a new object. |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head2 run |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Do all the grunt work. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 parse_opts |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Parsing the command line arguments using L<Getopt::Long>. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head2 process |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
Parses extra arguments from L<Getopt::Long>. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head2 help |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Print a help menu for the application itself. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=head2 error($error) |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Calls C<die> with a message. |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
=head2 warn($warning) |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
Calls C<warn> with a message. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=head1 EXPORT |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
Object Oriented, nothing is exported. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 BUGS |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
173
|
|
|
|
|
|
|
C<bug-module-version at rt.cpan.org>, or through the web interface at |
174
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Module-Version>. I will be |
175
|
|
|
|
|
|
|
notified, and then you'll automatically be notified of progress on your bug as I |
176
|
|
|
|
|
|
|
make changes. |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head1 SUPPORT |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
This module sports 100% test coverage, but in case you have more issues... |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
perldoc Module::Version |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
You can also look for information at: |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=over 4 |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Module-Version> |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
L<http://annocpan.org/dist/Module-Version> |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=item * CPAN Ratings |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
L<http://cpanratings.perl.org/d/Module-Version> |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=item * Search CPAN |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
L<http://search.cpan.org/dist/Module-Version/> |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=back |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 AUTHOR |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Sawyer X |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
This software is copyright (c) 2010-2018 by Sawyer X. |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
217
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=cut |