Class: Capybara::Poltergeist::Client
- Inherits:
-
Object
- Object
- Capybara::Poltergeist::Client
- Defined in:
- lib/capybara/poltergeist/client.rb
Constant Summary collapse
- PHANTOMJS_SCRIPT =
File.('../client/compiled/main.js', __FILE__)
- PHANTOMJS_VERSION =
"1.4.1"
Instance Attribute Summary collapse
-
#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.
Class Method Summary collapse
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.
16 17 18 19 20 |
# File 'lib/capybara/poltergeist/client.rb', line 16 def initialize(port, path = nil) @port = port @path = path || 'phantomjs' at_exit { stop } end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/capybara/poltergeist/client.rb', line 8 def path @path end |
#pid ⇒ Object (readonly)
Returns the value of attribute pid.
8 9 10 |
# File 'lib/capybara/poltergeist/client.rb', line 8 def pid @pid end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
8 9 10 |
# File 'lib/capybara/poltergeist/client.rb', line 8 def port @port end |
Class Method Details
.start(*args) ⇒ Object
10 11 12 13 14 |
# File 'lib/capybara/poltergeist/client.rb', line 10 def self.start(*args) client = new(*args) client.start client end |
Instance Method Details
#restart ⇒ Object
31 32 33 34 |
# File 'lib/capybara/poltergeist/client.rb', line 31 def restart stop start end |
#start ⇒ Object
22 23 24 25 |
# File 'lib/capybara/poltergeist/client.rb', line 22 def start check_phantomjs_version @pid = Kernel.spawn("#{path} #{PHANTOMJS_SCRIPT} #{port}") end |
#stop ⇒ Object
27 28 29 |
# File 'lib/capybara/poltergeist/client.rb', line 27 def stop Process.kill('TERM', pid) if pid end |