line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# file: lib/Perl/PrereqScanner/Scanner/Hint.pm |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#pod =encoding UTF-8 |
7
|
|
|
|
|
|
|
#pod |
8
|
|
|
|
|
|
|
#pod =head1 COPYRIGHT AND LICENSE |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod Copyright © 2015 Van de Bugger |
11
|
|
|
|
|
|
|
#pod |
12
|
|
|
|
|
|
|
#pod This file is part of perl-Perl-PrereqScanner-Scanner-Hint. |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod perl-Perl-PrereqScanner-Scanner-Hint is free software: you can redistribute it and/or modify it |
15
|
|
|
|
|
|
|
#pod under the terms of the GNU General Public License as published by the Free Software Foundation, |
16
|
|
|
|
|
|
|
#pod either version 3 of the License, or (at your option) any later version. |
17
|
|
|
|
|
|
|
#pod |
18
|
|
|
|
|
|
|
#pod perl-Perl-PrereqScanner-Scanner-Hint is distributed in the hope that it will be useful, but |
19
|
|
|
|
|
|
|
#pod WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
20
|
|
|
|
|
|
|
#pod PARTICULAR PURPOSE. See the GNU General Public License for more details. |
21
|
|
|
|
|
|
|
#pod |
22
|
|
|
|
|
|
|
#pod You should have received a copy of the GNU General Public License along with |
23
|
|
|
|
|
|
|
#pod perl-Perl-PrereqScanner-Scanner-Hint. If not, see <http://www.gnu.org/licenses/>. |
24
|
|
|
|
|
|
|
#pod |
25
|
|
|
|
|
|
|
#pod =cut |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
#pod =for :this This is C<Perl::PrereqScanner::Scanner::Hint> module documentation. Read this if you are going to hack or |
30
|
|
|
|
|
|
|
#pod extend C<Manifest::Write>. |
31
|
|
|
|
|
|
|
#pod |
32
|
|
|
|
|
|
|
#pod =for :those If you want to specify implicit prerequisites directly in your Perl code, read the L<user manual|Perl::PrereqScanner::Scanner::Hint::Manual>. |
33
|
|
|
|
|
|
|
#pod General topics like getting source, building, installing, bug reporting and some others are covered |
34
|
|
|
|
|
|
|
#pod in the F<README>. |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =for test_synopsis my $path; |
37
|
|
|
|
|
|
|
#pod |
38
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
39
|
|
|
|
|
|
|
#pod |
40
|
|
|
|
|
|
|
#pod use Perl::PrereqScanner; |
41
|
|
|
|
|
|
|
#pod my $scanner = Perl::PrereqScanner->new( { |
42
|
|
|
|
|
|
|
#pod extra_scanners => [ qw{ Hint } ], |
43
|
|
|
|
|
|
|
#pod } ); |
44
|
|
|
|
|
|
|
#pod my $prereqs = $scanner->scan_file( $path ); |
45
|
|
|
|
|
|
|
#pod |
46
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
47
|
|
|
|
|
|
|
#pod |
48
|
|
|
|
|
|
|
#pod TODO |
49
|
|
|
|
|
|
|
#pod |
50
|
|
|
|
|
|
|
#pod =cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
package Perl::PrereqScanner::Scanner::Hint; |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
|
34277
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
55
|
1
|
|
|
1
|
|
6557
|
use namespace::autoclean; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# ABSTRACT: Plugin for C<Perl::PrereqScanner> looking for C<# REQUIRE:> comments |
58
|
|
|
|
|
|
|
our $VERSION = 'v0.0.0_01'; # TRIAL VERSION |
59
|
|
|
|
|
|
|
|
60
|
1
|
|
|
1
|
|
98
|
use Module::Runtime qw{ is_module_name }; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
61
|
1
|
|
|
1
|
|
43
|
use Try::Tiny; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
567
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
with 'Perl::PrereqScanner::Scanner'; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
my $error = sub { |
68
|
|
|
|
|
|
|
my ( $what, $elem ) = @_; |
69
|
|
|
|
|
|
|
my ( undef, undef, undef, $line, $file ) = @{ $elem->location }; |
70
|
|
|
|
|
|
|
chomp( $what ); |
71
|
|
|
|
|
|
|
if ( not defined( $file ) ) { |
72
|
|
|
|
|
|
|
$file = '(*UNKNOWN*)'; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
die "$what at $file line $line.\n"; |
75
|
|
|
|
|
|
|
}; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
#pod =method scan_for_prereqs |
80
|
|
|
|
|
|
|
#pod |
81
|
|
|
|
|
|
|
#pod TODO |
82
|
|
|
|
|
|
|
#pod |
83
|
|
|
|
|
|
|
#pod =cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub scan_for_prereqs { |
86
|
5
|
|
|
5
|
1
|
14480
|
my ( $self, $doc, $req ) = @_; |
87
|
5
|
|
50
|
|
|
23
|
my $comments = $doc->find( 'Token::Comment' ) || []; |
88
|
5
|
|
|
|
|
3752
|
for my $comment ( @$comments ) { |
89
|
13
|
100
|
|
|
|
990
|
if ( $comment->content =~ m{ ^ \s* \# \s* REQUIRES? \s* : \s* (.*) \s* $ }x ) { |
90
|
9
|
|
|
|
|
84
|
my $requirement = $1; |
91
|
9
|
|
|
|
|
29
|
$requirement =~ s{ \s* \# .* \z }{}x; # Strip trailing comment, if any. |
92
|
9
|
|
|
|
|
32
|
my ( $mod, $ver ) = ( split( m{\s+}x, $requirement, 2 ), '0' ); |
93
|
9
|
100
|
|
|
|
29
|
if ( is_module_name( $mod ) ) { |
94
|
|
|
|
|
|
|
try { |
95
|
8
|
|
|
8
|
|
273
|
$req->add_string_requirement( $mod, $ver ); |
96
|
|
|
|
|
|
|
} catch { |
97
|
1
|
|
|
1
|
|
111
|
my $ex = $_; |
98
|
1
|
|
|
|
|
3
|
$error->( "$ex", $comment ); |
99
|
8
|
|
|
|
|
121
|
}; |
100
|
|
|
|
|
|
|
} else { |
101
|
1
|
|
|
|
|
17
|
$error->( "'$mod' is not a valid module name", $comment ); |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
}; |
104
|
|
|
|
|
|
|
}; |
105
|
3
|
|
|
|
|
104
|
return; |
106
|
|
|
|
|
|
|
}; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# -------------------------------------------------------------------------------------------------- |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
#pod =pod |
117
|
|
|
|
|
|
|
#pod |
118
|
|
|
|
|
|
|
#pod =encoding UTF-8 |
119
|
|
|
|
|
|
|
#pod |
120
|
|
|
|
|
|
|
#pod =head1 WHAT? |
121
|
|
|
|
|
|
|
#pod |
122
|
|
|
|
|
|
|
#pod C<Perl::PrereqScanner::Scanner::Hint> (or just C<Scanner::Hint> for brevity) is a plugin for C<Perl::PrereqScanner> |
123
|
|
|
|
|
|
|
#pod tool. C<Scanner::Hint> looks for C<# REQUIRE: I<ModuleName> I<VersionRange>> comments in the code. |
124
|
|
|
|
|
|
|
#pod |
125
|
|
|
|
|
|
|
#pod =cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
# end of file # |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
__END__ |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=pod |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=encoding UTF-8 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 NAME |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Perl::PrereqScanner::Scanner::Hint - Plugin for C<Perl::PrereqScanner> looking for C<# REQUIRE:> comments |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head1 VERSION |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Version v0.0.0_01, released on 2015-10-21 23:22 UTC. |
143
|
|
|
|
|
|
|
This is a B<trial release>. |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 WHAT? |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
C<Perl::PrereqScanner::Scanner::Hint> (or just C<Scanner::Hint> for brevity) is a plugin for C<Perl::PrereqScanner> |
148
|
|
|
|
|
|
|
tool. C<Scanner::Hint> looks for C<# REQUIRE: I<ModuleName> I<VersionRange>> comments in the code. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This is C<Perl::PrereqScanner::Scanner::Hint> module documentation. Read this if you are going to hack or |
151
|
|
|
|
|
|
|
extend C<Manifest::Write>. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
If you want to specify implicit prerequisites directly in your Perl code, read the L<user manual|Perl::PrereqScanner::Scanner::Hint::Manual>. |
154
|
|
|
|
|
|
|
General topics like getting source, building, installing, bug reporting and some others are covered |
155
|
|
|
|
|
|
|
in the F<README>. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 SYNOPSIS |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
use Perl::PrereqScanner; |
160
|
|
|
|
|
|
|
my $scanner = Perl::PrereqScanner->new( { |
161
|
|
|
|
|
|
|
extra_scanners => [ qw{ Hint } ], |
162
|
|
|
|
|
|
|
} ); |
163
|
|
|
|
|
|
|
my $prereqs = $scanner->scan_file( $path ); |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 DESCRIPTION |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
TODO |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 OBJECT METHODS |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head2 scan_for_prereqs |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
TODO |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=for test_synopsis my $path; |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 AUTHOR |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Van de Bugger <van.de.bugger@gmail.com> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Copyright © 2015 Van de Bugger |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
This file is part of perl-Perl-PrereqScanner-Scanner-Hint. |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
perl-Perl-PrereqScanner-Scanner-Hint is free software: you can redistribute it and/or modify it |
188
|
|
|
|
|
|
|
under the terms of the GNU General Public License as published by the Free Software Foundation, |
189
|
|
|
|
|
|
|
either version 3 of the License, or (at your option) any later version. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
perl-Perl-PrereqScanner-Scanner-Hint is distributed in the hope that it will be useful, but |
192
|
|
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
193
|
|
|
|
|
|
|
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along with |
196
|
|
|
|
|
|
|
perl-Perl-PrereqScanner-Scanner-Hint. If not, see <http://www.gnu.org/licenses/>. |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=cut |