Class: Opal::CliRunners::Chrome
- Inherits:
-
Object
- Object
- Opal::CliRunners::Chrome
- Defined in:
- opal/lib/opal/cli_runners/chrome.rb
Constant Summary
- SCRIPT_PATH =
File.('../chrome.js', __FILE__).freeze
- DEFAULT_CHROME_HOST =
'localhost'.freeze
- DEFAULT_CHROME_PORT =
9222.freeze
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
14 15 16 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 14 def initialize() @output = .fetch(:output, $stdout) end |
Instance Attribute Details
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status
17 18 19 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 17 def exit_status @exit_status end |
#output ⇒ Object (readonly)
Returns the value of attribute output
17 18 19 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 17 def output @output end |
Instance Method Details
#run(code, argv) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 19 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 |