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.030;
2             # ABSTRACT: build a MANIFEST file
3              
4 13     13   9386 use Moose;
  13         49  
  13         117  
5             with 'Dist::Zilla::Role::FileGatherer';
6              
7 13     13   94407 use Dist::Zilla::Pragmas;
  13         46  
  13         122  
8              
9 13     13   111 use namespace::autoclean;
  13         38  
  13         137  
10              
11 13     13   5497 use Dist::Zilla::File::FromCode;
  13         47  
  13         5804  
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   215 my ($name) = @_;
34 134 100       471 return $name unless $name =~ /[ '\\]/;
35 5         18 $name =~ s/\\/\\\\/g;
36 5         14 $name =~ s/'/\\'/g;
37 5         14 return qq{'$name'};
38             }
39              
40             sub gather_files {
41 12     12 0 52 my ($self, $arg) = @_;
42              
43 12         1070 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   209 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         76 . join("\n", map { __fix_filename($_) } sort map { $_->name } @{ $zilla->files })
  134         273  
  134         400  
  12         373  
53             . "\n",
54             },
55 12         561 });
56              
57 12         87 $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.030
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 released
90             in the last two to three years. (That is, if the most recently released
91             version is v5.40, then this module should work on both v5.40 and v5.38.)
92              
93             Although it may work on older versions of perl, no guarantee is made that the
94             minimum required version will not be increased. The version may be increased
95             for any reason, and there is no promise that patches will be accepted to lower
96             the minimum required perl.
97              
98             =head1 SEE ALSO
99              
100             Dist::Zilla core plugins:
101             L<@Basic|Dist::Zilla::PluginBundle::Manifest>,
102             L<ManifestSkip|Dist::Zilla::Plugin::ManifestSkip>.
103              
104             Other modules: L<ExtUtils::Manifest>.
105              
106             =head1 AUTHOR
107              
108             Ricardo SIGNES 😏 <cpan@semiotic.systems>
109              
110             =head1 COPYRIGHT AND LICENSE
111              
112             This software is copyright (c) 2023 by Ricardo SIGNES.
113              
114             This is free software; you can redistribute it and/or modify it under
115             the same terms as the Perl 5 programming language system itself.
116              
117             =cut