| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
2
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::RecommendedPrereqs; |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# Copyright 2011 Christopher J. Madsen |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
# Author: Christopher J. Madsen <perl@cjmweb.net> |
|
7
|
|
|
|
|
|
|
# Created: 31 Oct 2011 |
|
8
|
|
|
|
|
|
|
# |
|
9
|
|
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
10
|
|
|
|
|
|
|
# it under the same terms as Perl itself. |
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
|
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See either the |
|
15
|
|
|
|
|
|
|
# GNU General Public License or the Artistic License for more details. |
|
16
|
|
|
|
|
|
|
# |
|
17
|
|
|
|
|
|
|
# ABSTRACT: Look for comments recommending prerequisites |
|
18
|
|
|
|
|
|
|
#--------------------------------------------------------------------- |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '4.21'; |
|
21
|
|
|
|
|
|
|
# This file is part of Dist-Zilla-Plugins-CJM 4.27 (August 29, 2015) |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
|
24
|
2
|
|
|
2
|
|
694060
|
use 5.008; |
|
|
2
|
|
|
|
|
5
|
|
|
25
|
2
|
|
|
2
|
|
10
|
use Moose; |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
18
|
|
|
26
|
|
|
|
|
|
|
with( |
|
27
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqSource', |
|
28
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
|
29
|
|
|
|
|
|
|
default_finders => [ ':InstallModules', ':ExecFiles' ], |
|
30
|
|
|
|
|
|
|
}, |
|
31
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
|
32
|
|
|
|
|
|
|
method => 'found_test_files', |
|
33
|
|
|
|
|
|
|
finder_arg_names => [ 'test_finder' ], |
|
34
|
|
|
|
|
|
|
default_finders => [ ':TestFiles' ], |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
); |
|
37
|
|
|
|
|
|
|
|
|
38
|
2
|
|
|
2
|
|
11285
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
20
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
#===================================================================== |
|
41
|
|
|
|
|
|
|
|
|
42
|
2
|
|
|
2
|
|
138
|
use CPAN::Meta::Requirements (); |
|
|
2
|
|
|
|
|
3
|
|
|
|
2
|
|
|
|
|
22
|
|
|
43
|
2
|
|
|
2
|
|
8
|
use version (); |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
772
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub register_prereqs |
|
46
|
|
|
|
|
|
|
{ |
|
47
|
1
|
|
|
1
|
0
|
221764
|
my $self = shift; |
|
48
|
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
8
|
my @sets = ( |
|
50
|
|
|
|
|
|
|
[ runtime => 'found_files' ], |
|
51
|
|
|
|
|
|
|
[ test => 'found_test_files' ], |
|
52
|
|
|
|
|
|
|
); |
|
53
|
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
2
|
my %runtime; |
|
55
|
|
|
|
|
|
|
|
|
56
|
1
|
|
|
|
|
3
|
for my $fileset (@sets) { |
|
57
|
2
|
|
|
|
|
755
|
my ($phase, $method) = @$fileset; |
|
58
|
|
|
|
|
|
|
|
|
59
|
2
|
|
|
|
|
6
|
my %req = map { $_ => CPAN::Meta::Requirements->new } qw(RECOMMEND SUGGEST); |
|
|
4
|
|
|
|
|
44
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
2
|
|
|
|
|
41
|
my $files = $self->$method; |
|
62
|
|
|
|
|
|
|
|
|
63
|
2
|
|
|
|
|
4075
|
foreach my $file (@$files) { |
|
64
|
3
|
|
|
|
|
14
|
$self->log_debug("Checking " . $file->name); |
|
65
|
3
|
|
|
|
|
459
|
my $content = $file->content; |
|
66
|
|
|
|
|
|
|
|
|
67
|
3
|
|
|
|
|
2907
|
while ($content =~ /^ [ \t]* \# [ \t]* (RECOMMEND|SUGGEST) [ \t]+ PREREQ: |
|
68
|
|
|
|
|
|
|
[ \t]* (\S+) (?: [ \t]+ (\S+) )?/mgx) { |
|
69
|
3
|
|
100
|
|
|
223
|
$req{$1}->add_minimum($2, $3 || 0); |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
} # end foreach $file |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
# we're done, add what we've found |
|
74
|
2
|
|
|
|
|
91
|
while (my ($type, $req) = each %req) { |
|
75
|
4
|
|
|
|
|
297
|
$req = $req->as_string_hash; |
|
76
|
|
|
|
|
|
|
|
|
77
|
4
|
100
|
|
|
|
108
|
if ($phase eq 'runtime') { |
|
78
|
2
|
|
|
|
|
5
|
$runtime{$type} = $req; |
|
79
|
|
|
|
|
|
|
} else { |
|
80
|
2
|
|
|
|
|
3
|
delete $req->{$_} for |
|
81
|
2
|
50
|
|
|
|
11
|
grep { exists $req->{$_} and $runtime{$type}{$_} ge $req->{$_} } |
|
82
|
2
|
50
|
|
|
|
17
|
keys %{ $runtime{$type} || {} }; |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
4
|
100
|
|
|
|
125
|
$self->zilla->register_prereqs({ phase => $phase, type => "\L${type}s" }, |
|
86
|
|
|
|
|
|
|
%$req) if %$req; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
} # end foreach $fileset |
|
89
|
|
|
|
|
|
|
} # end register_prereqs |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#===================================================================== |
|
92
|
|
|
|
|
|
|
# Package Return Value: |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
95
|
|
|
|
|
|
|
1; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 NAME |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Dist::Zilla::Plugin::RecommendedPrereqs - Look for comments recommending prerequisites |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 VERSION |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This document describes version 4.21 of |
|
106
|
|
|
|
|
|
|
Dist::Zilla::Plugin::RecommendedPrereqs, released August 29, 2015 |
|
107
|
|
|
|
|
|
|
as part of Dist-Zilla-Plugins-CJM version 4.27. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
In your F<dist.ini>: |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
[RecommendedPrereqs] |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
In your code: |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# RECOMMEND PREREQ: Foo::Bar 1.0 |
|
118
|
|
|
|
|
|
|
# SUGGEST PREREQ: Foo::Suggested |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
If included, this plugin will look for special comments that specify |
|
123
|
|
|
|
|
|
|
suggested or recommended prerequisites. It's intended as a companion |
|
124
|
|
|
|
|
|
|
to L<AutoPrereqs|Dist::Zilla::Plugin::AutoPrereqs>, which can only |
|
125
|
|
|
|
|
|
|
determine required prerequisites. |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Each comment must be on a line by itself, and begin with either |
|
128
|
|
|
|
|
|
|
S<C<RECOMMEND PREREQ:>> or S<C<SUGGEST PREREQ:>> followed by the |
|
129
|
|
|
|
|
|
|
module name. The name may be followed by the minimum version, which |
|
130
|
|
|
|
|
|
|
may in turn be followed by a note explaining the prereq (which will be |
|
131
|
|
|
|
|
|
|
ignored). If the note is present, the version I<must> be present, |
|
132
|
|
|
|
|
|
|
even if it's 0. |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 INCOMPATIBILITIES |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
None reported. |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 BUGS AND LIMITATIONS |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The parser currently just looks for lines beginning with a C<#> (which |
|
141
|
|
|
|
|
|
|
may be preceded by whitespace). This means it looks in strings and |
|
142
|
|
|
|
|
|
|
here docs, as well as after C<__END__>. This behavior may be fixed in |
|
143
|
|
|
|
|
|
|
the future and should not be depended on. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=for Pod::Coverage |
|
147
|
|
|
|
|
|
|
register_prereqs |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 AUTHOR |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Christopher J. Madsen S<C<< <perl AT cjmweb.net> >>> |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
Please report any bugs or feature requests |
|
154
|
|
|
|
|
|
|
to S<C<< <bug-Dist-Zilla-Plugins-CJM AT rt.cpan.org> >>> |
|
155
|
|
|
|
|
|
|
or through the web interface at |
|
156
|
|
|
|
|
|
|
L<< http://rt.cpan.org/Public/Bug/Report.html?Queue=Dist-Zilla-Plugins-CJM >>. |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
You can follow or contribute to Dist-Zilla-Plugins-CJM's development at |
|
159
|
|
|
|
|
|
|
L<< https://github.com/madsen/dist-zilla-plugins-cjm >>. |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Christopher J. Madsen. |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
166
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
167
|
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=head1 DISCLAIMER OF WARRANTY |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY |
|
171
|
|
|
|
|
|
|
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN |
|
172
|
|
|
|
|
|
|
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES |
|
173
|
|
|
|
|
|
|
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER |
|
174
|
|
|
|
|
|
|
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
175
|
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE |
|
176
|
|
|
|
|
|
|
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH |
|
177
|
|
|
|
|
|
|
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL |
|
178
|
|
|
|
|
|
|
NECESSARY SERVICING, REPAIR, OR CORRECTION. |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING |
|
181
|
|
|
|
|
|
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR |
|
182
|
|
|
|
|
|
|
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENSE, BE |
|
183
|
|
|
|
|
|
|
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, |
|
184
|
|
|
|
|
|
|
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE |
|
185
|
|
|
|
|
|
|
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING |
|
186
|
|
|
|
|
|
|
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A |
|
187
|
|
|
|
|
|
|
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF |
|
188
|
|
|
|
|
|
|
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF |
|
189
|
|
|
|
|
|
|
SUCH DAMAGES. |
|
190
|
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
=cut |