Class: Pair::Session::HostedSession

Inherits:
Pair::Session show all
Defined in:
lib/pair/session/hosted_session.rb

Instance Attribute Summary collapse

Attributes inherited from Pair::Session

#host, #name, #options, #participants, #viewers

Instance Method Summary collapse

Methods inherited from Pair::Session

host

Constructor Details

#initialize(options = {}) ⇒ HostedSession

Returns a new instance of HostedSession.



7
8
9
10
11
12
13
14
15
16
# File 'lib/pair/session/hosted_session.rb', line 7

def initialize(options = {})
  puts "Hosting session #{"called #{options[:name].inspect} " if options[:name]}..."

  self.name         = options.delete(:name)
  self.viewers      = options.delete(:viewers)      || []
  self.participants = options.delete(:participants) || []
  self.tmux         = Tmux.new(self)

  super(options)
end

Instance Attribute Details

#authorized_keys_fileObject

Returns the value of attribute authorized_keys_file.



4
5
6
# File 'lib/pair/session/hosted_session.rb', line 4

def authorized_keys_file
  @authorized_keys_file
end

#responseObject

Returns the value of attribute response.



4
5
6
# File 'lib/pair/session/hosted_session.rb', line 4

def response
  @response
end

#tmuxObject

Returns the value of attribute tmux.



4
5
6
# File 'lib/pair/session/hosted_session.rb', line 4

def tmux
  @tmux
end

#tunnelObject

Returns the value of attribute tunnel.



4
5
6
# File 'lib/pair/session/hosted_session.rb', line 4

def tunnel
  @tunnel
end

Instance Method Details

#bastionObject



50
51
52
# File 'lib/pair/session/hosted_session.rb', line 50

def bastion
  response["tunnel"]["bastion"]
end

#cleanup_authorized_keysObject



58
59
60
# File 'lib/pair/session/hosted_session.rb', line 58

def cleanup_authorized_keys
  authorized_keys_file.cleanup
end

#connect_commandObject

TODO: this should get host/user from response



46
47
48
# File 'lib/pair/session/hosted_session.rb', line 46

def connect_command
  "ssh-add; ssh -tqA -l#{bastion["join_user"]} #{bastion["host"]} #{name}"
end

#display_startup_messageObject



35
36
37
38
39
40
41
42
43
# File 'lib/pair/session/hosted_session.rb', line 35

def display_startup_message
  puts "Your pairs can connect to this session using the following command:"
  puts ""
  puts "	#{connect_command}"
  puts ""
  print "Press any key to continue..."

  gets
end

#host_loginObject



54
55
56
# File 'lib/pair/session/hosted_session.rb', line 54

def 
  `whoami`.chomp
end

#start!Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/pair/session/hosted_session.rb', line 18

def start!
  if setup
    display_startup_message

    tunnel.open do
      tmux.start
      tmux.attach
    end
  else
    puts "There was a problem starting the host session %s" % (name && name.inspect)
    puts "response: #{response.inspect}" if response && $-d
    puts ""
  end

  exit
end