class Dragonfly::Shell

Public Instance Methods

escape_args(args) click to toggle source
# File lib/dragonfly/shell.rb, line 17
def escape_args(args)
  args.shellsplit.map do |arg|
    quote arg.gsub(/\?'/, %q('\\''))
  end.join(' ')
end
quote(string) click to toggle source
# File lib/dragonfly/shell.rb, line 23
def quote(string)
  q = Dragonfly.running_on_windows? ? '"' : "'"
  q + string + q
end
run(command, opts={}) click to toggle source
# File lib/dragonfly/shell.rb, line 11
def run(command, opts={})
  command = escape_args(command) unless opts[:escape] == false
  Dragonfly.debug("shell command: #{command}")
  run_command(command)
end

Private Instance Methods

run_command(command) click to toggle source

Unfortunately we have no control over stderr this way

# File lib/dragonfly/shell.rb, line 36
def run_command(command)
  result = %x`#{command}`
  status = $?
  raise CommandFailed, "Command failed (#{command}) with exit status #{status.exitstatus}" unless status.success?
  result
end