| 1 | package Dist::Zilla::Role::FileMunger 6.040; | ||||||||||
| 2 | # ABSTRACT: something that alters a file's destination or content | ||||||||||
| 3 | |||||||||||
| 4 | 15 | ▶ | use Moose::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 15 | with 'Dist::Zilla::Role::Plugin'; | |||||||||
| 6 | |||||||||||
| 7 | 15 | ▶ | use Dist::Zilla::Pragmas; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 15 | ▶ | use namespace::autoclean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 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 | 11 | ▶ | sub munge_files { | ||||||||
|
Subroutine
munge_files: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||
| 29 | 11 | my ($self) = @_; | |||||||||
| 30 | |||||||||||
| 31 | 11 | ▶ | $self->log_fatal("no munge_file behavior implemented!") | ||||||||
|
Branch: 1 branch
| |||||||||||
| 32 | unless $self->can('munge_file'); | ||||||||||
| 33 | |||||||||||
| 34 | 11 | my @files = @{ $self->zilla->files }; | |||||||||
| 35 | 11 | for my $file ( @files ) { | |||||||||
| 36 | 99 | ▶ | if ($file->is_bytes) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 37 | 9 | $self->log_debug($file->name . " has 'bytes' encoding, skipping..."); | |||||||||
| 38 | 9 | next; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 90 | $self->munge_file($file); | |||||||||
| 42 | } | ||||||||||
| 43 | } | ||||||||||
| 44 | |||||||||||
| 45 | 15 | 1; | |||||||||
| 46 | |||||||||||
| 47 | __END__ | ||||||||||