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(string) ⇒ Object


21
22
23
# File 'lib/dragonfly/shell.rb', line 21

def escape(string)
  Shellwords.escape(string)
end

#escape_args(args) ⇒ Object


17
18
19
# File 'lib/dragonfly/shell.rb', line 17

def escape_args(args)
  args.shellsplit.map{|arg| escape(arg) }.join(' ')
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