Class: Dragonfly::Shell

Inherits:
Object show all
Defined in:
lib/dragonfly/shell.rb

Defined Under Namespace

Classes: CommandFailed

Instance Method Summary collapse

Instance Method Details

#escape_args(args) ⇒ Object



17
18
19
20
21
# 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) ⇒ Object



23
24
25
26
# File 'lib/dragonfly/shell.rb', line 23

def quote(string)
  q = Dragonfly.running_on_windows? ? '"' : "'"
  q + string + q
end

#run(command, opts = {}) ⇒ Object



11
12
13
14
15
# 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