Class: Terminus::Client::Base
- Inherits:
-
Object
- Object
- Terminus::Client::Base
- Defined in:
- lib/terminus/client.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Class Method Summary collapse
Instance Method Summary collapse
- #debug(*args) ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 31 32 |
# File 'lib/terminus/client.rb', line 24 def initialize() @id = Faye.random @options = @address = TCPServer.new(0).addr @connector = Connector.new(self) @port = [:port] || @address[1] @terminus = Terminus.create(:port => @port) @browser = ChildProcess.build(*browser_args) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
8 9 10 |
# File 'lib/terminus/client.rb', line 8 def id @id end |
Class Method Details
.debugger ⇒ Object
16 17 18 |
# File 'lib/terminus/client.rb', line 16 def self.debugger @process.debugger end |
.save_screenshot(path, options = {}) ⇒ Object
20 21 22 |
# File 'lib/terminus/client.rb', line 20 def self.save_screenshot(path, = {}) @process.save_screenshot(path, ) end |
.start(options = {}) ⇒ Object
10 11 12 13 14 |
# File 'lib/terminus/client.rb', line 10 def self.start( = {}) @process = new() @process.start @process end |
Instance Method Details
#debug(*args) ⇒ Object
34 35 36 |
# File 'lib/terminus/client.rb', line 34 def debug(*args) p args if Terminus.debug end |
#start ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/terminus/client.rb', line 38 def start Terminus.ensure_reactor_running @terminus.run! @browser.start Terminus.port = @port Terminus.browser = browser_selector at_exit { stop } end |
#stop ⇒ Object
50 51 52 53 54 55 |
# File 'lib/terminus/client.rb', line 50 def stop @terminus.stop! @browser.stop @browser.poll_for_exit(10) rescue ChildProcess::TimeoutError end |