File Coverage

blib/lib/Dist/Zilla/Plugin/Test/Kwalitee.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 2 100.0
condition n/a
subroutine 10 10 100.0
pod 0 3 0.0
total 45 48 93.7


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