File Coverage

blib/lib/Object/Remote/Connector/SSH.pm
Criterion Covered Total %
statement 22 22 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 30 32 93.7


line stmt bran cond sub pod time code
1             package Object::Remote::Connector::SSH;
2              
3 12     12   5009 use Object::Remote::ModuleSender;
  12         28  
  12         318  
4 12     12   54 use Object::Remote::Handle;
  12         21  
  12         232  
5 12     12   4736 use String::ShellQuote;
  12         8672  
  12         585  
6 12     12   70 use Moo;
  12         23  
  12         53  
7              
8             with 'Object::Remote::Role::Connector::PerlInterpreter';
9              
10             has ssh_to => (is => 'ro', required => 1);
11              
12             has ssh_perl_command => (is => 'lazy');
13              
14             has ssh_options => (is => 'ro', default => sub { [ '-A' ] });
15              
16             has ssh_command => (is => 'ro', default => sub { 'ssh' });
17              
18             sub _build_ssh_perl_command {
19 1     1   10 my ($self) = @_;
20 1         14 my $perl_command = $self->perl_command;
21              
22             return [
23 1 50       4 do { my $c = $self->ssh_command; ref($c) ? @$c : $c },
  1         4  
24 1         2 @{$self->ssh_options}, $self->ssh_to,
  1         5  
25             shell_quote(@$perl_command),
26             ];
27             }
28              
29 1     1 0 23 sub final_perl_command { shift->ssh_perl_command }
30              
31 12     12   4933 no warnings 'once';
  12         24  
  12         2674  
32              
33             push @Object::Remote::Connection::Guess, sub {
34             for ($_[0]) {
35             # 0-9 a-z _ - first char, those or . subsequent - hostnamish
36             if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) {
37             my $host = shift(@_);
38             return __PACKAGE__->new(@_, ssh_to => $host);
39             }
40             }
41             return;
42             };
43              
44             1;