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.030;
2             # ABSTRACT: build a README file
3              
4 9     9   7183 use Moose;
  9         25  
  9         69  
5             with qw/Dist::Zilla::Role::FileGatherer
6             Dist::Zilla::Role::TextTemplate
7             Dist::Zilla::Role::FileMunger/;
8              
9 9     9   64561 use Dist::Zilla::Pragmas;
  9         30  
  9         95  
10              
11 9     9   101 use Moose::Util::TypeConstraints;
  9         26  
  9         111  
12 9     9   20941 use namespace::autoclean;
  9         43  
  9         89  
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 39 my ($self, $arg) = @_;
28              
29 9         480 require Dist::Zilla::File::InMemory;
30              
31 9         36 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         57 $template =~ s/\A\n+//;
44 9         68 $template =~ s/\n+\z/\n/;
45              
46 9         297 $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         162 return;
56             }
57              
58             sub munge_files {
59 9     9 0 26 my $self = shift;
60              
61 9         319 my $file = $self->_file_obj;
62              
63 9   50     79 $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         105 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.030
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 released
104             in the last two to three years. (That is, if the most recently released
105             version is v5.40, then this module should work on both v5.40 and v5.38.)
106              
107             Although it may work on older versions of perl, no guarantee is made that the
108             minimum required version will not be increased. The version may be increased
109             for any reason, and there is no promise that patches will be accepted to lower
110             the minimum required perl.
111              
112             =head1 AUTHOR
113              
114             Ricardo SIGNES 😏 <cpan@semiotic.systems>
115              
116             =head1 COPYRIGHT AND LICENSE
117              
118             This software is copyright (c) 2023 by Ricardo SIGNES.
119              
120             This is free software; you can redistribute it and/or modify it under
121             the same terms as the Perl 5 programming language system itself.
122              
123             =cut