BCSSH/Handler/scp.pm

filter: Statementstmt 30.3% 10 / 33 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 40.0% 2 / 5 Podpod 0.0% 0 / 1 totaltotal 21.4% 12 / 56 CC 10 SCAR 37.8
CC
10
Cov
21%
handle
72.0
__ANON__
12.0
__ANON__
2.0
CRAP 44.0
« BCSSH/Client.pm ↑ Summary BCSSH/Options.pm »
1 package App::BCSSH::Handler::scp;
2 1 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 my $have_pty;
4 0 ▶BEGIN { eval {require IO::Pty::Easy; $have_pty = 1} }
Subroutine BEGIN: called CC=1 SCAR=0.4
5  
6 1 with 'App::BCSSH::Handler';
7  
8 has destination => (
9 is => 'ro',
10 0 ▶ default => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
11 -d && return $_
12 0 ▶ for ("$ENV{HOME}/Desktop", "$ENV{HOME}/desktop", $ENV{HOME});
Branch: 1 branch
BranchTrueFalseTotal
-d $_ and return $_ 0 0 0
13 },
14 1 );
15 has scp => (
16 is => 'ro',
17 0 ▶ default => sub { 'scp' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
18 1 );
19  
20 0 ▶sub handle {
Subroutine handle: not called CC=8 SCAR=42.8
Pod undocumented
21 0 my ($self, $send, $args) = @_;
22 0 my $files = $args->{files};
23 0 for my $file (@$files) {
24 0 $file = $self->host.':'.$file;
25 }
26 0 my $socket = $send->();
27 0 ▶ fork and return;
Branch: 1 branch
BranchTrueFalseTotal
fork and return 0 0 0
28 0 ▶ my @scp = ref $self->scp ? @{ $self->scp } : $self->scp;
Branch: 1 branch
BranchTrueFalseTotal
ref $self->scp ? : 0 0 0
29 0 my @command = (@scp, '-r', '--', @$files, $self->destination);
30 0 ▶ if ($have_pty) {
Branch: 1 branch
BranchTrueFalseTotal
if ($have_pty) { } 0 0 0
31 0 my $pty = IO::Pty::Easy->new;
32 0 $pty->spawn(@command);
33  
34 0 ▶ while ($pty->is_active) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pty->is_active) 0 0 0
35 0 my $output = $pty->read;
36 0 ▶ last if defined($output) && $output eq '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $output and $output eq "" 0 0 0
Condition0%0/3
defined $output and $output eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $output and $output eq ""
defined $output $output eq ""
Truth table0%0/3
A and B
A= defined $outputB= $output eq ""
ABresult
0X0
100
111
37 0 $socket->syswrite($output);
38 }
39 0 $pty->close;
40 }
41 else {
42 0 system @command;
43 }
44 0 $socket->shutdown(2);
45 0 exit;
46 }
47  
48 1 1;
« BCSSH/Client.pm ↑ Summary BCSSH/Options.pm »