Class: RemoteTable::Executor

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/remote_table/executor.rb

Instance Method Summary collapse

Instance Method Details

#backtick_with_reporting(cmd) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/remote_table/executor.rb', line 13

def backtick_with_reporting(cmd)
  cmd = cmd.gsub /[ ]*\n[ ]*/m, ' '
  output = `#{cmd}`
  if not $?.success?
    raise %{
From the remote_table gem...

Command failed:
#{cmd}

Output:
#{output}
}
  end
end

#bang(path, cmd) ⇒ Object



7
8
9
10
11
# File 'lib/remote_table/executor.rb', line 7

def bang(path, cmd)
  tmp_path = "#{path}.bang.#{rand}"
  backtick_with_reporting "/bin/cat #{::Escape.shell_single_word path} | #{cmd} > #{::Escape.shell_single_word tmp_path}"
  ::FileUtils.mv tmp_path, path
end