line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Test::Version; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
2036796
|
use Moose; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
31
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with |
6
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileGatherer', |
7
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
8
|
|
|
|
|
|
|
'Dist::Zilla::Role::TextTemplate', |
9
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqSource', |
10
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
11
|
|
|
|
|
|
|
method => 'found_files', |
12
|
|
|
|
|
|
|
finder_arg_names => [ 'finder' ], |
13
|
|
|
|
|
|
|
default_finders => [], |
14
|
|
|
|
|
|
|
}, |
15
|
|
|
|
|
|
|
; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
4
|
|
17324
|
use Sub::Exporter::ForMethods 'method_installer'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
40
|
|
18
|
|
|
|
|
|
|
use Data::Section 0.004 # fixed header_re |
19
|
4
|
|
|
4
|
|
613
|
{ installer => method_installer }, '-setup'; |
|
4
|
|
|
|
|
120
|
|
|
4
|
|
|
|
|
22
|
|
20
|
4
|
|
|
4
|
|
1967
|
use Moose::Util::TypeConstraints qw( role_type union enum ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
35
|
|
21
|
4
|
|
|
4
|
|
1503
|
use namespace::autoclean; |
|
4
|
|
|
|
|
5
|
|
|
4
|
|
|
|
|
33
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# ABSTRACT: Author Test::Version tests |
24
|
|
|
|
|
|
|
our $VERSION = '1.07'; # VERSION |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub gather_files { |
27
|
5
|
|
|
5
|
0
|
173073
|
my($self) = @_; |
28
|
|
|
|
|
|
|
|
29
|
5
|
|
|
|
|
1991
|
require Dist::Zilla::File::InMemory; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
$self->add_file( |
32
|
|
|
|
|
|
|
$self->_file_obj( |
33
|
|
|
|
|
|
|
Dist::Zilla::File::InMemory->new( |
34
|
|
|
|
|
|
|
# PRs welcome: make configurable. |
35
|
|
|
|
|
|
|
name => 'xt/author/test-version.t', |
36
|
5
|
|
|
|
|
229097
|
content => ${$self->section_data('__TEST__')}, |
|
5
|
|
|
|
|
30
|
|
37
|
|
|
|
|
|
|
) |
38
|
|
|
|
|
|
|
) |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
5
|
|
|
|
|
1473
|
return; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub munge_files |
45
|
|
|
|
|
|
|
{ |
46
|
5
|
|
|
5
|
0
|
6197
|
my($self) = @_; |
47
|
|
|
|
|
|
|
|
48
|
5
|
|
|
|
|
9
|
my @filenames; |
49
|
5
|
|
|
|
|
7
|
my $use_finder = 0; |
50
|
|
|
|
|
|
|
|
51
|
5
|
100
|
|
|
|
8
|
if(@{ $self->finder } > 0) { |
|
5
|
|
|
|
|
149
|
|
52
|
1
|
|
|
|
|
44
|
@filenames = map { Path::Class::File->new($_->name)->relative('.')->stringify } |
53
|
1
|
|
33
|
|
|
669
|
grep { not ($_->can('is_bytes') and $_->is_bytes) } |
54
|
1
|
|
|
|
|
8
|
@{ $self->found_files }; |
|
1
|
|
|
|
|
6
|
|
55
|
1
|
|
|
|
|
349
|
$use_finder = 1; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
5
|
|
|
|
|
168
|
my $file = $self->_file_obj; |
59
|
|
|
|
|
|
|
$file->content( |
60
|
|
|
|
|
|
|
$self->fill_in_string( |
61
|
|
|
|
|
|
|
$file->content, |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
name => __PACKAGE__, |
64
|
|
|
|
|
|
|
version => __PACKAGE__->VERSION |
65
|
|
|
|
|
|
|
|| 'bootstrapped version' |
66
|
|
|
|
|
|
|
, |
67
|
|
|
|
|
|
|
is_strict => \$self->_is_strict, |
68
|
|
|
|
|
|
|
has_version => \$self->has_version, |
69
|
|
|
|
|
|
|
multiple => \$self->multiple, |
70
|
5
|
|
50
|
|
|
25
|
filename_match => join(", ", @{ $self->filename_match }), |
|
5
|
|
|
|
|
152
|
|
71
|
|
|
|
|
|
|
filenames => [ sort @filenames ], |
72
|
|
|
|
|
|
|
use_finder => $use_finder, |
73
|
|
|
|
|
|
|
}, |
74
|
|
|
|
|
|
|
) |
75
|
|
|
|
|
|
|
); |
76
|
|
|
|
|
|
|
|
77
|
5
|
|
|
|
|
8021
|
return; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub register_prereqs { |
81
|
5
|
|
|
5
|
1
|
1483
|
my $self = shift; |
82
|
|
|
|
|
|
|
$self->zilla->register_prereqs({ |
83
|
|
|
|
|
|
|
type => 'requires', |
84
|
|
|
|
|
|
|
phase => 'develop', |
85
|
|
|
|
|
|
|
}, |
86
|
|
|
|
|
|
|
'Test::More' => 0, |
87
|
5
|
100
|
|
|
|
135
|
'Test::Version' => @{ $self->filename_match } > 0 ? '2.00' : '1', |
|
5
|
|
|
|
|
165
|
|
88
|
|
|
|
|
|
|
); |
89
|
5
|
|
|
|
|
2349
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
has is_strict => ( |
93
|
|
|
|
|
|
|
is => 'ro', |
94
|
|
|
|
|
|
|
isa => union([ 'Bool', enum(['adaptive']) ]), |
95
|
|
|
|
|
|
|
lazy => 1, |
96
|
|
|
|
|
|
|
default => sub { 0 }, |
97
|
|
|
|
|
|
|
); |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
has _is_strict => ( |
100
|
|
|
|
|
|
|
is => 'ro', |
101
|
|
|
|
|
|
|
isa => 'Bool', |
102
|
|
|
|
|
|
|
lazy => 1, |
103
|
|
|
|
|
|
|
default => sub { |
104
|
|
|
|
|
|
|
my($self) = @_; |
105
|
|
|
|
|
|
|
$self->is_strict eq 'adaptive' ? ($self->zilla->is_trial ? 0 : 1) : $self->is_strict |
106
|
|
|
|
|
|
|
}, |
107
|
|
|
|
|
|
|
); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
has has_version => ( |
110
|
|
|
|
|
|
|
is => 'ro', |
111
|
|
|
|
|
|
|
isa => 'Bool', |
112
|
|
|
|
|
|
|
lazy => 1, |
113
|
|
|
|
|
|
|
default => sub { 1 }, |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
has multiple => ( |
117
|
|
|
|
|
|
|
is => 'ro', |
118
|
|
|
|
|
|
|
isa => 'Bool', |
119
|
|
|
|
|
|
|
lazy => 1, |
120
|
|
|
|
|
|
|
default => sub { 0 }, |
121
|
|
|
|
|
|
|
); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
has filename_match => ( |
124
|
|
|
|
|
|
|
is => 'ro', |
125
|
|
|
|
|
|
|
isa => 'ArrayRef', |
126
|
|
|
|
|
|
|
lazy => 1, |
127
|
|
|
|
|
|
|
default => sub { [] }, |
128
|
|
|
|
|
|
|
); |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
has _file_obj => ( |
131
|
|
|
|
|
|
|
is => 'rw', |
132
|
|
|
|
|
|
|
isa => role_type('Dist::Zilla::Role::File'), |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
around mvp_multivalue_args => sub { |
136
|
|
|
|
|
|
|
my($orig, $self) = @_; |
137
|
|
|
|
|
|
|
return ($self->$orig, 'filename_match'); |
138
|
|
|
|
|
|
|
}; |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
141
|
|
|
|
|
|
|
1; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=pod |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head1 NAME |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Test::Version - Author Test::Version tests |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 VERSION |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
version 1.07 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 SYNOPSIS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
in C<dist.ini> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
[Test::Version] |
158
|
|
|
|
|
|
|
is_strict = 0 |
159
|
|
|
|
|
|
|
has_version = 1 |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 DESCRIPTION |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This module will add a L<Test::Version> test as a author test to your module. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head2 is_strict |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
set L<Test::Version is_strict|Test::Version/is_strict> |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
In addition to a boolean value, you may specify C<adaptive> to indicate that |
172
|
|
|
|
|
|
|
is_strict should be true for production releases, but false for trial or |
173
|
|
|
|
|
|
|
development releases. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=head2 has_version |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
set L<Test::Version has_version|Test::Version/has_version> |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=head2 filename_match |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
set L<Test::Version filename_match|Test::Version/filename_match> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 multiple |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
set L<Test::Version multiple|Test::Version/multiple> |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head2 finder |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
This is the name of a L<Dist::Zilla::Role::FileFinder> for finding files to check. |
190
|
|
|
|
|
|
|
If this is specified then C<version_ok> will be used for each file that matches, |
191
|
|
|
|
|
|
|
otherwise C<version_all_ok> will be used, and the file discovery will be handled |
192
|
|
|
|
|
|
|
by L<Test::Version>. |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=head1 METHODS |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 register_prereqs |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Register L<Test::Version> as an a development prerequisite. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 BUGS |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website |
203
|
|
|
|
|
|
|
https://github.com/plicease/dist-zilla-plugin-test-version/issues |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
206
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
207
|
|
|
|
|
|
|
feature. |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 AUTHORS |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over 4 |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item * |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
Graham Ollis <plicease@cpan.org> |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
=item * |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
Caleb Cushing <xenoterracide@gmail.com> |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=back |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
This software is Copyright (c) 2016 by Caleb Cushing <xenoterracide@gmail.com>. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
This is free software, licensed under: |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=cut |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
__DATA__ |
234
|
|
|
|
|
|
|
__[ __TEST__ ]__ |
235
|
|
|
|
|
|
|
use strict; |
236
|
|
|
|
|
|
|
use warnings; |
237
|
|
|
|
|
|
|
use Test::More; |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
# generated by {{ $name }} {{ $version }} |
240
|
|
|
|
|
|
|
use Test::Version; |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
my @imports = qw( {{ $use_finder ? 'version_ok' : 'version_all_ok' }} ); |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
my $params = { |
245
|
|
|
|
|
|
|
is_strict => {{ $is_strict }}, |
246
|
|
|
|
|
|
|
has_version => {{ $has_version }}, |
247
|
|
|
|
|
|
|
multiple => {{ $multiple }}, |
248
|
|
|
|
|
|
|
{{ $filename_match ? " filename_match => [ $filename_match ]," : '' }} |
249
|
|
|
|
|
|
|
}; |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
push @imports, $params |
252
|
|
|
|
|
|
|
if version->parse( $Test::Version::VERSION ) >= version->parse('1.002'); |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
Test::Version->import(@imports); |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
{{ |
257
|
|
|
|
|
|
|
$use_finder |
258
|
|
|
|
|
|
|
? @filenames > 0 ? join("\n", map { s/'/\\'/g; "version_ok('$_');" } @filenames) : '# finder found no files' |
259
|
|
|
|
|
|
|
: 'version_all_ok;'; |
260
|
|
|
|
|
|
|
}} |
261
|
|
|
|
|
|
|
done_testing; |