Class: Opal::CliRunners::Phantomjs

Inherits:
Object
  • Object
show all
Defined in:
opal/lib/opal/cli_runners/phantomjs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_statusObject (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

#outputObject (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

#commandObject



22
23
24
25
# File 'opal/lib/opal/cli_runners/phantomjs.rb', line 22

def command
  script_path = File.expand_path('../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