Class: JstdRunner::VncControl

Inherits:
Object
  • Object
show all
Defined in:
lib/jstd-runner/vnc_control.rb

Defined Under Namespace

Classes: Error

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(display = nil) ⇒ VncControl

Returns a new instance of VncControl.



19
20
21
# File 'lib/jstd-runner/vnc_control.rb', line 19

def initialize(display = nil)
  @display = display
end

Instance Attribute Details

#displayObject (readonly)

Returns the value of attribute display.



17
18
19
# File 'lib/jstd-runner/vnc_control.rb', line 17

def display
  @display
end

Class Method Details

.allObject



12
13
14
# File 'lib/jstd-runner/vnc_control.rb', line 12

def all
  displays.map { |display| new(":#{display}") }
end

.displaysObject



8
9
10
# File 'lib/jstd-runner/vnc_control.rb', line 8

def displays
  Dir[File.expand_path("~/.vnc/*.pid")].map { |e| e[/(\d+)\.pid/, 1] }.compact
end

Instance Method Details

#startObject



23
24
25
26
27
28
29
30
31
# File 'lib/jstd-runner/vnc_control.rb', line 23

def start
  if @display
    server @display
    Log.info "vnc server launched on #{@display.inspect}"
  else
    output = server
    @display = output[/desktop is #{host}(\S+)/, 1]
  end
end

#stopObject



33
34
35
# File 'lib/jstd-runner/vnc_control.rb', line 33

def stop
  server "-kill", @display.to_s
end