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 2     2   1712179 use 5.008;
  2         5  
2 2     2   6 use strict;
  2         3  
  2         36  
3 2     2   4 use warnings;
  2         4  
  2         97  
4              
5             package Dist::Zilla::Plugin::Test::Portability;
6             # ABSTRACT: Author tests for portability
7             our $VERSION = '2.000007'; # VERSION
8 2     2   6 use Moose;
  2         3  
  2         10  
9             with qw/
10             Dist::Zilla::Role::FileGatherer
11             Dist::Zilla::Role::FileInjector
12             Dist::Zilla::Role::PrereqSource
13             Dist::Zilla::Role::TextTemplate
14             /;
15 2     2   8862 use Dist::Zilla::File::InMemory;
  2         111556  
  2         73  
16 2     2   13 use Data::Section -setup;
  2         3  
  2         20  
17              
18              
19              
20             has options => (
21               is => 'ro',
22               isa => 'Str',
23               default => '',
24             );
25              
26              
27             sub register_prereqs {
28 5     5 0 9109     my ($self) = @_;
29              
30 5         125     $self->zilla->register_prereqs({
31                         type => 'requires',
32                         phase => 'develop',
33                     },
34                     'Test::Portability::Files' => '0',
35                 );
36              
37 5         1967     return;
38             }
39              
40              
41             sub gather_files {
42 5     5 0 93570     my $self = shift;
43              
44             # 'name => val, name=val'
45 5         179     my %options = split(/\W+/, $self->options);
46              
47 5         11     my $opts = '';
48 5 100       15     if (%options) {
49 2         11         $opts = join ', ', map { "$_ => $options{$_}" } sort keys %options;
  3         12  
50 2         7         $opts = "options($opts);";
51                 }
52              
53 5         9     my $filename = 'xt/author/portability.t';
54 5         40     my $content = $self->section_data($filename);
55 5         1338     my $filled_content = $self->fill_in_string( $$content, { opts => $opts } );
56 5         3525     $self->add_file(
57                     Dist::Zilla::File::InMemory->new({
58                         name => $filename,
59                         content => $filled_content,
60                     })
61                 );
62              
63 5         2856     return;
64             }
65              
66             __PACKAGE__->meta->make_immutable;
67 2     2   1467 no Moose;
  2         4  
  2         11  
68             1;
69              
70             =pod
71            
72             =encoding UTF-8
73            
74             =head1 NAME
75            
76             Dist::Zilla::Plugin::Test::Portability - Author tests for portability
77            
78             =head1 VERSION
79            
80             version 2.000007
81            
82             =for test_synopsis BEGIN { die "SKIP: synopsis isn't perl code" }
83            
84             =head1 SYNOPSIS
85            
86             In C<dist.ini>:
87            
88             [Test::Portability]
89             ; you can optionally specify test options
90             options = test_dos_length = 1, use_file_find = 0
91            
92             =head1 DESCRIPTION
93            
94             This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing the
95             following file:
96            
97             xt/author/portability.t - a standard Test::Portability::Files test
98            
99             You can set options for the tests in the 'options' attribute:
100             Specify C<< name = value >> separated by commas.
101            
102             See L<Test::Portability::Files/options> for possible options.
103            
104             =for Pod::Coverage register_prereqs
105            
106             =head2 munge_file
107            
108             Inserts the given options into the generated test file.
109            
110             =for Pod::Coverage gather_files
111            
112             =head1 AVAILABILITY
113            
114             The project homepage is L<http://metacpan.org/release/Dist-Zilla-Plugin-Test-Portability/>.
115            
116             The latest version of this module is available from the Comprehensive Perl
117             Archive Network (CPAN). Visit L<http://www.perl.com/CPAN/> to find a CPAN
118             site near you, or see L<https://metacpan.org/module/Dist::Zilla::Plugin::Test::Portability/>.
119            
120             =head1 SOURCE
121            
122             The development version is on github at L<http://github.com/doherty/Dist-Zilla-Plugin-Test-Portability>
123             and may be cloned from L<git://github.com/doherty/Dist-Zilla-Plugin-Test-Portability.git>
124            
125             =head1 BUGS AND LIMITATIONS
126            
127             You can make new bug reports, and view existing ones, through the
128             web interface at L<https://github.com/doherty/Dist-Zilla-Plugin-Test-Portability/issues>.
129            
130             =head1 AUTHORS
131            
132             =over 4
133            
134             =item *
135            
136             Marcel Gruenauer <marcel@cpan.org>
137            
138             =item *
139            
140             Randy Stauner <rwstauner@cpan.org>
141            
142             =item *
143            
144             Mike Doherty <doherty@cpan.org>
145            
146             =back
147            
148             =head1 COPYRIGHT AND LICENSE
149            
150             This software is copyright (c) 2010 by Mike Doherty.
151            
152             This is free software; you can redistribute it and/or modify it under
153             the same terms as the Perl 5 programming language system itself.
154            
155             =cut
156              
157             __DATA__
158             ___[ xt/author/portability.t ]___
159             #!perl
160            
161             use strict;
162             use warnings;
163            
164             use Test::More;
165            
166             eval 'use Test::Portability::Files';
167             plan skip_all => 'Test::Portability::Files required for testing portability'
168             if $@;
169             {{$opts}}
170             run_tests();
171