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.
5 6 7 8 9 10 |
# File 'lib/capybara/poltergeist/server.rb', line 5 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.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def custom_host @custom_host end |
#fixed_port ⇒ Object (readonly)
Returns the value of attribute fixed_port.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def fixed_port @fixed_port end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def socket @socket end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/capybara/poltergeist/server.rb', line 3 def timeout @timeout end |
Instance Method Details
#host ⇒ Object
16 17 18 |
# File 'lib/capybara/poltergeist/server.rb', line 16 def host @socket.host end |
#port ⇒ Object
12 13 14 |
# File 'lib/capybara/poltergeist/server.rb', line 12 def port @socket.port end |
#restart ⇒ Object
32 33 34 35 |
# File 'lib/capybara/poltergeist/server.rb', line 32 def restart stop start end |
#send(command) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/capybara/poltergeist/server.rb', line 37 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
24 25 26 |
# File 'lib/capybara/poltergeist/server.rb', line 24 def start @socket = WebSocketServer.new(fixed_port, timeout, custom_host) end |
#stop ⇒ Object
28 29 30 |
# File 'lib/capybara/poltergeist/server.rb', line 28 def stop @socket.close end |