Class: Opal::CliRunners::Phantomjs
- Inherits:
-
Object
- Object
- Opal::CliRunners::Phantomjs
- Defined in:
- opal/lib/opal/cli_runners/phantomjs.rb
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
- #command ⇒ Object
-
#initialize(output = $stdout) ⇒ Phantomjs
constructor
A new instance of Phantomjs.
- #run(code, argv) ⇒ Object
Constructor Details
#initialize(output = $stdout) ⇒ Phantomjs
Returns a new instance of Phantomjs
6 7 8 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 6 def initialize(output = $stdout) @output = output end |
Instance Attribute Details
#exit_status ⇒ Object (readonly)
Returns the value of attribute exit_status
9 10 11 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 9 def exit_status @exit_status end |
#output ⇒ Object (readonly)
Returns the value of attribute output
9 10 11 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 9 def output @output end |
Instance Method Details
#command ⇒ Object
22 23 24 25 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 22 def command script_path = File.('../phantom.js', __FILE__) "phantomjs #{script_path.shellescape}" end |
#run(code, argv) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 11 def run(code, argv) unless argv.empty? raise ArgumentError, 'Program arguments are not supported on the PhantomJS runner' end phantomjs = IO.popen(command, 'w', out: output) do |io| io.write(code) end @exit_status = $?.exitstatus end |