line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::Test::NoTabs; # git description: v0.13-19-gbebd27c |
2
|
|
|
|
|
|
|
# ABSTRACT: Author tests that ensure hard tabs are not used |
3
|
|
|
|
|
|
|
# KEYWORDS: plugin test testing author development whitespace tab tabstop indent formatting |
4
|
|
|
|
|
|
|
# vim: set ts=8 sts=4 sw=4 tw=78 et : |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
|
2706360
|
use Moose; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
25
|
|
9
|
5
|
|
|
5
|
|
20247
|
use Path::Tiny; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
264
|
|
10
|
5
|
|
|
5
|
|
1917
|
use Sub::Exporter::ForMethods 'method_installer'; # method_installer returns a sub. |
|
5
|
|
|
|
|
2244
|
|
|
5
|
|
|
|
|
27
|
|
11
|
|
|
|
|
|
|
use Data::Section 0.004 # fixed header_re |
12
|
5
|
|
|
5
|
|
716
|
{ installer => method_installer }, '-setup'; |
|
5
|
|
|
|
|
85
|
|
|
5
|
|
|
|
|
17
|
|
13
|
5
|
|
|
5
|
|
2192
|
use Moose::Util::TypeConstraints 'role_type'; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
64
|
|
14
|
5
|
|
|
5
|
|
1291
|
use namespace::autoclean; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
34
|
|
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
with |
17
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileGatherer', |
18
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
19
|
|
|
|
|
|
|
'Dist::Zilla::Role::TextTemplate', |
20
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
21
|
|
|
|
|
|
|
method => 'found_files', |
22
|
|
|
|
|
|
|
finder_arg_names => [ 'finder' ], |
23
|
|
|
|
|
|
|
default_finders => [ ':InstallModules', ':ExecFiles', ':TestFiles' ], |
24
|
|
|
|
|
|
|
}, |
25
|
|
|
|
|
|
|
'Dist::Zilla::Role::PrereqSource'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has filename => ( |
28
|
|
|
|
|
|
|
is => 'ro', isa => 'Str', |
29
|
|
|
|
|
|
|
lazy => 1, |
30
|
|
|
|
|
|
|
default => sub { return 'xt/author/no-tabs.t' }, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has files => ( |
34
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
35
|
|
|
|
|
|
|
traits => ['Array'], |
36
|
|
|
|
|
|
|
handles => { files => 'elements' }, |
37
|
|
|
|
|
|
|
lazy => 1, |
38
|
|
|
|
|
|
|
default => sub { [] }, |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has _file_obj => ( |
42
|
|
|
|
|
|
|
is => 'rw', isa => role_type('Dist::Zilla::Role::File'), |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub mvp_multivalue_args { qw(files module_finder script_finder) } |
46
|
5
|
|
|
5
|
0
|
624
|
sub mvp_aliases { return { file => 'files' } } |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
around BUILDARGS => sub |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
my $orig = shift; |
51
|
|
|
|
|
|
|
my $self = shift; |
52
|
|
|
|
|
|
|
my $args = $self->$orig(@_); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# handle legacy args |
55
|
|
|
|
|
|
|
my $module_finder = delete $args->{module_finder}; |
56
|
|
|
|
|
|
|
my $script_finder = delete $args->{script_finder}; |
57
|
|
|
|
|
|
|
if ($module_finder or $script_finder) |
58
|
|
|
|
|
|
|
{ |
59
|
|
|
|
|
|
|
$args->{zilla}->log('folding deprecated options (module_finder, script_finder) into finder'); |
60
|
|
|
|
|
|
|
$args->{finder} = [ $args->finder ] if $args->{finder} and not ref $args->{finder}; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
push @{$args->{finder}}, |
63
|
|
|
|
|
|
|
$module_finder |
64
|
|
|
|
|
|
|
? (ref $module_finder ? @$module_finder : $module_finder) |
65
|
|
|
|
|
|
|
: ':InstallModules'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
push @{$args->{finder}}, |
68
|
|
|
|
|
|
|
$script_finder |
69
|
|
|
|
|
|
|
? (ref $script_finder ? @$script_finder : $script_finder) |
70
|
|
|
|
|
|
|
: (':ExecFiles', ':TestFiles'); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return $args; |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
around dump_config => sub |
77
|
|
|
|
|
|
|
{ |
78
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
79
|
|
|
|
|
|
|
my $config = $self->$orig; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
82
|
|
|
|
|
|
|
finder => $self->finder, |
83
|
|
|
|
|
|
|
filename => $self->filename, |
84
|
|
|
|
|
|
|
}; |
85
|
|
|
|
|
|
|
return $config; |
86
|
|
|
|
|
|
|
}; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub register_prereqs |
89
|
|
|
|
|
|
|
{ |
90
|
5
|
|
|
5
|
0
|
1122
|
my $self = shift; |
91
|
5
|
|
|
|
|
118
|
$self->zilla->register_prereqs( |
92
|
|
|
|
|
|
|
{ |
93
|
|
|
|
|
|
|
type => 'requires', |
94
|
|
|
|
|
|
|
phase => 'develop', |
95
|
|
|
|
|
|
|
}, |
96
|
|
|
|
|
|
|
'Test::More' => '0.88', |
97
|
|
|
|
|
|
|
'Test::NoTabs' => '0', |
98
|
|
|
|
|
|
|
); |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub gather_files |
102
|
|
|
|
|
|
|
{ |
103
|
5
|
|
|
5
|
0
|
196523
|
my $self = shift; |
104
|
|
|
|
|
|
|
|
105
|
5
|
|
|
|
|
2157
|
require Dist::Zilla::File::InMemory; |
106
|
|
|
|
|
|
|
|
107
|
5
|
|
|
|
|
22
|
$self->add_file( |
108
|
|
|
|
|
|
|
$self->_file_obj( |
109
|
|
|
|
|
|
|
Dist::Zilla::File::InMemory->new( |
110
|
|
|
|
|
|
|
name => $self->filename, |
111
|
5
|
|
|
|
|
247117
|
content => ${$self->section_data('__TEST__')}, |
112
|
|
|
|
|
|
|
) |
113
|
|
|
|
|
|
|
) |
114
|
|
|
|
|
|
|
); |
115
|
5
|
|
|
|
|
2578
|
return; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
sub munge_files |
119
|
|
|
|
|
|
|
{ |
120
|
5
|
|
|
5
|
0
|
5635
|
my $self = shift; |
121
|
|
|
|
|
|
|
|
122
|
11
|
|
66
|
|
|
801
|
my @filenames = map { path($_->name)->relative('.')->stringify } |
|
12
|
|
|
|
|
7431
|
|
123
|
5
|
|
|
|
|
22
|
grep { not ($_->can('is_bytes') and $_->is_bytes) } |
124
|
5
|
|
|
|
|
8
|
@{ $self->found_files }; |
125
|
5
|
|
|
|
|
654
|
push @filenames, $self->files; |
126
|
|
|
|
|
|
|
|
127
|
5
|
|
|
|
|
25
|
$self->log_debug('adding file ' . $_) foreach @filenames; |
128
|
|
|
|
|
|
|
|
129
|
5
|
|
|
|
|
2458
|
my $file = $self->_file_obj; |
130
|
5
|
|
|
|
|
22
|
$file->content( |
131
|
|
|
|
|
|
|
$self->fill_in_string( |
132
|
|
|
|
|
|
|
$file->content, |
133
|
|
|
|
|
|
|
{ |
134
|
|
|
|
|
|
|
dist => \($self->zilla), |
135
|
|
|
|
|
|
|
plugin => \$self, |
136
|
|
|
|
|
|
|
filenames => \@filenames, |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
) |
139
|
|
|
|
|
|
|
); |
140
|
|
|
|
|
|
|
|
141
|
5
|
|
|
|
|
5841
|
return; |
142
|
|
|
|
|
|
|
} |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
#pod =pod |
147
|
|
|
|
|
|
|
#pod |
148
|
|
|
|
|
|
|
#pod =for Pod::Coverage::TrustPod |
149
|
|
|
|
|
|
|
#pod mvp_aliases |
150
|
|
|
|
|
|
|
#pod register_prereqs |
151
|
|
|
|
|
|
|
#pod gather_files |
152
|
|
|
|
|
|
|
#pod munge_files |
153
|
|
|
|
|
|
|
#pod |
154
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
155
|
|
|
|
|
|
|
#pod |
156
|
|
|
|
|
|
|
#pod In your F<dist.ini>: |
157
|
|
|
|
|
|
|
#pod |
158
|
|
|
|
|
|
|
#pod [Test::NoTabs] |
159
|
|
|
|
|
|
|
#pod finder = my_finder |
160
|
|
|
|
|
|
|
#pod finder = other_finder |
161
|
|
|
|
|
|
|
#pod |
162
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
163
|
|
|
|
|
|
|
#pod |
164
|
|
|
|
|
|
|
#pod This is a plugin that runs at the L<gather files|Dist::Zilla::Role::FileGatherer> stage, |
165
|
|
|
|
|
|
|
#pod providing the file F<xt/author/no-tabs.t>, a standard L<Test::NoTabs> test. |
166
|
|
|
|
|
|
|
#pod |
167
|
|
|
|
|
|
|
#pod =head1 CONFIGURATION OPTIONS |
168
|
|
|
|
|
|
|
#pod |
169
|
|
|
|
|
|
|
#pod This plugin accepts the following options: |
170
|
|
|
|
|
|
|
#pod |
171
|
|
|
|
|
|
|
#pod =head2 C<finder> |
172
|
|
|
|
|
|
|
#pod |
173
|
|
|
|
|
|
|
#pod =for stopwords FileFinder |
174
|
|
|
|
|
|
|
#pod |
175
|
|
|
|
|
|
|
#pod This is the name of a L<FileFinder|Dist::Zilla::Role::FileFinder> for finding |
176
|
|
|
|
|
|
|
#pod files to check. The default value is C<:InstallModules>, |
177
|
|
|
|
|
|
|
#pod C<:ExecFiles> (see also L<Dist::Zilla::Plugin::ExecDir>) and C<:TestFiles>; |
178
|
|
|
|
|
|
|
#pod this option can be used more than once. |
179
|
|
|
|
|
|
|
#pod |
180
|
|
|
|
|
|
|
#pod Other predefined finders are listed in |
181
|
|
|
|
|
|
|
#pod L<Dist::Zilla::Role::FileFinderUser/default_finders>. |
182
|
|
|
|
|
|
|
#pod You can define your own with the |
183
|
|
|
|
|
|
|
#pod L<[FileFinder::ByName]|Dist::Zilla::Plugin::FileFinder::ByName> plugin. |
184
|
|
|
|
|
|
|
#pod |
185
|
|
|
|
|
|
|
#pod =head2 C<file> |
186
|
|
|
|
|
|
|
#pod |
187
|
|
|
|
|
|
|
#pod a filename to also test, in addition to any files found |
188
|
|
|
|
|
|
|
#pod earlier. This option can be repeated to specify multiple additional files. |
189
|
|
|
|
|
|
|
#pod |
190
|
|
|
|
|
|
|
#pod =head2 C<filename> |
191
|
|
|
|
|
|
|
#pod |
192
|
|
|
|
|
|
|
#pod The filename of the test to add - defaults to F<xt/author/no-tabs.t>. |
193
|
|
|
|
|
|
|
#pod |
194
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
195
|
|
|
|
|
|
|
#pod |
196
|
|
|
|
|
|
|
#pod =for :list |
197
|
|
|
|
|
|
|
#pod * Test::NoTabs |
198
|
|
|
|
|
|
|
#pod * Test::Tabs |
199
|
|
|
|
|
|
|
#pod |
200
|
|
|
|
|
|
|
#pod =cut |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=pod |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=encoding UTF-8 |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 NAME |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Dist::Zilla::Plugin::Test::NoTabs - Author tests that ensure hard tabs are not used |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 VERSION |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
version 0.14 |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 SYNOPSIS |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
In your F<dist.ini>: |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
[Test::NoTabs] |
219
|
|
|
|
|
|
|
finder = my_finder |
220
|
|
|
|
|
|
|
finder = other_finder |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 DESCRIPTION |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
This is a plugin that runs at the L<gather files|Dist::Zilla::Role::FileGatherer> stage, |
225
|
|
|
|
|
|
|
providing the file F<xt/author/no-tabs.t>, a standard L<Test::NoTabs> test. |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=for Pod::Coverage::TrustPod mvp_aliases |
228
|
|
|
|
|
|
|
register_prereqs |
229
|
|
|
|
|
|
|
gather_files |
230
|
|
|
|
|
|
|
munge_files |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=head1 CONFIGURATION OPTIONS |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
This plugin accepts the following options: |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=head2 C<finder> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=for stopwords FileFinder |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
This is the name of a L<FileFinder|Dist::Zilla::Role::FileFinder> for finding |
241
|
|
|
|
|
|
|
files to check. The default value is C<:InstallModules>, |
242
|
|
|
|
|
|
|
C<:ExecFiles> (see also L<Dist::Zilla::Plugin::ExecDir>) and C<:TestFiles>; |
243
|
|
|
|
|
|
|
this option can be used more than once. |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Other predefined finders are listed in |
246
|
|
|
|
|
|
|
L<Dist::Zilla::Role::FileFinderUser/default_finders>. |
247
|
|
|
|
|
|
|
You can define your own with the |
248
|
|
|
|
|
|
|
L<[FileFinder::ByName]|Dist::Zilla::Plugin::FileFinder::ByName> plugin. |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
=head2 C<file> |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
a filename to also test, in addition to any files found |
253
|
|
|
|
|
|
|
earlier. This option can be repeated to specify multiple additional files. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=head2 C<filename> |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
The filename of the test to add - defaults to F<xt/author/no-tabs.t>. |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
=head1 SEE ALSO |
260
|
|
|
|
|
|
|
|
261
|
|
|
|
|
|
|
=over 4 |
262
|
|
|
|
|
|
|
|
263
|
|
|
|
|
|
|
=item * |
264
|
|
|
|
|
|
|
|
265
|
|
|
|
|
|
|
Test::NoTabs |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
=item * |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
Test::Tabs |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=back |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=head1 AUTHOR |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
276
|
|
|
|
|
|
|
|
277
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Florian Ragwitz. |
280
|
|
|
|
|
|
|
|
281
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
282
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
=for stopwords Karen Etheridge |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
=cut |
291
|
|
|
|
|
|
|
|
292
|
|
|
|
|
|
|
__DATA__ |
293
|
|
|
|
|
|
|
___[ __TEST__ ]___ |
294
|
|
|
|
|
|
|
use strict; |
295
|
|
|
|
|
|
|
use warnings; |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
# this test was generated with {{ ref($plugin) . ' ' . $plugin->VERSION }} |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
use Test::More 0.88; |
300
|
|
|
|
|
|
|
use Test::NoTabs; |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
my @files = ( |
303
|
|
|
|
|
|
|
{{ join(",\n", map { " '" . $_ . "'" } map { s/'/\\'/g; $_ } sort @filenames) }} |
304
|
|
|
|
|
|
|
); |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
notabs_ok($_) foreach @files; |
307
|
|
|
|
|
|
|
done_testing; |