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