| 1 | package Dist::Zilla::Role::FileInjector 6.040; | ||
| 2 | # ABSTRACT: something that can add files to the distribution | ||
| 3 | |||
| 4 | 47 | ▶ | use Moose::Role; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 47 | ▶ | use Dist::Zilla::Pragmas; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 47 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | #pod =head1 DESCRIPTION | ||
| 11 | #pod | ||
| 12 | #pod This role should be implemented by any plugin that plans to add files into the | ||
| 13 | #pod distribution. It provides one method (C<L</add_file>>, documented below), | ||
| 14 | #pod which adds a file to the distribution, noting the place of addition. | ||
| 15 | #pod | ||
| 16 | #pod =method add_file | ||
| 17 | #pod | ||
| 18 | #pod $plugin->add_file($dzil_file); | ||
| 19 | #pod | ||
| 20 | #pod This adds a file to the distribution, setting the file's C<added_by> attribute | ||
| 21 | #pod as it does so. | ||
| 22 | #pod | ||
| 23 | #pod =cut | ||
| 24 | |||
| 25 | 803 | ▶ | sub add_file { |
|
Subroutine
add_file: called CC=1 SCAR=0.0
Pod
documented
| |||
| 26 | 803 | my ($self, $file) = @_; | |
| 27 | 803 | my ($pkg, undef, $line) = caller; | |
| 28 | |||
| 29 | 803 | $file->_set_added_by( | |
| 30 | sprintf("%s (%s line %s)", $self->plugin_name, $pkg, $line), | ||
| 31 | ); | ||
| 32 | |||
| 33 | 803 | $self->log_debug([ 'adding file %s', $file->name ]); | |
| 34 | 803 | push @{ $self->zilla->files }, $file; | |
| 35 | } | ||
| 36 | |||
| 37 | 47 | 1; | |
| 38 | |||
| 39 | __END__ | ||