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   4633 use Object::Remote::ModuleSender;
  12         18  
  12         286  
4 12     12   81 use Object::Remote::Handle;
  12         15  
  12         180  
5 12     12   4783 use String::ShellQuote;
  12         7129  
  12         645  
6 12     12   53 use Moo;
  12         169  
  12         54  
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   287 my ($self) = @_;
20 1         3 my $perl_command = $self->perl_command;
21              
22             return [
23 1 50       5 do { my $c = $self->ssh_command; ref($c) ? @$c : $c },
  1         3  
24 1         1 @{$self->ssh_options}, $self->ssh_to,
  1         8  
25             shell_quote(@$perl_command),
26             ];
27             }
28              
29 1     1 0 6 sub final_perl_command { shift->ssh_perl_command }
30              
31 12     12   3816 no warnings 'once';
  12         14  
  12         6576  
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;