File Coverage

blib/lib/Dist/Zilla/Plugin/Test/Portability.pm
Criterion Covered Total %
statement 35 35 100.0
branch 2 2 100.0
condition n/a
subroutine 9 9 100.0
pod 0 2 0.0
total 46 48 95.8


line stmt bran cond sub pod time code
1 3     3   5620548 use strict;
  3         15  
  3         89  
2 3     3   21 use warnings;
  3         6  
  3         193  
3              
4             # ABSTRACT: Author tests for portability
5              
6             our $VERSION = '2.001001';
7              
8             use Moose;
9 3     3   513 with qw/
  3         410773  
  3         22  
10             Dist::Zilla::Role::FileGatherer
11             Dist::Zilla::Role::FileInjector
12             Dist::Zilla::Role::PrereqSource
13             Dist::Zilla::Role::TextTemplate
14             /;
15             use Dist::Zilla::File::InMemory;
16 3     3   19061 use Sub::Exporter::ForMethods 'method_installer';
  3         587973  
  3         143  
17 3     3   28 use Data::Section 0.004 { installer => method_installer }, '-setup';
  3         7  
  3         34  
18 3     3   1455 use namespace::autoclean;
  3         15170  
  3         22  
19 3     3   2216  
  3         7  
  3         21  
20             has options => (
21             is => 'ro',
22             isa => 'Str',
23             default => '',
24             );
25              
26             around dump_config => sub
27             {
28             my ($orig, $self) = @_;
29             my $config = $self->$orig;
30              
31             $config->{+__PACKAGE__} = {
32             options => $self->options,
33             blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (),
34             };
35             return $config;
36             };
37              
38             my ($self) = @_;
39              
40 6     6 0 13689 $self->zilla->register_prereqs({
41             phase => 'develop',
42 6         170 type => 'requires',
43             },
44             'Test::More' => 0,
45             'Test::Portability::Files' => '0',
46             );
47              
48             return;
49             }
50 6         3173  
51             my $self = shift;
52              
53             # 'name => val, name=val'
54 6     6 0 194464 my %options = split(/\W+/, $self->options);
55              
56             my $opts = '';
57 6         201 if (%options) {
58             $opts = join ', ', map "$_ => $options{$_}", sort keys %options;
59 6         17 $opts = "options($opts);";
60 6 100       19 }
61 2         18  
62 2         8 my $filename = 'xt/author/portability.t';
63             my $filled_content = $self->fill_in_string(
64             ${ $self->section_data($filename) },
65 6         13 { opts => $opts },
66             );
67 6         9 $self->add_file(
  6         31  
68             Dist::Zilla::File::InMemory->new({
69             name => $filename,
70 6         7357 content => $filled_content,
71             })
72             );
73              
74             return;
75             }
76              
77 6         4665 __PACKAGE__->meta->make_immutable;
78             1;
79              
80             #pod =pod
81             #pod
82             #pod =begin :prelude
83             #pod
84             #pod =for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }
85             #pod
86             #pod =end :prelude
87             #pod
88             #pod =head1 SYNOPSIS
89             #pod
90             #pod In your F<dist.ini>:
91             #pod
92             #pod [Test::Portability]
93             #pod ; you can optionally specify test options
94             #pod options = test_dos_length = 1, use_file_find = 0
95             #pod
96             #pod =cut
97              
98             #pod =head1 DESCRIPTION
99             #pod
100             #pod This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
101             #pod following file:
102             #pod
103             #pod xt/author/portability.t - a standard Test::Portability::Files test
104             #pod
105             #pod You can set options for the tests in the 'options' attribute:
106             #pod Specify C<< name = value >> separated by commas.
107             #pod
108             #pod See L<Test::Portability::Files/options> for possible options.
109             #pod
110             #pod =cut
111              
112             #pod =for Pod::Coverage register_prereqs
113             #pod
114             #pod =cut
115              
116             #pod =head2 munge_file
117             #pod
118             #pod Inserts the given options into the generated test file.
119             #pod
120             #pod =for Pod::Coverage gather_files
121             #pod
122             #pod =cut
123              
124             =pod
125              
126             =encoding UTF-8
127              
128             =head1 NAME
129              
130             Dist::Zilla::Plugin::Test::Portability - Author tests for portability
131              
132             =head1 VERSION
133              
134             version 2.001001
135              
136             =for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }
137              
138             =head1 SYNOPSIS
139              
140             In your F<dist.ini>:
141              
142             [Test::Portability]
143             ; you can optionally specify test options
144             options = test_dos_length = 1, use_file_find = 0
145              
146             =head1 DESCRIPTION
147              
148             This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
149             following file:
150              
151             xt/author/portability.t - a standard Test::Portability::Files test
152              
153             You can set options for the tests in the 'options' attribute:
154             Specify C<< name = value >> separated by commas.
155              
156             See L<Test::Portability::Files/options> for possible options.
157              
158             =for Pod::Coverage register_prereqs
159              
160             =head2 munge_file
161              
162             Inserts the given options into the generated test file.
163              
164             =for Pod::Coverage gather_files
165              
166             =head1 SUPPORT
167              
168             Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-Test-Portability>
169             (or L<bug-Dist-Zilla-Plugin-Test-Portability@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-Test-Portability@rt.cpan.org>).
170              
171             There is also a mailing list available for users of this distribution, at
172             L<http://dzil.org/#mailing-list>.
173              
174             There is also an irc channel available for users of this distribution, at
175             L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>.
176              
177             =head1 AUTHORS
178              
179             =over 4
180              
181             =item *
182              
183             Marcel Gruenauer <marcel@cpan.org>
184              
185             =item *
186              
187             Randy Stauner <rwstauner@cpan.org>
188              
189             =item *
190              
191             Mike Doherty <doherty@cpan.org>
192              
193             =back
194              
195             =head1 CONTRIBUTORS
196              
197             =for stopwords Karen Etheridge Marcel Gruenauer Mike Doherty Randy Stauner Dave Rolsky Graham Knop Kent Fredric Peter Vereshagin
198              
199             =over 4
200              
201             =item *
202              
203             Karen Etheridge <ether@cpan.org>
204              
205             =item *
206              
207             Marcel Gruenauer <hanekomu@gmail.com>
208              
209             =item *
210              
211             Mike Doherty <doherty@cs.dal.ca>
212              
213             =item *
214              
215             Mike Doherty <mike@mikedoherty.ca>
216              
217             =item *
218              
219             Randy Stauner <randy@magnificent-tears.com>
220              
221             =item *
222              
223             Dave Rolsky <autarch@urth.org>
224              
225             =item *
226              
227             Graham Knop <haarg@haarg.org>
228              
229             =item *
230              
231             Karen Etheridge <github@froods.org>
232              
233             =item *
234              
235             Kent Fredric <kentfredric@gmail.com>
236              
237             =item *
238              
239             Peter Vereshagin <peter@vereshagin.org>
240              
241             =back
242              
243             =head1 COPYRIGHT AND LICENCE
244              
245             This software is copyright (c) 2010 by Mike Doherty.
246              
247             This is free software; you can redistribute it and/or modify it under
248             the same terms as the Perl 5 programming language system itself.
249              
250             =cut
251              
252             ___[ xt/author/portability.t ]___
253             use strict;
254             use warnings;
255              
256             use Test::More;
257              
258             use Test::Portability::Files;
259             {{$opts}}
260             run_tests();