cleanup trailing whitespace ugliness
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / SSH.pm
CommitLineData
47c83a13 1package Object::Remote::Connector::SSH;
2
84b04178 3use Object::Remote::ModuleSender;
8ba4f2e3 4use Object::Remote::Handle;
8506bc08 5use String::ShellQuote;
47c83a13 6use Moo;
7
a9fdb55e 8with 'Object::Remote::Role::Connector::PerlInterpreter';
47c83a13 9
fbd3b8ec 10has ssh_to => (is => 'ro', required => 1);
11
498c4ad5 12has ssh_perl_command => (is => 'lazy');
13
6ec765ba 14has ssh_options => (is => 'ro', default => sub { [ '-A' ] });
15
16has ssh_command => (is => 'ro', default => sub { 'ssh' });
17
498c4ad5 18sub _build_ssh_perl_command {
19 my ($self) = @_;
55c0d020 20 my $perl_command = $self->perl_command;
8506bc08 21
6ec765ba 22 return [
23 do { my $c = $self->ssh_command; ref($c) ? @$c : $c },
24 @{$self->ssh_options}, $self->ssh_to,
8506bc08 25 shell_quote(@$perl_command),
6ec765ba 26 ];
498c4ad5 27}
28
29sub final_perl_command { shift->ssh_perl_command }
84b04178 30
7efea51f 31no warnings 'once';
32
55c0d020 33push @Object::Remote::Connection::Guess, sub {
84b04178 34 for ($_[0]) {
35 # 0-9 a-z _ - first char, those or . subsequent - hostnamish
a9fdb55e 36 if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) {
c824fdf3 37 my $host = shift(@_);
38 return __PACKAGE__->new(@_, ssh_to => $host);
84b04178 39 }
40 }
41 return;
42};
43
47c83a13 441;