File Coverage

blib/lib/Dist/Zilla/Plugin/Test/Portability.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 2 100.0
condition n/a
subroutine 8 8 100.0
pod 0 2 0.0
total 43 45 95.5


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