- OBJECT ATTRIBUTES
- OBJECT METHODS
- SEE ALSO
- COPYRIGHT AND LICENSE
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.
Hooker role documentation. Read this if you are going to hack or extend
Dist-Zilla-Plugin-Hook, or use the role in your plugin.
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-Plugin-Hook is a set of plugins:
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
Perl code to execute, list of lines (without newline characters).
ArrayRef[Str], read-only. Default value is empty array (i. e. no code).
init_arg attribute property set to ".". In dist.ini file the Perl code should be specified using this notation:
[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.
Following lexical variables are exposed to the code intentionally:
hookarguments, self-reference is already shifted!
The same as
$_[ 0 ].
Reference to the plugin object executing the code (such as
Dist::Zillaobject, the same as
If code dies, the method logs error message and aborts
$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 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
The method tells
Dist::Zilla that dot (
.) is a multi-value option.
Van de Bugger <firstname.lastname@example.org>
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.