File Coverage

lib/Dist/Zilla/Plugin/Test/NoBreakpoints.pm
Criterion Covered Total %
statement 24 42 57.1
branch n/a
condition 0 3 0.0
subroutine 8 12 66.6
pod 0 4 0.0
total 32 61 52.4


line stmt bran cond sub pod time code
1 1     1   37076 use strict;
  1         2  
  1         28  
2 1     1   6 use warnings;
  1         2  
  1         68  
3             package Dist::Zilla::Plugin::Test::NoBreakpoints;
4             {
5             $Dist::Zilla::Plugin::Test::NoBreakpoints::DIST = 'Dist-Zilla-Plugin-Test-NoBreakpoints';
6             }
7             # ABSTRACT: Author tests making sure no debugger breakpoints make it to 'released'
8             # KEYWORDS: plugin test testing author development debug debugger debugging breakpoint breakpoints
9             $Dist::Zilla::Plugin::Test::NoBreakpoints::VERSION = '0.0.2';
10 1     1   955 use Moose;
  1         477838  
  1         7  
11 1     1   8417 use Path::Tiny;
  1         9332  
  1         67  
12 1     1   905 use Sub::Exporter::ForMethods 'method_installer';
  1         844  
  1         4  
13             use Data::Section 0.004 # fixed header_re
14 1     1   975 { installer => method_installer }, '-setup';
  1         14099  
  1         7  
15 1     1   771 use Moose::Util::TypeConstraints 'role_type';
  1         2  
  1         12  
16 1     1   1181 use namespace::autoclean;
  1         8303  
  1         5  
17              
18             with
19             'Dist::Zilla::Role::FileGatherer',
20             'Dist::Zilla::Role::FileMunger',
21             'Dist::Zilla::Role::TextTemplate',
22             'Dist::Zilla::Role::FileFinderUser' => {
23             method => 'found_files',
24             finder_arg_names => [ 'finder' ],
25             default_finders => [ ':InstallModules', ':ExecFiles', ':TestFiles' ],
26             },
27             'Dist::Zilla::Role::PrereqSource',
28             ;
29              
30             has filename => (
31             is => 'ro', isa => 'Str',
32             lazy => 1,
33             default => sub { return 'xt/author/no-breakpoints.t' },
34             );
35              
36             has files => (
37             isa => 'ArrayRef[Str]',
38             traits => ['Array'],
39             handles => { files => 'elements' },
40             lazy => 1,
41             default => sub { [] },
42             );
43              
44             has _file_obj => (
45             is => 'rw', isa => role_type('Dist::Zilla::Role::File'),
46             );
47              
48             sub mvp_multivalue_args { 'files' }
49 0     0 0   sub mvp_aliases { return { file => 'files' } }
50              
51             around dump_config => sub
52             {
53             my ($orig, $self) = @_;
54             my $config = $self->$orig;
55              
56             $config->{+__PACKAGE__} = {
57             map { $_ => $self->$_ } qw(filename finder),
58             };
59             return $config;
60             };
61              
62             sub gather_files
63             {
64 0     0 0   my $self = shift;
65              
66 0           require Dist::Zilla::File::InMemory;
67              
68             $self->add_file(
69             $self->_file_obj(
70             Dist::Zilla::File::InMemory->new(
71             name => $self->filename,
72 0           content => ${$self->section_data('__TEST__')},
  0            
73             )
74             )
75             );
76              
77 0           return;
78             }
79              
80             sub munge_files
81             {
82 0     0 0   my $self = shift;
83              
84 0           my @filenames = map { path($_->name)->relative('.')->stringify }
85 0   0       grep { not ($_->can('is_bytes') and $_->is_bytes) }
86 0           @{ $self->found_files };
  0            
87 0           push @filenames, $self->files;
88              
89 0           $self->log_debug('adding file ' . $_) foreach @filenames;
90              
91 0           my $file = $self->_file_obj;
92 0           $file->content(
93             $self->fill_in_string(
94             $file->content,
95             {
96             dist => \($self->zilla),
97             plugin => \$self,
98             filenames => [ sort @filenames ],
99             },
100             )
101             );
102              
103 0           return;
104             }
105              
106             sub register_prereqs
107             {
108 0     0 0   my $self = shift;
109 0           $self->zilla->register_prereqs(
110             {
111             type => 'requires',
112             phase => 'develop',
113             },
114             'Test::More' => '0.88',
115             'Test::NoBreakpoints' => '0.15',
116             );
117             }
118              
119             __PACKAGE__->meta->make_immutable;
120             1;
121              
122             =pod
123              
124             =encoding UTF-8
125              
126             =head1 NAME
127              
128             Dist::Zilla::Plugin::Test::NoBreakpoints - Author tests making sure no debugger breakpoints make it to 'released'
129              
130             =head1 VERSION
131              
132             version 0.0.2
133              
134             =head1 DESCRIPTION
135              
136             Generate an author L<Test::NoBreakpoints>.
137              
138             This is an extension of L<Dist::Zilla::Plugin::InlineFiles>, providing
139             the file F<xt/author/no-breakpoints.t>, a standard L<Test::NoBreakpoints> test.
140              
141             =head1 CONFIGURATION OPTIONS
142              
143             This plugin accepts the following options:
144              
145             =head2 C<finder>
146              
147             =for stopwords FileFinder
148              
149             This is the name of a L<FileFinder|Dist::Zilla::Role::FileFinder> for finding
150             files to check. The default value is C<:InstallModules>,
151             C<:ExecFiles> (see also L<Dist::Zilla::Plugin::ExecDir>) and C<:TestFiles>;
152             this option can be used more than once.
153              
154             Other predefined finders are listed in
155             L<Dist::Zilla::Role::FileFinderUser/default_finders>.
156             You can define your own with the
157             L<[FileFinder::ByName]|Dist::Zilla::Plugin::FileFinder::ByName> plugin.
158              
159             =head2 C<file>
160              
161             a filename to also test, in addition to any files found
162             earlier. This option can be repeated to specify multiple additional files.
163              
164             =head2 C<filename>
165              
166             The filename of the test to add - defaults to F<xt/author/test-eol.t>.
167              
168             =for Pod::Coverage mvp_multivalue_args mvp_aliases gather_files munge_files register_prereqs
169              
170             =head1 ACKNOWLEDGMENTS
171              
172             This module was B<heavily> cribbed from L<Dist::Zilla::Plugin::Test::EOL>.
173              
174             =head1 SEE ALSO
175              
176             =over 4
177              
178             =item *
179              
180             Test::NoBreakpoints
181              
182             =back
183              
184             =head1 AUTHOR
185              
186             Chisel <chisel@chizography.net>
187              
188             =head1 COPYRIGHT AND LICENSE
189              
190             This software is copyright (c) 2015 by Chisel Wright.
191              
192             This is free software; you can redistribute it and/or modify it under
193             the same terms as the Perl 5 programming language system itself.
194              
195             =cut
196              
197             __DATA__
198             ___[ __TEST__ ]___
199             use strict;
200             use warnings;
201              
202             # this test was generated with {{ ref($plugin) . ' ' . $plugin->VERSION }}
203              
204             use Test::More 0.88;
205             use Test::NoBreakpoints 0.15;
206              
207             all_files_no_breakpoints_ok();
208              
209             done_testing;