parameterize more of the connector information
[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 has ssh_perl_command => (is => 'lazy');
12
13 sub _build_ssh_perl_command {
14   my ($self) = @_;
15   return [ 'ssh', '-A', $self->ssh_to, @{$self->perl_command} ];
16 }
17
18 sub final_perl_command { shift->ssh_perl_command }
19
20 no warnings 'once';
21
22 push @Object::Remote::Connection::Guess, sub { 
23   for ($_[0]) {
24     # 0-9 a-z _ - first char, those or . subsequent - hostnamish
25     if (defined and !ref and /^(?:.*?\@)?[\w\-][\w\-\.]/) {
26       return __PACKAGE__->new(ssh_to => $_[0]);
27     }
28   }
29   return;
30 };
31
32 1;