Class: Phantomrb::Runner
- Inherits:
-
Object
- Object
- Phantomrb::Runner
- Defined in:
- lib/phantomrb/runner.rb
Instance Method Summary collapse
-
#initialize ⇒ Runner
constructor
A new instance of Runner.
- #run(script, *arguments, &block) ⇒ Object
Constructor Details
#initialize ⇒ Runner
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..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 |