| 1 | package App::RemoteCommand::Select; | ||||||||||||||||||||
| 2 | 1 | ▶ | use v5.24; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 1 | ▶ | use experimental qw(lexical_subs signatures); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 1 | ▶ | use IO::Select; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 1 | ▶ | use App::RemoteCommand::LineBuffer; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | |||||||||||||||||||||
| 9 | 0 | ▶ | sub new ($class) { | ||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 10 | 0 | bless { select => IO::Select->new, container => [] }, $class; | |||||||||||||||||||
| 11 | } | ||||||||||||||||||||
| 12 | |||||||||||||||||||||
| 13 | 0 | ▶ | sub add ($self, %args) { | ||||||||||||||||||
|
Subroutine
add: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||
| 14 | 0 | my $pid = $args{pid}; | |||||||||||||||||||
| 15 | 0 | my $fh = $args{fh}; | |||||||||||||||||||
| 16 | 0 | my $host = $args{host}; | |||||||||||||||||||
| 17 | 0 | ▶ | my $buffer = $args{buffer} || App::RemoteCommand::LineBuffer->new; | ||||||||||||||||||
|
Condition0%0/3
$args{'buffer'} || 'App::RemoteCommand::LineBuffer'->new
MC/DC0%0/2
$args{'buffer'} || 'App::RemoteCommand::LineBuffer'->new
$args{'buffer'}
'App::RemoteCommand::LineBuffer'->new
Truth table0%0/3
A || B
A= $args{'buffer'}B= 'App::RemoteCommand::LineBuffer'->new
| |||||||||||||||||||||
| 18 | push $self->{container}->@*, { | ||||||||||||||||||||
| 19 | 0 | pid => $pid, | |||||||||||||||||||
| 20 | fh => $fh, | ||||||||||||||||||||
| 21 | host => $host, | ||||||||||||||||||||
| 22 | buffer => $buffer, | ||||||||||||||||||||
| 23 | }; | ||||||||||||||||||||
| 24 | 0 | $self->{select}->add($fh); | |||||||||||||||||||
| 25 | } | ||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 0 | ▶ | sub can_read ($self, @args) { | ||||||||||||||||||
|
Subroutine
can_read: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 28 | 0 | my @fh = $self->{select}->can_read(@args); | |||||||||||||||||||
| 29 | 0 | my @ready; | |||||||||||||||||||
| 30 | 0 | for my $c ($self->{container}->@*) { | |||||||||||||||||||
| 31 | 0 | ▶ | if (grep { $c->{fh} == $_ } @fh) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 32 | 0 | push @ready, $c; | |||||||||||||||||||
| 33 | } | ||||||||||||||||||||
| 34 | } | ||||||||||||||||||||
| 35 | 0 | return @ready; | |||||||||||||||||||
| 36 | } | ||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | 0 | ▶ | sub count ($self) { | ||||||||||||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 39 | 0 | $self->{select}->count; | |||||||||||||||||||
| 40 | } | ||||||||||||||||||||
| 41 | |||||||||||||||||||||
| 42 | 0 | ▶ | sub remove ($self, $kind, $value) { | ||||||||||||||||||
|
Subroutine
remove: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||
| 43 | 0 | for my $i (0..$self->{container}->$#*) { | |||||||||||||||||||
| 44 | 0 | ▶ | if ($self->{container}[$i]{$kind} eq $value) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 45 | 0 | my $remove = splice $self->{container}->@*, $i, 1; | |||||||||||||||||||
| 46 | 0 | $self->{select}->remove($remove->{fh}); | |||||||||||||||||||
| 47 | 0 | return $remove; | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | } | ||||||||||||||||||||
| 50 | 0 | return; | |||||||||||||||||||
| 51 | } | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | 1 | 1; | |||||||||||||||||||