NAME
Dist::Zilla::Role::Hooker - Run Perl code written in your plugin's dist.ini section
VERSION
Version 0.003, released on 2015-07-25 21:49 UTC.
WHAT?
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.
This is Dist::Zilla::Role::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.
DESCRIPTION
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.
OBJECT ATTRIBUTES
code
Perl code to execute, list of lines (without newline characters).
ArrayRef[Str], read-only. Default value is empty array (i. e. no code).
Note: init_arg
attribute property set to ".". In dist.ini file the Perl code should be specified using this notation:
[Hook::Phase]
. = …Perl code…
OBJECT METHODS
hook
$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 with string 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, but warnings do not stop executing.
Following lexical variables are exposed to the code intentionally:
$self
$plugin
-
Reference to the plugin object executing the code (such as
Hook::Init
orHook::BeforeBuild
). $zilla
$dist
-
Reference to
Dist::Zilla
object, the same as$self->zilla
. $arg
-
The same as
$_[ 0 ]
. @_
-
hook
arguments, self-reference is already shifted!
If code dies, the method logs error message and aborts Dist::Zilla
.
prologue
my @code = $self->prologue;
The method returns prologue code.
Prologue code is extracted from Dist::Zilla
plugin named prologue
.
mvp_multivalue_args
The method tells Dist::Zilla
that dot (.
) is a multi-value option.
SEE ALSO
- Dist::Zilla
- Dist::Zilla::Role
- Dist::Zilla::Role::Plugin
- Dist::Zilla::Plugin::Hook::Manual
- Dist::Zilla::Plugin::Hook::ReadMe
AUTHOR
Van de Bugger <van.de.bugger@gmail.com>
COPYRIGHT AND LICENSE
Copyright © 2015 Van de Bugger
This file is part of perl-Dist-Zilla-Plugin-Hook.
perl-Dist-Zilla-Plugin-Hook is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
perl-Dist-Zilla-Plugin-Hook is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with perl-Dist-Zilla-Plugin-Hook. If not, see <http://www.gnu.org/licenses/>.