File Coverage

blib/lib/Dist/Zilla/Plugin/Manifest.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition 1 2 50.0
subroutine 7 7 100.0
pod 0 1 0.0
total 36 38 94.7


line stmt bran cond sub pod time code
1             package Dist::Zilla::Plugin::Manifest 6.037;
2             # ABSTRACT: build a MANIFEST file
3              
4 13     13   9925 use Moose;
  13         34  
  13         122  
5             with 'Dist::Zilla::Role::FileGatherer';
6              
7 13     13   93073 use Dist::Zilla::Pragmas;
  13         30  
  13         120  
8              
9 13     13   91 use namespace::autoclean;
  13         28  
  13         136  
10              
11 13     13   6130 use Dist::Zilla::File::FromCode;
  13         183  
  13         6780  
12              
13             #pod =head1 DESCRIPTION
14             #pod
15             #pod If included, this plugin will produce a F<MANIFEST> file for the distribution,
16             #pod listing all of the files it contains. For obvious reasons, it should be
17             #pod included as close to last as possible.
18             #pod
19             #pod This plugin is included in the L<@Basic|Dist::Zilla::PluginBundle::Basic>
20             #pod bundle.
21             #pod
22             #pod =head1 SEE ALSO
23             #pod
24             #pod Dist::Zilla core plugins:
25             #pod L<@Basic|Dist::Zilla::PluginBundle::Manifest>,
26             #pod L<ManifestSkip|Dist::Zilla::Plugin::ManifestSkip>.
27             #pod
28             #pod Other modules: L<ExtUtils::Manifest>.
29             #pod
30             #pod =cut
31              
32             sub __fix_filename {
33 134     134   223 my ($name) = @_;
34 134 100       531 return $name unless $name =~ /[ '\\]/;
35 5         7 $name =~ s/\\/\\\\/g;
36 5         24 $name =~ s/'/\\'/g;
37 5         11 return qq{'$name'};
38             }
39              
40             sub gather_files {
41 12     12 0 45 my ($self, $arg) = @_;
42              
43 12         396 my $zilla = $self->zilla;
44              
45             my $file = Dist::Zilla::File::FromCode->new({
46             name => 'MANIFEST',
47             code_return_type => 'bytes',
48             code => sub {
49 12   50 12   187 my $generated_by = sprintf "%s v%s", ref($self), $self->VERSION || '(dev)';
50              
51             return "# This file was automatically generated by $generated_by\n"
52 12         51 . join("\n", map { __fix_filename($_) } sort map { $_->name } @{ $zilla->files })
  134         275  
  134         401  
  12         452  
53             . "\n",
54             },
55 12         571 });
56              
57 12         79 $self->add_file($file);
58             }
59              
60             __PACKAGE__->meta->make_immutable;
61             1;
62              
63             __END__
64              
65             =pod
66              
67             =encoding UTF-8
68              
69             =head1 NAME
70              
71             Dist::Zilla::Plugin::Manifest - build a MANIFEST file
72              
73             =head1 VERSION
74              
75             version 6.037
76              
77             =head1 DESCRIPTION
78              
79             If included, this plugin will produce a F<MANIFEST> file for the distribution,
80             listing all of the files it contains. For obvious reasons, it should be
81             included as close to last as possible.
82              
83             This plugin is included in the L<@Basic|Dist::Zilla::PluginBundle::Basic>
84             bundle.
85              
86             =head1 PERL VERSION
87              
88             This module should work on any version of perl still receiving updates from
89             the Perl 5 Porters. This means it should work on any version of perl
90             released in the last two to three years. (That is, if the most recently
91             released version is v5.40, then this module should work on both v5.40 and
92             v5.38.)
93              
94             Although it may work on older versions of perl, no guarantee is made that the
95             minimum required version will not be increased. The version may be increased
96             for any reason, and there is no promise that patches will be accepted to
97             lower the minimum required perl.
98              
99             =head1 SEE ALSO
100              
101             Dist::Zilla core plugins:
102             L<@Basic|Dist::Zilla::PluginBundle::Manifest>,
103             L<ManifestSkip|Dist::Zilla::Plugin::ManifestSkip>.
104              
105             Other modules: L<ExtUtils::Manifest>.
106              
107             =head1 AUTHOR
108              
109             Ricardo SIGNES 😏 <cpan@semiotic.systems>
110              
111             =head1 COPYRIGHT AND LICENSE
112              
113             This software is copyright (c) 2026 by Ricardo SIGNES.
114              
115             This is free software; you can redistribute it and/or modify it under
116             the same terms as the Perl 5 programming language system itself.
117              
118             =cut