Class: Wemux::Pair::PairConnection

Inherits:
Object
  • Object
show all
Defined in:
lib/wemux/pair/pair_connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tunnel) ⇒ PairConnection

Returns a new instance of PairConnection.



5
6
7
# File 'lib/wemux/pair/pair_connection.rb', line 5

def initialize(tunnel)
  @tunnel = tunnel
end

Instance Attribute Details

#tunnelObject (readonly)

Returns the value of attribute tunnel.



4
5
6
# File 'lib/wemux/pair/pair_connection.rb', line 4

def tunnel
  @tunnel
end

Instance Method Details

#client_portObject



13
14
15
# File 'lib/wemux/pair/pair_connection.rb', line 13

def client_port
  tunnel.client_port
end

#connectObject



28
29
30
# File 'lib/wemux/pair/pair_connection.rb', line 28

def connect
  system "ssh #{ssh_options} -L #{rails_server_port}:localhost:3000 -p #{client_port} #{Wemux::Pair.config.pair_user}@localhost"
end

#port_offsetObject



9
10
11
# File 'lib/wemux/pair/pair_connection.rb', line 9

def port_offset
  tunnel.port_offset
end

#rails_server_portObject



17
18
19
# File 'lib/wemux/pair/pair_connection.rb', line 17

def rails_server_port
  3000 + port_offset
end

#ssh_optionsObject



21
22
23
24
25
26
# File 'lib/wemux/pair/pair_connection.rb', line 21

def ssh_options
  [
    "StrictHostKeyChecking no",
    "UserKnownHostsFile /dev/null",
  ].map { |o| "-o \"#{o}\""}.join(" ")
end