Tangerine::Hook - A simple hook class
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 }
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.
run
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.
modules
type
hooks
children
Returns or sets the hook type. May be one of package, compile or runtime.
package
compile
runtime
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.
Tangerine, PPI::Statement, Tangerine::HookData
Tangerine
PPI::Statement
Tangerine::HookData
Petr Šabata <contyk@redhat.com>
Copyright (c) 2014-2016 Petr Šabata
See LICENSE for licensing details.
To install Tangerine, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tangerine
CPAN shell
perl -MCPAN -e shell install Tangerine
For more information on module installation, please visit the detailed CPAN module installation guide.