Class: Steam::Browser::HtmlUnit::Drb

Inherits:
Object
  • Object
show all
Defined in:
lib/steam/browser/html_unit/drb.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, options = {}) ⇒ Drb

Returns a new instance of Drb.



9
10
11
12
13
14
15
# File 'lib/steam/browser/html_unit/drb.rb', line 9

def initialize(connection, options = {})
  @connection, @options = connection, options
  @process = Steam::Process.new

  process.kill if options[:restart] && process.running?
  options[:daemon] ? daemonize : start unless process.running?
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



39
40
41
# File 'lib/steam/browser/html_unit/drb.rb', line 39

def method_missing(method, *args, &block)
  object.send(method, *args, &block)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



7
8
9
# File 'lib/steam/browser/html_unit/drb.rb', line 7

def connection
  @connection
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/steam/browser/html_unit/drb.rb', line 7

def options
  @options
end

#processObject (readonly)

Returns the value of attribute process.



7
8
9
# File 'lib/steam/browser/html_unit/drb.rb', line 7

def process
  @process
end

Instance Method Details

#daemonizeObject



21
22
23
24
25
# File 'lib/steam/browser/html_unit/drb.rb', line 21

def daemonize
  options[:keep_alive] = true unless options.key?(:keep_alive)
  process.fork(options) { start }
  sleep(1) # FIXME
end

#objectObject



17
18
19
# File 'lib/steam/browser/html_unit/drb.rb', line 17

def object
  @object ||= DRbObject.new(nil, Steam.config[:drb_uri])
end

#restartObject



34
35
36
37
# File 'lib/steam/browser/html_unit/drb.rb', line 34

def restart
  process.kill if process.running?
  daemonize
end

#startObject



27
28
29
30
31
32
# File 'lib/steam/browser/html_unit/drb.rb', line 27

def start
  uri = Steam.config[:drb_uri]
  DRb.start_service(uri, HtmlUnit.new(connection, options))
  puts "HtmlUnit ready and listening at #{uri} [#{::Process.pid}]"
  DRb.thread.join
end