remote_table 1.2.4 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,37 +0,0 @@
1
- require 'singleton'
2
- require 'escape'
3
- require 'fileutils'
4
- require 'posix/spawn'
5
-
6
- class RemoteTable
7
- class Executor
8
- include ::Singleton
9
- # we should really be piping things i think
10
- def bang(path, cmd)
11
- srand # in case this was forked by resque
12
- tmp_path = "#{path}.bang.#{rand}"
13
- backtick_with_reporting "cat #{::Escape.shell_single_word path} | #{cmd} > #{::Escape.shell_single_word tmp_path}"
14
- ::FileUtils.mv tmp_path, path
15
- end
16
-
17
- def backtick_with_reporting(cmd, raise_on_error = false)
18
- cmd = cmd.gsub /\n/m, ' '
19
- if ::ENV['REMOTE_TABLE_DEBUG'] and ::ENV['REMOTE_TABLE_DEBUG'].include? 'backtick'
20
- $stderr.puts "[remote_table] Executing #{cmd}"
21
- end
22
- pid = ::POSIX::Spawn.spawn({ 'PATH' => '/usr/local/bin:/usr/bin:/bin' }, cmd)
23
- stat = ::Process::waitpid pid
24
- if raise_on_error and not stat.success?
25
- raise %{
26
- From the remote_table gem...
27
-
28
- Command failed:
29
- #{cmd}
30
-
31
- Exit code:
32
- #{stat.exitstatus}
33
- }
34
- end
35
- end
36
- end
37
- end