| 1 | package Linux::Event::Kernel::Inotify::Watch; | ||||||||||||||||||||
| 2 | 9 | ▶ | use v5.36; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 9 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 9 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 9 | our $VERSION = '0.119'; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 9 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 24 | ▶ | sub _new ($class, $parent, $id, $path, $event_mask, $callback, $flag) { | ||||||||||||||||||
|
Subroutine
_new: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 24 | my $self = bless { | |||||||||||||||||||
| 12 | parent => $parent, | ||||||||||||||||||||
| 13 | id => $id, | ||||||||||||||||||||
| 14 | path => $path, | ||||||||||||||||||||
| 15 | event_mask => $event_mask, | ||||||||||||||||||||
| 16 | callbacks => $callback, | ||||||||||||||||||||
| 17 | flags => $flag, | ||||||||||||||||||||
| 18 | wd => undef, | ||||||||||||||||||||
| 19 | state => 'pending', | ||||||||||||||||||||
| 20 | }, $class; | ||||||||||||||||||||
| 21 | 24 | weaken($self->{parent}); | |||||||||||||||||||
| 22 | 24 | return $self; | |||||||||||||||||||
| 23 | } | ||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | 9 | ▶ | sub cancel ($self) { | ||||||||||||||||||
|
Subroutine
cancel: called CC=3 SCAR=13.3
Pod
documented
| |||||||||||||||||||||
| 26 | 9 | ▶ | return $self if $self->is_terminal; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 27 | 9 | my $parent = $self->{parent}; | |||||||||||||||||||
| 28 | 9 | ▶ | return $parent->_cancel_watch($self) if $parent; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 29 | 0 | $self->_terminate('cancelled'); | |||||||||||||||||||
| 30 | 0 | return $self; | |||||||||||||||||||
| 31 | } | ||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | 375 | ▶ | sub path ($self) { $self->{path} } | ||||||||||||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 34 | 0 | ▶ | sub inotify ($self) { $self->{parent} } | ||||||||||||||||||
|
Subroutine
inotify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 35 | 6 | ▶ | sub state ($self) { $self->{state} } | ||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 36 | 5183 | ▶ | sub is_active ($self) { $self->{state} eq 'active' } | ||||||||||||||||||
|
Subroutine
is_active: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||
| 37 | 36 | ▶ | sub is_terminal ($self) { | ||||||||||||||||||
|
Subroutine
is_terminal: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||
| 38 | 36 | ▶ | return $self->{state} ne 'pending' && $self->{state} ne 'active'; | ||||||||||||||||||
|
Condition100%3/3
$self->{'state'} ne 'pending' && $self->{'state'} ne 'active'
MC/DC100%2/2
$self->{'state'} ne 'pending' && $self->{'state'} ne 'active'
$self->{'state'} ne 'pending'
$self->{'state'} ne 'active'
Truth table100%3/3
A && B
A= $self->{'state'} ne 'pending'B= $self->{'state'} ne 'active'
| |||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 33 | ▶ | sub _id ($self) { $self->{id} } | ||||||||||||||||||
|
Subroutine
_id: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 42 | 346 | ▶ | sub _wd ($self) { $self->{wd} } | ||||||||||||||||||
|
Subroutine
_wd: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 43 | 373 | ▶ | sub _event_mask ($self) { $self->{event_mask} } | ||||||||||||||||||
|
Subroutine
_event_mask: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 44 | 661 | ▶ | sub _callback ($self, $name) { $self->{callbacks}{$name} } | ||||||||||||||||||
|
Subroutine
_callback: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 45 | 124 | ▶ | sub _flag ($self, $name) { $self->{flags}{$name} ? 1 : 0 } | ||||||||||||||||||
|
Subroutine
_flag: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 21 | ▶ | sub _activate ($self, $wd) { | ||||||||||||||||||
|
Subroutine
_activate: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 48 | 21 | $self->{wd} = $wd; | |||||||||||||||||||
| 49 | 21 | $self->{state} = 'active'; | |||||||||||||||||||
| 50 | 21 | return $self; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 0 | ▶ | sub _reset_pending ($self) { | ||||||||||||||||||
|
Subroutine
_reset_pending: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 54 | 0 | $self->{wd} = undef; | |||||||||||||||||||
| 55 | 0 | $self->{state} = 'pending'; | |||||||||||||||||||
| 56 | 0 | return $self; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 24 | ▶ | sub _terminate ($self, $state) { | ||||||||||||||||||
|
Subroutine
_terminate: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 60 | 24 | $self->{wd} = undef; | |||||||||||||||||||
| 61 | 24 | $self->{state} = $state; | |||||||||||||||||||
| 62 | 24 | $self->{callbacks} = {}; | |||||||||||||||||||
| 63 | 24 | return $self; | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | 9 | 1; | |||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | __END__ | ||||||||||||||||||||