File Coverage

blib/lib/Dist/Zilla/Plugin/Test/Kwalitee.pm
Criterion Covered Total %
statement 34 34 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 46 49 93.8


line stmt bran cond sub pod time code
1 2     2   2013451 use strict;
  2         5  
  2         58  
2 2     2   12 use warnings;
  2         3  
  2         122  
3             package Dist::Zilla::Plugin::Test::Kwalitee; # git description: v2.11-22-g5782daa
4             # ABSTRACT: Author tests for kwalitee
5             # KEYWORDS: plugin testing tests distribution kwalitee CPANTS quality lint errors critic
6             # vim: set ts=8 sts=4 sw=4 tw=115 et :
7              
8             our $VERSION = '2.12';
9              
10 2     2   10 use Moose;
  2         5  
  2         17  
11 2     2   11612 use Sub::Exporter::ForMethods 'method_installer'; # method_installer returns a sub.
  2         5  
  2         24  
12             use Data::Section 0.004 # fixed header_re
13 2     2   390 { installer => method_installer }, '-setup';
  2         72  
  2         15  
14 2     2   1386 use namespace::autoclean;
  2         4  
  2         22  
15              
16             with
17             'Dist::Zilla::Role::FileGatherer',
18             'Dist::Zilla::Role::TextTemplate',
19             'Dist::Zilla::Role::PrereqSource';
20              
21 2     2 0 1077 sub mvp_multivalue_args { return qw( skiptest ) }
22              
23             has skiptest => (
24             isa => 'ArrayRef[Str]',
25             traits => [ 'Array' ],
26             default => sub { [] },
27             handles => {
28             skiptest => 'sort',
29             push_skiptest => 'push'
30             },
31             );
32              
33             has filename => (
34             is => 'ro', isa => 'Str',
35             lazy => 1,
36             default => sub { return 'xt/release/kwalitee.t' },
37             );
38              
39             around dump_config => sub
40             {
41             my ($orig, $self) = @_;
42             my $config = $self->$orig;
43              
44             $config->{+__PACKAGE__} = {
45             skiptest => [ $self->skiptest ],
46             filename => $self->filename,
47             blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
48             };
49             return $config;
50             };
51              
52 4     4   1377 sub _tk_prereq { '1.21' }
53              
54             sub register_prereqs
55             {
56 2     2 0 11671 my $self = shift;
57 2         66 $self->zilla->register_prereqs(
58             {
59             type => 'requires',
60             phase => 'develop',
61             },
62             'Test::Kwalitee' => $self->_tk_prereq,
63             );
64             }
65              
66             sub gather_files {
67 2     2 0 186883 my ( $self, ) = @_;
68              
69 2         6 my $test_options = '';
70              
71 2         101 my @skiptests = $self->skiptest;
72 2 100       9 if (@skiptests > 0) {
73 1         3 my $skip = join ' ', map { "-$_" } @skiptests;
  3         10  
74 1         5 $test_options = qq{ qw( $skip ) };
75             }
76              
77 2         861 require Dist::Zilla::File::InMemory;
78              
79 2         75691 my $filename = $self->filename;
80              
81             my $content = $self->fill_in_string(
82 2         6 ${$self->section_data('__TEST__')},
  2         17  
83             {
84             dist => \($self->zilla),
85             plugin => \$self,
86             test_options => \$test_options,
87             tk_prereq => \($self->_tk_prereq),
88             },
89             );
90              
91 2         2344 $self->add_file(
92             Dist::Zilla::File::InMemory->new( {
93             'name' => $filename,
94             'content' => $content,
95             } ),
96             );
97             };
98              
99             __PACKAGE__->meta->make_immutable;
100              
101             #pod =pod
102             #pod
103             #pod =head1 SYNOPSIS
104             #pod
105             #pod In your F<dist.ini>:
106             #pod
107             #pod [Test::Kwalitee]
108             #pod skiptest = use_strict ; Don't test for strictness.
109             #pod
110             #pod =head1 DESCRIPTION
111             #pod
112             #pod This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
113             #pod following file:
114             #pod
115             #pod xt/release/kwalitee.t - a standard Test::Kwalitee test
116             #pod
117             #pod =head1 CONFIGURATION OPTIONS
118             #pod
119             #pod =for stopwords skiptest
120             #pod
121             #pod =head2 skiptest
122             #pod
123             #pod The name of a kwalitee metric to skip (see the list in L<Test::Kwalitee>.
124             #pod Can be used more than once.
125             #pod
126             #pod =head2 filename
127             #pod
128             #pod The filename of the test to add - defaults to F<xt/release/kwalitee.t>.
129             #pod
130             #pod =for Pod::Coverage mvp_multivalue_args register_prereqs gather_files
131             #pod
132             #pod =head1 SEE ALSO
133             #pod
134             #pod =for :list
135             #pod * L<Module::CPANTS::Analyse>
136             #pod * L<App::CPANTS::Lint>
137             #pod * L<Test::Kwalitee>
138             #pod * L<Dist::Zilla::App::Command::kwalitee>
139             #pod * L<Test::Kwalitee::Extra>
140             #pod * L<Dist::Zilla::Plugin::Test::Kwalitee::Extra>
141             #pod
142             #pod =cut
143              
144             =pod
145              
146             =encoding UTF-8
147              
148             =head1 NAME
149              
150             Dist::Zilla::Plugin::Test::Kwalitee - Author tests for kwalitee
151              
152             =head1 VERSION
153              
154             version 2.12
155              
156             =head1 SYNOPSIS
157              
158             In your F<dist.ini>:
159              
160             [Test::Kwalitee]
161             skiptest = use_strict ; Don't test for strictness.
162              
163             =head1 DESCRIPTION
164              
165             This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
166             following file:
167              
168             xt/release/kwalitee.t - a standard Test::Kwalitee test
169              
170             =head1 CONFIGURATION OPTIONS
171              
172             =for stopwords skiptest
173              
174             =head2 skiptest
175              
176             The name of a kwalitee metric to skip (see the list in L<Test::Kwalitee>.
177             Can be used more than once.
178              
179             =head2 filename
180              
181             The filename of the test to add - defaults to F<xt/release/kwalitee.t>.
182              
183             =for Pod::Coverage mvp_multivalue_args register_prereqs gather_files
184              
185             =head1 SEE ALSO
186              
187             =over 4
188              
189             =item *
190              
191             L<Module::CPANTS::Analyse>
192              
193             =item *
194              
195             L<App::CPANTS::Lint>
196              
197             =item *
198              
199             L<Test::Kwalitee>
200              
201             =item *
202              
203             L<Dist::Zilla::App::Command::kwalitee>
204              
205             =item *
206              
207             L<Test::Kwalitee::Extra>
208              
209             =item *
210              
211             L<Dist::Zilla::Plugin::Test::Kwalitee::Extra>
212              
213             =back
214              
215             =head1 SUPPORT
216              
217             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Test-Kwalitee>
218             (or L<bug-Dist-Zilla-Plugin-Test-Kwalitee@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Test-Kwalitee@rt.cpan.org>).
219              
220             There is also a mailing list available for users of this distribution, at
221             L<http://dzil.org/#mailing-list>.
222              
223             There is also an irc channel available for users of this distribution, at
224             irc://irc.perl.org/#distzilla.
225              
226             =head1 AUTHORS
227              
228             =over 4
229              
230             =item *
231              
232             Marcel Gruenauer <marcel@cpan.org>
233              
234             =item *
235              
236             Harley Pig <harleypig@gmail.com>
237              
238             =item *
239              
240             Caleb Cushing <xenoterracide@gmail.com>
241              
242             =item *
243              
244             Kent Fredric <kentfredric@gmail.com>
245              
246             =item *
247              
248             Karen Etheridge <ether@cpan.org>
249              
250             =back
251              
252             =head1 CONTRIBUTORS
253              
254             =for stopwords Marcel Gruenauer Mike Doherty Graham Knop
255              
256             =over 4
257              
258             =item *
259              
260             Marcel Gruenauer <hanekomu@gmail.com>
261              
262             =item *
263              
264             Mike Doherty <doherty@cs.dal.ca>
265              
266             =item *
267              
268             Graham Knop <haarg@haarg.org>
269              
270             =back
271              
272             =head1 COPYRIGHT AND LICENSE
273              
274             This software is copyright (c) 2010 by Marcel Gruenauer.
275              
276             This is free software; you can redistribute it and/or modify it under
277             the same terms as the Perl 5 programming language system itself.
278              
279             =cut
280              
281             __DATA__
282             ___[ __TEST__ ]___
283             # this test was generated with {{ ref($plugin) . ' ' . $plugin->VERSION }}
284             use strict;
285             use warnings;
286             use Test::More 0.88;
287             use Test::Kwalitee {{ $tk_prereq }} 'kwalitee_ok';
288              
289             kwalitee_ok({{ $test_options }});
290              
291             done_testing;