File Coverage

blib/lib/Dist/Zilla/Role/FileMunger.pm
Criterion Covered Total %
statement 18 18 100.0
branch 3 4 75.0
condition n/a
subroutine 4 4 100.0
pod 0 1 0.0
total 25 27 92.5


line stmt bran cond sub pod time code
1             package Dist::Zilla::Role::FileMunger 6.030;
2             # ABSTRACT: something that alters a file's destination or content
3              
4 15     15   18041 use Moose::Role;
  15         44  
  15         134  
5             with 'Dist::Zilla::Role::Plugin';
6              
7 15     15   81529 use Dist::Zilla::Pragmas;
  15         40  
  15         114  
8              
9 15     15   122 use namespace::autoclean;
  15         58  
  15         141  
10              
11             #pod =head1 DESCRIPTION
12             #pod
13             #pod A FileMunger has an opportunity to mess around with each file that will be
14             #pod included in the distribution. Each FileMunger's C<munge_files> method is
15             #pod called once. By default, this method will just call the C<munge_file> method
16             #pod (note the missing terminal 's') once for each file, excluding files with an
17             #pod encoding attribute of 'bytes'.
18             #pod
19             #pod The C<munge_file> method is expected to change attributes about the file before
20             #pod it is written out to the built distribution.
21             #pod
22             #pod If you want to modify all files (including ones with an encoding of 'bytes') or
23             #pod want to select a more limited set of files, you can provide your own
24             #pod C<munge_files> method.
25             #pod
26             #pod =cut
27              
28             sub munge_files {
29 11     11 0 3636 my ($self) = @_;
30              
31 11 50       93 $self->log_fatal("no munge_file behavior implemented!")
32             unless $self->can('munge_file');
33              
34 11         33 my @files = @{ $self->zilla->files };
  11         442  
35 11         57 for my $file ( @files ) {
36 99 100       364 if ($file->is_bytes) {
37 9         56 $self->log_debug($file->name . " has 'bytes' encoding, skipping...");
38 9         776 next;
39             }
40              
41 90         296 $self->munge_file($file);
42             }
43             }
44              
45             1;
46              
47             __END__
48              
49             =pod
50              
51             =encoding UTF-8
52              
53             =head1 NAME
54              
55             Dist::Zilla::Role::FileMunger - something that alters a file's destination or content
56              
57             =head1 VERSION
58              
59             version 6.030
60              
61             =head1 DESCRIPTION
62              
63             A FileMunger has an opportunity to mess around with each file that will be
64             included in the distribution. Each FileMunger's C<munge_files> method is
65             called once. By default, this method will just call the C<munge_file> method
66             (note the missing terminal 's') once for each file, excluding files with an
67             encoding attribute of 'bytes'.
68              
69             The C<munge_file> method is expected to change attributes about the file before
70             it is written out to the built distribution.
71              
72             If you want to modify all files (including ones with an encoding of 'bytes') or
73             want to select a more limited set of files, you can provide your own
74             C<munge_files> method.
75              
76             =head1 PERL VERSION
77              
78             This module should work on any version of perl still receiving updates from
79             the Perl 5 Porters. This means it should work on any version of perl released
80             in the last two to three years. (That is, if the most recently released
81             version is v5.40, then this module should work on both v5.40 and v5.38.)
82              
83             Although it may work on older versions of perl, no guarantee is made that the
84             minimum required version will not be increased. The version may be increased
85             for any reason, and there is no promise that patches will be accepted to lower
86             the minimum required perl.
87              
88             =head1 AUTHOR
89              
90             Ricardo SIGNES 😏 <cpan@semiotic.systems>
91              
92             =head1 COPYRIGHT AND LICENSE
93              
94             This software is copyright (c) 2023 by Ricardo SIGNES.
95              
96             This is free software; you can redistribute it and/or modify it under
97             the same terms as the Perl 5 programming language system itself.
98              
99             =cut