Class: Opal::CliRunners::Chrome
- Inherits:
-
Object
- Object
- Opal::CliRunners::Chrome
- Defined in:
- opal/lib/opal/cli_runners/chrome.rb
Constant Summary collapse
- SCRIPT_PATH =
File.('chrome.js', __dir__).freeze
- DEFAULT_CHROME_HOST =
'localhost'
- DEFAULT_CHROME_PORT =
9222
Instance Attribute Summary collapse
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Instance Method Summary collapse
-
#initialize(options) ⇒ Chrome
constructor
A new instance of Chrome.
- #run(code, _argv) ⇒ Object
Constructor Details
#initialize(options) ⇒ Chrome
Returns a new instance of Chrome.
15 16 17 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 15 def initialize() @output = .fetch(:output, $stdout) end |
Instance Attribute Details
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status.
18 19 20 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 18 def exit_status @exit_status end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
18 19 20 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 18 def output @output end |
Instance Method Details
#run(code, _argv) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 20 def run(code, _argv) with_chrome_server do cmd = [ 'env', "CHROME_HOST=#{chrome_host}", "CHROME_PORT=#{chrome_port}", 'node', SCRIPT_PATH ] IO.popen(cmd, 'w', out: output) do |io| io.write(code) end @exit_status = $?.exitstatus end end |