File Coverage

blib/lib/Dist/Zilla/Plugin/Covenant.pm
Criterion Covered Total %
statement 25 25 100.0
branch n/a
condition n/a
subroutine 9 9 100.0
pod 0 3 0.0
total 34 37 91.8


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