File Coverage

blib/lib/Dist/Zilla/Plugin/Author/KENTNL/CONTRIBUTING.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod n/a
total 31 31 100.0


line stmt bran cond sub pod time code
1 1     1   442 use 5.006; # our
  1         2  
2 1     1   4 use strict;
  1         1  
  1         18  
3 1     1   9 use warnings;
  1         1  
  1         97  
4              
5             package Dist::Zilla::Plugin::Author::KENTNL::CONTRIBUTING;
6              
7             our $VERSION = '0.001006';
8              
9             # ABSTRACT: Generates a CONTRIBUTING file for KENTNL's distributions.
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13             # NB: This list is intentionally short, because these are API-versions
14             # describing which document to fetch, and certain documents will update
15             # without changing their API version
16             my $valid_versions = { map { $_ => 1 } qw( 0.1 ) };
17              
18 1     1   479 use Moose qw( has around extends );
  1         295940  
  1         5  
19 1     1   4100 use Moose::Util::TypeConstraints qw( enum );
  1         1  
  1         9  
20 1     1   925 use Dist::Zilla::Plugin::GenerateFile::FromShareDir 0.006;
  1         456608  
  1         96  
21              
22             extends 'Dist::Zilla::Plugin::GenerateFile::FromShareDir';
23              
24             my $valid_version_enum = enum [ keys %{$valid_versions} ];
25              
26 1     1   12 no Moose::Util::TypeConstraints;
  1         1  
  1         10  
27              
28              
29              
30              
31              
32              
33              
34              
35              
36              
37              
38             has 'document_version' => (
39             isa => $valid_version_enum,
40             is => 'ro',
41             default => '0.1',
42             );
43              
44             has '+filename' => (
45             lazy => 1,
46             default => sub { 'CONTRIBUTING.pod' },
47             );
48              
49             has '+source_filename' => (
50             lazy => 1,
51             default => sub { 'contributing-' . $_[0]->document_version . '.pod' },
52             );
53              
54             has '+location' => (
55             lazy => 1,
56             default => sub { 'root' },
57             );
58              
59             has '+phase' => (
60             lazy => 1,
61             default => sub { 'build' },
62             );
63              
64             around dump_config => sub {
65             my ( $orig, $self, @args ) = @_;
66             my $config = $self->$orig(@args);
67             my $localconf = $config->{ +__PACKAGE__ } = {};
68              
69             $localconf->{document_version} = $self->document_version;
70              
71             $localconf->{ q[$] . __PACKAGE__ . '::VERSION' } = $VERSION
72             unless __PACKAGE__ eq ref $self;
73              
74             return $config;
75             };
76              
77             __PACKAGE__->meta->make_immutable;
78 1     1   301 no Moose;
  1         1  
  1         5  
79              
80             1;
81              
82             __END__
83              
84             =pod
85              
86             =encoding UTF-8
87              
88             =head1 NAME
89              
90             Dist::Zilla::Plugin::Author::KENTNL::CONTRIBUTING - Generates a CONTRIBUTING file for KENTNL's distributions.
91              
92             =head1 VERSION
93              
94             version 0.001006
95              
96             =head1 DESCRIPTION
97              
98             This is a personal Dist::Zilla plug-in that generates a CONTRIBUTING
99             section in my distribution.
100              
101             I would have made something more general, but my head exploded in thinking about it.
102              
103             =head1 ATTRIBUTES
104              
105             =head2 C<document_version>
106              
107             Specify which shared document to deploy
108              
109             Valid values:
110              
111             [0.1]
112              
113             =head1 AUTHOR
114              
115             Kent Fredric <kentnl@cpan.org>
116              
117             =head1 CONTRIBUTORS
118              
119             =for stopwords David Golden Karen Etheridge
120              
121             =over 4
122              
123             =item *
124              
125             David Golden <dagolden@cpan.org>
126              
127             =item *
128              
129             Karen Etheridge <ether@cpan.org>
130              
131             =back
132              
133             =head1 COPYRIGHT AND LICENSE
134              
135             This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
136              
137             This is free software; you can redistribute it and/or modify it under
138             the same terms as the Perl 5 programming language system itself.
139              
140             =cut