NAME
Tangerine::Hook - A simple hook class
SYNOPSIS
package MyHook;
use parent 'Tangerine::Hook';
use Tangerine::HookData;
use Tangerine::Occurence;
sub run {
my ($self, $s) = @_;
if ($s->[0] eq 'use' && $self->type eq 'compile' &&
$s->[1] && $s->[1] eq 'MyModule') {
return Tangerine::HookData->new(
modules => { MyModule => Tangerine::Occurence->new },
)
}
return
}
DESCRIPTION
Hooks are the workhorses of Tangerine, examining the actual code and returning Tangerine::HookData where applicable.
Every hook has a type, which can be one of 'package', 'compile' or 'runtime', set by the caller and determining what she is interested in.
Every hook should implement the run
method which is passed an array reference containing the significant children (see PPI::Statement) of the currently parsed Perl statement.
The caller expects a Tangerine::HookData instance defining what modules
of the requested type
we found, what hooks
the caller should register or what children
shall be examined next. Either or all these may be returned at once.
METHODS
type
-
Returns or sets the hook type. May be one of
package
,compile
orruntime
. run
-
This is called by Tangerine with an array reference containing the significant children of the currently parsed Perl statement. Returns a Tangerine::HookData instance.
Every hook needs to implement this method.
SEE ALSO
Tangerine
, PPI::Statement
, Tangerine::HookData
AUTHOR
Petr Šabata <contyk@redhat.com>
COPYRIGHT AND LICENSE
Copyright (c) 2014-2016 Petr Šabata
See LICENSE for licensing details.