Included Modules

Files

Class/Module Index [+]

Quicksearch

Dragonfly::Shell

Public Instance Methods

escape_args(args) click to toggle source
# File lib/dragonfly/shell.rb, line 32
def escape_args(args)
  args.shellsplit.map do |arg|
    quote arg.gsub(/\\?'/, %('\\''))
  end.join(' ')
end
quote(string) click to toggle source
# File lib/dragonfly/shell.rb, line 38
def quote(string)
  q = Dragonfly.running_on_windows? ? '"' : "'"
  q + string + q
end
raise_shell_command_failed(command) click to toggle source
# File lib/dragonfly/shell.rb, line 28
def raise_shell_command_failed(command)
  raise CommandFailed, "Command failed (#{command}) with exit status #{$?.exitstatus}"
end
run(command, args="") click to toggle source
# File lib/dragonfly/shell.rb, line 12
def run(command, args="")
  full_command = "#{command} #{escape_args(args)}"
  log.debug("Running command: #{full_command}") if log_commands
  begin
    result = `#{full_command}`
  rescue Errno::ENOENT
    raise_shell_command_failed(full_command)
  end
  if $?.exitstatus == 1
    throw :unable_to_handle
  elsif !$?.success?
    raise_shell_command_failed(full_command)
  end
  result
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.