Class: Capybara::Poltergeist::Server
- Inherits:
-
Object
- Object
- Capybara::Poltergeist::Server
- Defined in:
- lib/capybara/poltergeist/server.rb
Instance Attribute Summary collapse
-
#custom_host ⇒ Object
readonly
Returns the value of attribute custom_host.
-
#fixed_port ⇒ Object
readonly
Returns the value of attribute fixed_port.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #host ⇒ Object
-
#initialize(fixed_port = nil, timeout = nil, custom_host = nil) ⇒ Server
constructor
A new instance of Server.
- #port ⇒ Object
- #restart ⇒ Object
- #send(command) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(fixed_port = nil, timeout = nil, custom_host = nil) ⇒ Server
Returns a new instance of Server.
7 8 9 10 11 12 |
# File 'lib/capybara/poltergeist/server.rb', line 7 def initialize(fixed_port = nil, timeout = nil, custom_host = nil) @fixed_port = fixed_port @timeout = timeout @custom_host = custom_host start end |
Instance Attribute Details
#custom_host ⇒ Object (readonly)
Returns the value of attribute custom_host.
5 6 7 |
# File 'lib/capybara/poltergeist/server.rb', line 5 def custom_host @custom_host end |
#fixed_port ⇒ Object (readonly)
Returns the value of attribute fixed_port.
5 6 7 |
# File 'lib/capybara/poltergeist/server.rb', line 5 def fixed_port @fixed_port end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
5 6 7 |
# File 'lib/capybara/poltergeist/server.rb', line 5 def socket @socket end |
#timeout ⇒ Object
Returns the value of attribute timeout.
5 6 7 |
# File 'lib/capybara/poltergeist/server.rb', line 5 def timeout @timeout end |
Instance Method Details
#host ⇒ Object
18 19 20 |
# File 'lib/capybara/poltergeist/server.rb', line 18 def host @socket.host end |
#port ⇒ Object
14 15 16 |
# File 'lib/capybara/poltergeist/server.rb', line 14 def port @socket.port end |
#restart ⇒ Object
34 35 36 37 |
# File 'lib/capybara/poltergeist/server.rb', line 34 def restart stop start end |
#send(command) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/capybara/poltergeist/server.rb', line 39 def send(command) receive_timeout = nil # default if command.name == 'visit' command.args.push(timeout) # set the client set visit timeout parameter receive_timeout = timeout + 5 # Add a couple of seconds to let the client timeout first end @socket.send(command.id, command., receive_timeout) or raise DeadClient.new(command.) end |
#start ⇒ Object
26 27 28 |
# File 'lib/capybara/poltergeist/server.rb', line 26 def start @socket = WebSocketServer.new(fixed_port, timeout, custom_host) end |
#stop ⇒ Object
30 31 32 |
# File 'lib/capybara/poltergeist/server.rb', line 30 def stop @socket.close end |