File Coverage

blib/lib/Dist/Zilla/Plugin/Covenant.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 3 0.0
total 28 31 90.3


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