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