File Coverage

blib/lib/Dist/Zilla/Plugin/Test/Perl/Critic/Freenode.pm
Criterion Covered Total %
statement 39 39 100.0
branch 1 2 50.0
condition 1 3 33.3
subroutine 12 12 100.0
pod 0 2 0.0
total 53 58 91.3


line stmt bran cond sub pod time code
1 1     1   2767558 use 5.008;
  1         4  
2 1     1   5 use strict;
  1         3  
  1         21  
3 1     1   6 use warnings;
  1         2  
  1         56  
4              
5             package Dist::Zilla::Plugin::Test::Perl::Critic::Freenode;
6             # ABSTRACT: Tests to check your code against policies inspired by #perl on Freenode
7             $Dist::Zilla::Plugin::Test::Perl::Critic::Freenode::VERSION = '0.002';
8 1     1   6 use Moose;
  1         2  
  1         9  
9 1     1   6102 use Moose::Util qw( get_all_attribute_values );
  1         3  
  1         9  
10              
11 1     1   716 use Dist::Zilla::File::InMemory;
  1         77412  
  1         39  
12 1     1   9 use Sub::Exporter::ForMethods 'method_installer';
  1         3  
  1         13  
13 1     1   632 use Data::Section 0.004 { installer => method_installer }, '-setup';
  1         30  
  1         7  
14 1     1   839 use namespace::autoclean;
  1         3  
  1         11  
15              
16             # and when the time comes, treat them like templates
17             with qw(
18             Dist::Zilla::Role::FileGatherer
19             Dist::Zilla::Role::TextTemplate
20             Dist::Zilla::Role::PrereqSource
21             );
22              
23             sub gather_files {
24 1     1 0 58735 my ($self) = @_;
25              
26 1         6 my $data = $self->merged_section_data;
27 1 50 33     659 return unless $data and %$data;
28              
29 1         8 my $stash = get_all_attribute_values( $self->meta, $self);
30              
31             # NB: This code is a bit generalised really, and could be forked into its
32             # own plugin.
33 1         738 for my $name ( keys %$data ){
34 1         6 my $template = ${$data->{$name}};
  1         5  
35 1         12 $self->add_file( Dist::Zilla::File::InMemory->new({
36             name => $name,
37             content => $self->fill_in_string( $template, $stash )
38             }));
39             }
40             }
41              
42             sub register_prereqs {
43 1     1 0 3948 my $self = shift;
44              
45 1         50 $self->zilla->register_prereqs(
46             {
47             type => 'requires',
48             phase => 'develop',
49             },
50             'Test::Perl::Critic' => 0,
51             'Perl::Critic::Freenode' => 0,
52              
53             # TODO also extract list of policies used in file $self->critic_config
54             );
55             }
56              
57 1     1   224 no Moose;
  1         2  
  1         7  
58             __PACKAGE__->meta->make_immutable;
59             1;
60              
61             =pod
62              
63             =encoding UTF-8
64              
65             =head1 NAME
66              
67             Dist::Zilla::Plugin::Test::Perl::Critic::Freenode - Tests to check your code against policies inspired by #perl on Freenode
68              
69             =head1 VERSION
70              
71             version 0.002
72              
73             =head1 SYNOPSIS
74              
75             In your F<dist.ini>:
76              
77             [Test::Perl::Critic::Freenode]
78              
79             =head1 DESCRIPTION
80              
81             This will provide a F<xt/author/critic-freenode.t> file for use during the
82             "test" and "release" calls of C<dzil>. To use this, make the changes to
83             F<dist.ini> above and run one of the following:
84              
85             dzil test
86             dzil release
87              
88             During these runs, F<xt/author/critic-freenode.t> will use
89             L<Test::Perl::Critic> to run L<Perl::Critic> against your code and report its
90             findings.
91              
92             This plugin is an extension of L<Dist::Zilla::Plugin::InlineFiles>.
93              
94             This plugin is a fork of L<Dist::Zilla::Plugin::Test::Perl::Critic>.
95              
96             =for Pod::Coverage gather_files register_prereqs
97              
98             =head1 SEE ALSO
99              
100             You can look for information on this module at:
101              
102             =for stopwords AnnoCPAN
103              
104             =over 4
105              
106             =item * Search CPAN
107              
108             L<http://search.cpan.org/dist/Dist-Zilla-Plugin-Test-Perl-Critic-Freenode>
109              
110             =item * See open / report bugs
111              
112             L<https://github.com/pink-mist/Dist-Zilla-Plugin-Test-Perl-Critic-Freenode/issues>
113              
114             =item * Git repository
115              
116             L<https://github.com/pink-mist/Dist-Zilla-Plugin-Test-Perl-Critic-Freenode>
117              
118             =item * AnnoCPAN: Annotated CPAN documentation
119              
120             L<http://annocpan.org/dist/Dist-Zilla-Plugin-Test-Perl-Critic-Freenode>
121              
122             =item * CPAN Ratings
123              
124             L<http://cpanratings.perl.org/d/Dist-Zilla-Plugin-Test-Perl-Critic-Freenode>
125              
126             =back
127              
128             =head1 ORIGINAL AUTHOR
129              
130             Original author of L<Dist::Zilla::Plugin::Test::Perl::Critic> is Jerome Quelin
131              
132             =head1 AUTHOR
133              
134             Andreas Guldstrand
135              
136             =head1 COPYRIGHT AND LICENSE
137              
138             This software is copyright (c) 2017 by Andreas Guldstrand.
139              
140             This is free software; you can redistribute it and/or modify it under
141             the same terms as the Perl 5 programming language system itself.
142              
143             =cut
144              
145             __DATA__
146             ___[ xt/author/critic-freenode.t ]___
147             #!perl
148              
149             use strict;
150             use warnings;
151              
152             use Test::Perl::Critic (-theme => 'freenode', severity => 1);
153             all_critic_ok();