Dist::Zilla::Role::FileInjector - something that can add files to the distribution


Dist-Zilla documentation Contained in the Dist-Zilla distribution.

Index


Code Index:

NAME

Top

Dist::Zilla::Role::FileInjector - something that can add files to the distribution

VERSION

Top

version 4.200008

DESCRIPTION

Top

This role should be implemented by any plugin that plans to add files into the distribution. It provides one method (add_file, documented below), which adds a file to the distribution, noting the place of addition.

METHODS

Top

add_file

  $plugin->add_file($dzil_file);

This adds a file to the distribution, setting the file's added_by attribute as it does so.

AUTHOR

Top

Ricardo SIGNES <rjbs@cpan.org>

COPYRIGHT AND LICENSE

Top


Dist-Zilla documentation Contained in the Dist-Zilla distribution.

package Dist::Zilla::Role::FileInjector;
BEGIN {
  $Dist::Zilla::Role::FileInjector::VERSION = '4.200008';
}
# ABSTRACT: something that can add files to the distribution
use Moose::Role;

use Moose::Autobox;


sub add_file {
  my ($self, $file) = @_;
  my ($pkg, undef, $line) = caller;

  $file->meta->get_attribute('added_by')->set_value(
    $file,
    sprintf("%s (%s line %s)", $self->plugin_name, $pkg, $line),
  );

  $self->log_debug([ 'adding file %s', $file->name ]);
  $self->zilla->files->push($file);
}

no Moose::Role;
1;

__END__