File Coverage

blib/lib/Dist/Zilla/Plugin/Covenant.pm
Criterion Covered Total %
statement 21 21 100.0
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 31 36 86.1


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Covenant;
2             our $AUTHORITY = 'cpan:YANICK';
3             # ABSTRACT: add the author's pledge to the distribution
4             $Dist::Zilla::Plugin::Covenant::VERSION = '0.1.2';
5              
6              
7 1     1   3063034 use 5.20.0;
  1         4  
8 1     1   6 use warnings;
  1         3  
  1         37  
9              
10 1     1   5 use Moose;
  1         3  
  1         10  
11 1     1   8380 use Dist::Zilla::File::InMemory;
  1         95422  
  1         63  
12              
13             with qw/
14             Dist::Zilla::Role::Plugin
15             Dist::Zilla::Role::FileGatherer
16             Dist::Zilla::Role::TextTemplate
17             Dist::Zilla::Role::MetaProvider
18             /;
19              
20 1     1   622 use experimental 'signatures';
  1         984  
  1         6  
21              
22             has pledge_file => (
23             is => 'ro',
24             default => 'AUTHOR_PLEDGE',
25             );
26              
27             sub metadata {
28 1     1 0 22831 return { 'x_author_pledge' => { 'version' => 1 } };
29             }
30              
31             has '+zilla' => (
32             handles => {
33             distribution_name => 'name',
34             authors => 'authors',
35             }
36             );
37              
38             has pledge => (
39             is => 'ro',
40             lazy => 1,
41             default => sub($self) {
42             $self->fill_in_string(
43             pledge_template(), {
44             distribution => $self->distribution_name,
45             author => join ', ', @{ $self->authors },
46             }
47             );
48             },
49             );
50              
51 1 50   1 0 65744 sub gather_files ($self) {
  1 50       5  
  1         3  
  1         3  
52 1         37 $self->add_file(
53             Dist::Zilla::File::InMemory->new({
54             content => $self->pledge,
55             name => $self->pledge_file,
56             })
57             );
58             }
59              
60             sub pledge_template {
61 1     1 0 15 return <<'END_PLEDGE';
62              
63             # CPAN Covenant for {{ $distribution }}
64              
65             I, {{ $author }}, hereby give modules@perl.org permission to grant co-maintainership
66             to {{ $distribution }}, if all the following conditions are met:
67              
68             (1) I haven't released the module for a year or more
69             (2) There are outstanding issues in the module's public bug tracker
70             (3) Email to my CPAN email address hasn't been answered after a month
71             (4) The requester wants to make worthwhile changes that will benefit CPAN
72              
73             In the event of my death, then the time-limits in (1) and (3) do not apply.
74              
75             END_PLEDGE
76             }
77              
78             __PACKAGE__->meta->make_immutable;
79              
80             1;
81              
82             __END__
83              
84             =pod
85              
86             =encoding UTF-8
87              
88             =head1 NAME
89              
90             Dist::Zilla::Plugin::Covenant - add the author's pledge to the distribution
91              
92             =head1 VERSION
93              
94             version 0.1.2
95              
96             =head1 SYNOPSIS
97              
98             In dist.ini:
99              
100             [Covenant]
101             version = 1
102             pledge_file = AUTHOR_PLEDGE
103              
104             =head1 DESCRIPTION
105              
106             C<Dist::Zilla::Plugin::Covenant> adds the file
107             'I<AUTHOR_PLEDGE>' to the distribution. The author(s)
108             as defined in I<dist.ini> is taken as being the pledgee(s).
109              
110             The I<META> file of the distribution is also modified to
111             include a I<x_author_pledge> stanza.
112              
113             =head1 CONFIGURATION OPTIONS
114              
115             =head2 version
116              
117             Version of the pledge to use.
118              
119             Defaults to '1' (the only version currently existing).
120              
121             =head2 pledge_file
122              
123             Name of the file holding the pledge.
124              
125             Defaults to 'AUTHOR_PLEDGE'.
126              
127             =head1 AUTHOR
128              
129             Yanick Champoux <yanick@babyl.dyndns.org>
130              
131             =head1 COPYRIGHT AND LICENSE
132              
133             This software is copyright (c) 2011 by Yanick Champoux.
134              
135             This is free software; you can redistribute it and/or modify it under
136             the same terms as the Perl 5 programming language system itself.
137              
138             =cut