| 1 | package App::VTide::Hooks; | ||||||||||||||||||||||
| 2 | |||||||||||||||||||||||
| 3 | # Created on: 2016-04-07 16:42:42 | ||||||||||||||||||||||
| 4 | # Create by: Ivan Wills | ||||||||||||||||||||||
| 5 | # $Id$ | ||||||||||||||||||||||
| 6 | # $Revision$, $HeadURL$, $Date$ | ||||||||||||||||||||||
| 7 | # $Revision$, $Source$, $Date$ | ||||||||||||||||||||||
| 8 | |||||||||||||||||||||||
| 9 | 6 | ▶ | use Moo; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 10 | 6 | ▶ | use warnings; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 6 | ▶ | use version; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | 6 | ▶ | use Carp; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 13 | 6 | ▶ | use Data::Dumper qw/Dumper/; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 14 | 6 | ▶ | use English qw/ -no_match_vars /; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 15 | 6 | ▶ | use Path::Tiny; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 16 | |||||||||||||||||||||||
| 17 | 6 | our $VERSION = version->new('1.0.6'); | |||||||||||||||||||||
| 18 | |||||||||||||||||||||||
| 19 | 6 | has hook_cmds => ( | |||||||||||||||||||||
| 20 | is => 'rw', | ||||||||||||||||||||||
| 21 | lazy => 1, | ||||||||||||||||||||||
| 22 | builder => '_hook_cmds', | ||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||
| 24 | 6 | has vtide => ( | |||||||||||||||||||||
| 25 | is => 'rw', | ||||||||||||||||||||||
| 26 | required => 1, | ||||||||||||||||||||||
| 27 | handles => [qw/ config hooks /], | ||||||||||||||||||||||
| 28 | ); | ||||||||||||||||||||||
| 29 | |||||||||||||||||||||||
| 30 | 2 | ▶ | sub run { | ||||||||||||||||||||
|
Subroutine
run: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||
| 31 | 2 | my ($self, $hook, @args) = @_; | |||||||||||||||||||||
| 32 | |||||||||||||||||||||||
| 33 | 2 | ▶ | if ( $self->hook_cmds->{$hook} ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 34 | 1 | $self->hook_cmds->{$hook}->($self, @args); | |||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 2 | return; | |||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||
| 39 | |||||||||||||||||||||||
| 40 | 2 | ▶ | sub _hook_cmds { | ||||||||||||||||||||
|
Subroutine
_hook_cmds: called CC=5 SCAR=16.1
| |||||||||||||||||||||||
| 41 | 2 | my ($self) = @_; | |||||||||||||||||||||
| 42 | 2 | my $hooks = {}; | |||||||||||||||||||||
| 43 | 2 | my $global = path( $self->config->global_config )->parent->path('hooks.pl')->absolute; | |||||||||||||||||||||
| 44 | 2 | my $local = path( $self->config->local_config )->parent->path('.vtide', 'hooks.pl')->absolute; | |||||||||||||||||||||
| 45 | |||||||||||||||||||||||
| 46 | 2 | ▶ | if ( -f $global ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 47 | 1 | $hooks = do $global; | |||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||
| 49 | 2 | ▶ | if ( -f $local ) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 50 | 1 | my $done = do $local; | |||||||||||||||||||||
| 51 | 1 | ▶ | $hooks = { %{ $hooks || {} }, %{ $done || {} } }; | ||||||||||||||||||||
|
Condition50%2/4
$hooks || {}
$done || {}
MC/DC0%0/1
$hooks || {}
$hooks
MC/DC0%0/1
$done || {}
$done
Truth table50%1/2
A
A= $hooks
Truth table50%1/2
A
A= $done
| |||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||
| 53 | |||||||||||||||||||||||
| 54 | 2 | return $hooks; | |||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||
| 56 | |||||||||||||||||||||||
| 57 | 6 | 1; | |||||||||||||||||||||
| 58 | |||||||||||||||||||||||
| 59 | __END__ | ||||||||||||||||||||||