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_cdp_interface.rb', __dir__).freeze
- DEFAULT_CHROME_HOST =
'localhost'
- DEFAULT_CHROME_PORT =
9222
Instance Attribute Summary collapse
-
#builder ⇒ Object
readonly
Returns the value of attribute builder.
-
#exit_status ⇒ Object
readonly
Returns the value of attribute exit_status.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data) ⇒ Chrome
constructor
A new instance of Chrome.
- #run ⇒ Object
Constructor Details
#initialize(data) ⇒ Chrome
Returns a new instance of Chrome.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 23 def initialize(data) builder = data[:builder].call = data[:options] argv = data[:argv] if argv && argv.any? warn "warning: ARGV is not supported by the Chrome runner #{argv.inspect}" end @output = .fetch(:output, $stdout) @builder = builder end |
Instance Attribute Details
#builder ⇒ Object (readonly)
Returns the value of attribute builder.
36 37 38 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 36 def builder @builder end |
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status.
36 37 38 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 36 def exit_status @exit_status end |
#output ⇒ Object (readonly)
Returns the value of attribute output.
36 37 38 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 36 def output @output end |
Class Method Details
.call(data) ⇒ Object
18 19 20 21 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 18 def self.call(data) runner = new(data) runner.run end |
Instance Method Details
#run ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'opal/lib/opal/cli_runners/chrome.rb', line 38 def run mktmpdir do |dir| with_chrome_server do prepare_files_in(dir) env = { 'CHROME_HOST' => chrome_host, 'CHROME_PORT' => chrome_port.to_s, 'NODE_PATH' => File.join(__dir__, 'node_modules') } cmd = [ RbConfig.ruby, "#{__dir__}/../../../exe/opal", '--no-exit', '-I', __dir__, '-r', 'source-map-support-node', SCRIPT_PATH, dir, ] Kernel.exec(env, *cmd) end end end |