parallelise connection setup
[scpubgit/Object-Remote.git] / lib / Object / Remote / Connector / SSH.pm
1 package Object::Remote::Connector::SSH;
2
3 use Object::Remote::ModuleSender;
4 use Object::Remote::Handle;
5 use Moo;
6
7 with 'Object::Remote::Role::Connector::PerlInterpreter';
8
9 has ssh_to => (is => 'ro', required => 1);
10
11 around _perl_command => sub {
12   my ($orig, $self) = @_;
13   return 'ssh', '-A', $self->ssh_to, $self->$orig;
14 };
15
16 no warnings 'once';
17
18 push @Object::Remote::Connection::Guess, sub { 
19   for ($_[0]) {
20     # 0-9 a-z _ - first char, those or . subsequent - hostnamish
21     if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) {
22       return __PACKAGE__->new(ssh_to => $_[0]);
23     }
24   }
25   return;
26 };
27
28 1;