Dist::Zilla::Role::Hooker - Run Perl code written in your plugin's dist.ini section
Version v0.8.4, released on 2018-03-15 21:44 UTC.
Dist-Zilla-Plugin-Hook (or just Hook) is a set of Dist-Zilla plugins. Every plugin executes Perl code inlined into dist.ini at particular stage of build process.
Dist-Zilla-Plugin-Hook
Hook
Dist-Zilla
This is Hooker role documentation. Read this if you are going to hack or extend Dist-Zilla-Plugin-Hook, or use the role in your plugin.
Hooker
If you want to write Dist::Zilla plugin directly in dist.ini, read the manual. General topics like getting source, building, installing, bug reporting and some others are covered in the README.
Dist::Zilla
Dist-Zilla-Plugin-Hook is a set of plugins: Hook::Init, Hook::BeforeBuild, Hook::GatherFiles, etc. All these plugins are just stubs, they contains almost no code. They just use services provided by the Hooker role. The role is an engine for all Hook plugins.
Hook::Init
Hook::BeforeBuild
Hook::GatherFiles
Perl code to execute, list of lines (without newline characters).
ArrayRef[Str], read-only. Default value is empty array (i. e. no code).
ArrayRef[Str]
Note: init_arg attribute property set to ".". In dist.ini file the Perl code should be specified using this notation:
init_arg
[Hook::Role] . = …Perl code…
$ret = $self->hook( @args ); @ret = $self->hook( @args ); $self->hook( @args );
This is the primary method of the role. The method executes Perl code specified in code attribute (prepended with _prologue) with string form of eval. The method passes arguments specified by the caller to the code, and passes the code return value back to the caller. Calling context (list, scalar, or void) is preserved. The method also hides all the lexical variables (except the variables documented below) from code. The method intercepts warnings generated in code and logs them; warnings do not stop executing.
code
_prologue
eval
Following lexical variables are exposed to the code intentionally:
@_
hook arguments, self-reference is already shifted!
hook
$arg
The same as $_[ 0 ].
$_[ 0 ]
$self
$plugin
Reference to the plugin object executing the code (such as Hook::Init or Hook::BeforeBuild).
$dist
$zilla
Reference to Dist::Zilla object, the same as $self->zilla.
$self->zilla
If code dies, the method logs error message and aborts Dist::Zilla.
$dir = $self->_line_directive( $filename, $linenumber ); $dir = $self->_line_directive( $filename );
The method returns Perl line directive, like
#line 1 "filename.ext"
The method takes care about quotes. Perl line directive does not allow any quotes (escaped or not) in filename, so directive
#line 1 "\"Assa\" project.txt"
will be ignored. To avoid this, line_directive replaces quotes in filename with apostrophes, e. g.:
line_directive
#line 1 "'Assa' project.txt"
If line number is not specified, 1 will be used.
@code = $self->_prologue;
The method returns prologue code.
Prologue code is extracted from Dist::Zilla plugin named prologue.
prologue
The method tells Dist::Zilla that dot (.) is a multi-value option.
.
Van de Bugger <van.de.bugger@gmail.com>
Copyright (C) 2015, 2016, 2018 Van de Bugger
License GPLv3+: The GNU General Public License version 3 or later <http://www.gnu.org/licenses/gpl-3.0.txt>.
This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
To install Dist::Zilla::Plugin::Hook, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Dist::Zilla::Plugin::Hook
CPAN shell
perl -MCPAN -e shell install Dist::Zilla::Plugin::Hook
For more information on module installation, please visit the detailed CPAN module installation guide.