Class: Capybara::Poltergeist::Client
- Inherits:
-
Object
- Object
- Capybara::Poltergeist::Client
- Defined in:
- lib/capybara/poltergeist/client.rb
Constant Summary collapse
- PHANTOM_SCRIPT =
File.('../client/compiled/main.js', __FILE__)
Instance Attribute Summary collapse
-
#err ⇒ Object
readonly
Returns the value of attribute err.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#pid ⇒ Object
readonly
Returns the value of attribute pid.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(port, path = nil) ⇒ Client
constructor
A new instance of Client.
- #restart ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(port, path = nil) ⇒ Client
Returns a new instance of Client.
9 10 11 12 13 14 15 |
# File 'lib/capybara/poltergeist/client.rb', line 9 def initialize(port, path = nil) @port = port @path = path || 'phantomjs' start at_exit { stop } end |
Instance Attribute Details
#err ⇒ Object (readonly)
Returns the value of attribute err.
7 8 9 |
# File 'lib/capybara/poltergeist/client.rb', line 7 def err @err end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/capybara/poltergeist/client.rb', line 7 def path @path end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
7 8 9 |
# File 'lib/capybara/poltergeist/client.rb', line 7 def pid @pid end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
7 8 9 |
# File 'lib/capybara/poltergeist/client.rb', line 7 def port @port end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
7 8 9 |
# File 'lib/capybara/poltergeist/client.rb', line 7 def thread @thread end |
Instance Method Details
#restart ⇒ Object
25 26 27 28 |
# File 'lib/capybara/poltergeist/client.rb', line 25 def restart stop start end |
#start ⇒ Object
17 18 19 |
# File 'lib/capybara/poltergeist/client.rb', line 17 def start @pid = Kernel.spawn("#{path} #{PHANTOM_SCRIPT} #{port}") end |
#stop ⇒ Object
21 22 23 |
# File 'lib/capybara/poltergeist/client.rb', line 21 def stop Process.kill('TERM', pid) end |