Class: Provider
- Inherits:
-
Object
- Object
- Provider
- Defined in:
- lib/provider.rb
Instance Attribute Summary collapse
-
#drb_server_uri ⇒ Object
Returns the value of attribute drb_server_uri.
-
#ring_server_uri ⇒ Object
Returns the value of attribute ring_server_uri.
Instance Method Summary collapse
-
#initialize(params = {}) ⇒ Provider
constructor
A new instance of Provider.
-
#start(params = {}) ⇒ Object
Start providing Watir objects on the ring server.
-
#stop ⇒ Object
Stop the provider by shutting down the DRb service.
Constructor Details
#initialize(params = {}) ⇒ Provider
Returns a new instance of Provider.
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/provider.rb', line 88 def initialize(params = {}) @drb_server_host = params[:drb_server_host] || external_interface @drb_server_port = params[:drb_server_port] || 0 @ring_server_host = params[:ring_server_host] || external_interface @ring_server_port = params[:ring_server_port] || Rinda::Ring_PORT @controller_uri = params[:controller_uri] @renewer = params[:renewer] || Rinda::SimpleRenewer.new @driver = params[:driver] || 'webdriver' @browser_type = params[:browser_type] || 'firefox' logfile = params[:logfile] || STDOUT @log = Logger.new(logfile, 'daily') @log.level = params[:loglevel] || Logger::INFO @log.datetime_format = "%Y-%m-%d %H:%M:%S " end |
Instance Attribute Details
#drb_server_uri ⇒ Object
Returns the value of attribute drb_server_uri.
86 87 88 |
# File 'lib/provider.rb', line 86 def drb_server_uri @drb_server_uri end |
#ring_server_uri ⇒ Object
Returns the value of attribute ring_server_uri.
86 87 88 |
# File 'lib/provider.rb', line 86 def ring_server_uri @ring_server_uri end |
Instance Method Details
#start(params = {}) ⇒ Object
Start providing Watir objects on the ring server
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/provider.rb', line 106 def start(params = {}) # create a DRb 'front' object watir_provider = Watir::Provider.new(@driver) @log.debug("Watir provider is : #{watir_provider}") architecture = Config::CONFIG['arch'] hostname = ENV['SERVER_NAME'] || %x{hostname}.strip # setup the security--remember to call before DRb.start_service() DRb.install_acl(ACL.new(@acls)) # start the DRb Server drb_server = DRb.start_service( "druby://#{@drb_server_host}:#{@drb_server_port}") # obtain DRb Server uri @drb_server_uri = drb_server.uri @log.info("Provider started on : #{@drb_server_uri}") # create a service tuple @tuple = [ :WatirGrid, :WatirProvider, watir_provider, 'A watir provider', hostname, architecture, @driver, @browser_type ] # locate the Rinda Ring Server via a UDP broadcast @log.debug("Broadcast Ring Server : druby://#{@ring_server_host}:#{@ring_server_port}") find_ring_server # advertise this service on the primary remote tuple space @ring_server.write(@tuple, @renewer) # log DRb server uri @log.info("Provider registered : #{@controller_uri}") # wait for explicit stop via ctrl-c DRb.thread.join if __FILE__ == $0 end |
#stop ⇒ Object
Stop the provider by shutting down the DRb service
152 153 154 155 |
# File 'lib/provider.rb', line 152 def stop DRb.stop_service @log.info("Provider stopped on : #{@drb_server_uri}") end |