The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Dist::Zilla::Role::RepoFileInjector - Create files outside the build directory

VERSION

version 0.009

SYNOPSIS

In your dist.ini:

[MyPlugin]

And in your plugin:

package Dist::Zilla::Plugin::MyPlugin;
use Moose;
with 'Dist::Zilla::Role::RepoFileInjector';

sub some_method {
    ...
    $self->add_repo_file(Dist::Zilla::File::InMemory->new(...));
}

sub some_other_method {
    ...
    $self->write_repo_files;
}

DESCRIPTION

This role is to be consumed by any plugin that plans to create files outside the distribution.

ATTRIBUTES

repo_root

A string indicating the base directory where the file(s) are written, when relative paths are provided. Defaults to "root" in Dist::Zilla.

This attribute is available as an option of your plugin in dist.ini.

allow_overwrite

A boolean indicating whether it is permissible for the file to already exist (whereupon it is overwritten). When false, a fatal exception is thrown when the file already exists.

Defaults to true.

This attribute is available as an option of your plugin in dist.ini.

METHODS

add_repo_file

$plugin->add_repo_file($dzil_file);

Registers a file object to be written to disk. If the path is not absolute, it is treated as relative to repo_root. The file should consume the Dist::Zilla::Role::File role. Normally the consuming plugin would call this in the FileGatherer phase.

write_repo_files

$plugin->write_repo_files;

Writes out all files registered previously with add_repo_file. Your plugin should normally do this during either the AfterBuild or AfterRelease phase, e.g.:

sub after_build
{
    my $self = shift;
    $self->write_repo_files;
}

_repo_files

Returns the list of files added via add_repo_file. Normally the consuming plugin would call this in the FileMunger phase.

SEE ALSO

SUPPORT

Bugs may be submitted through the RT bug tracker (or bug-Dist-Zilla-Role-RepoFileInjector@rt.cpan.org).

There is also a mailing list available for users of this distribution, at http://dzil.org/#mailing-list.

There is also an irc channel available for users of this distribution, at #distzilla on irc.perl.org.

I am also usually active on irc, as 'ether' at irc.perl.org.

AUTHOR

Karen Etheridge <ether@cpan.org>

COPYRIGHT AND LICENCE

This software is copyright (c) 2015 by Karen Etheridge.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.