File Coverage

blib/lib/Dist/Zilla/Plugin/Readme.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition 1 2 50.0
subroutine 6 6 100.0
pod 0 2 0.0
total 30 33 90.9


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Readme 6.037;
2             # ABSTRACT: build a README file
3              
4 9     9   8910 use Moose;
  9         29  
  9         94  
5             with qw/Dist::Zilla::Role::FileGatherer
6             Dist::Zilla::Role::TextTemplate
7             Dist::Zilla::Role::FileMunger/;
8              
9 9     9   89301 use Dist::Zilla::Pragmas;
  9         23  
  9         101  
10              
11 9     9   85 use Moose::Util::TypeConstraints;
  9         36  
  9         147  
12 9     9   25746 use namespace::autoclean;
  9         27  
  9         112  
13              
14             #pod =head1 DESCRIPTION
15             #pod
16             #pod This plugin adds a very simple F<README> file to the distribution, citing the
17             #pod dist's name, version, abstract, and license. It may be more useful or
18             #pod informative in the future.
19             #pod
20             #pod =cut
21              
22             has _file_obj => (
23             is => 'rw', isa => role_type('Dist::Zilla::Role::File'),
24             );
25              
26             sub gather_files {
27 9     9 0 34 my ($self, $arg) = @_;
28              
29 9         712 require Dist::Zilla::File::InMemory;
30              
31 9         45 my $template = q|
32              
33             This archive contains the distribution {{ $dist->name }},
34             version {{ $dist->version }}:
35              
36             {{ $dist->abstract }}
37              
38             {{ $dist->license->notice }}
39              
40             This README file was generated by {{ $generated_by }}.
41              
42             |;
43 9         63 $template =~ s/\A\n+//;
44 9         66 $template =~ s/\n+\z/\n/;
45              
46 9         359 $self->add_file(
47             $self->_file_obj(
48             Dist::Zilla::File::InMemory->new(
49             name => 'README',
50             content => $template,
51             )
52             )
53             );
54              
55 9         180 return;
56             }
57              
58             sub munge_files {
59 9     9 0 23 my $self = shift;
60              
61 9         435 my $file = $self->_file_obj;
62              
63 9   50     74 $file->content(
64             $self->fill_in_string(
65             $file->content,
66             {
67             dist => \($self->zilla),
68             generated_by => \sprintf("%s v%s",
69             ref($self), $self->VERSION || '(dev)'),
70             }
71             )
72             );
73              
74 9         122 return;
75             }
76              
77             __PACKAGE__->meta->make_immutable;
78             1;
79              
80             __END__
81              
82             =pod
83              
84             =encoding UTF-8
85              
86             =head1 NAME
87              
88             Dist::Zilla::Plugin::Readme - build a README file
89              
90             =head1 VERSION
91              
92             version 6.037
93              
94             =head1 DESCRIPTION
95              
96             This plugin adds a very simple F<README> file to the distribution, citing the
97             dist's name, version, abstract, and license. It may be more useful or
98             informative in the future.
99              
100             =head1 PERL VERSION
101              
102             This module should work on any version of perl still receiving updates from
103             the Perl 5 Porters. This means it should work on any version of perl
104             released in the last two to three years. (That is, if the most recently
105             released version is v5.40, then this module should work on both v5.40 and
106             v5.38.)
107              
108             Although it may work on older versions of perl, no guarantee is made that the
109             minimum required version will not be increased. The version may be increased
110             for any reason, and there is no promise that patches will be accepted to
111             lower the minimum required perl.
112              
113             =head1 AUTHOR
114              
115             Ricardo SIGNES 😏 <cpan@semiotic.systems>
116              
117             =head1 COPYRIGHT AND LICENSE
118              
119             This software is copyright (c) 2026 by Ricardo SIGNES.
120              
121             This is free software; you can redistribute it and/or modify it under
122             the same terms as the Perl 5 programming language system itself.
123              
124             =cut