Dist::Zilla::Role::RepoFileInjector - Create files outside the build directory
version 0.009
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; }
This role is to be consumed by any plugin that plans to create files outside the distribution.
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.
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.
$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.
repo_root
FileGatherer
$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.:
add_repo_file
AfterBuild
AfterRelease
sub after_build { my $self = shift; $self->write_repo_files; }
Returns the list of files added via add_repo_file. Normally the consuming plugin would call this in the FileMunger phase.
FileMunger
Dist::Zilla::Role::FileInjector
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.
#distzilla
irc.perl.org
I am also usually active on irc, as 'ether' at irc.perl.org.
Karen Etheridge <ether@cpan.org>
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.
To install Dist::Zilla::Role::RepoFileInjector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dist::Zilla::Role::RepoFileInjector
CPAN shell
perl -MCPAN -e shell install Dist::Zilla::Role::RepoFileInjector
For more information on module installation, please visit the detailed CPAN module installation guide.