Class: SGrid::Hub

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium-grid/lib/ruby/s_grid/hub.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Hub

Returns a new instance of Hub.



5
6
7
8
# File 'lib/selenium-grid/lib/ruby/s_grid/hub.rb', line 5

def initialize(options={})
  @host = options[:host] || "localhost"
  @port = (options[:port] || "4444").to_i
end

Instance Method Details

#shutdownObject



22
23
24
25
# File 'lib/selenium-grid/lib/ruby/s_grid/hub.rb', line 22

def shutdown
  http = Net::HTTP.new(@host, @port)
  http.post('/lifecycle-manager', "action=shutdown")
end

#start(options = {}) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/selenium-grid/lib/ruby/s_grid/hub.rb', line 10

def start(options={})
  root = File.expand_path(File.dirname(__FILE__) + "/../../..")
  classpath = Java::Classpath.new(root)
  classpath = classpath << "." << "lib/selenium-grid-hub-standalone-*.jar"
  Java::VM.new.run "com.thoughtworks.selenium.grid.hub.HubServer",
                    options.merge(:classpath => classpath.definition)
end

#wait_until_up_and_runningObject



18
19
20
# File 'lib/selenium-grid/lib/ruby/s_grid/hub.rb', line 18

def wait_until_up_and_running
  TCPSocket.wait_for_service :host => @host, :port => @port
end