Class: Phantomrb::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/phantomrb/runner.rb

Instance Method Summary collapse

Constructor Details

#initializeRunner

Returns a new instance of Runner.



5
6
7
8
9
10
# File 'lib/phantomrb/runner.rb', line 5

def initialize
  config = Phantomrb.configuration
  @command = config.options.reduce(config.executable) do |memo, (key, value)|
    "#{memo} --#{key}=#{value}"
  end
end

Instance Method Details

#run(script, *arguments, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/phantomrb/runner.rb', line 12

def run(script, *arguments, &block)
  command_line = "#{@command} #{full_script_path(script)} #{arguments.join(' ')}"
  begin
    process = IO.popen(command_line)
  rescue => e
    raise ExecutableLoadError.new(e)
  end
  output = capture_output(process, &block)
  process.close
  OpenStruct.new(output: output, exit_status: $?.exitstatus, command_line: command_line)
end