Sha256: c1933341c13c7b5956217c265ef6f72465c373d769b2e163e7734f065089ae27

Contents?: true

Size: 596 Bytes

Versions: 7

Compression:

Stored size: 596 Bytes

Contents

require 'singleton'
require 'escape'
require 'fileutils'
class RemoteTable
  class Executor
    include ::Singleton
    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

    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
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
remote_table-1.1.2 lib/remote_table/executor.rb
remote_table-1.1.1 lib/remote_table/executor.rb
remote_table-1.1.0 lib/remote_table/executor.rb
remote_table-1.0.3 lib/remote_table/executor.rb
remote_table-1.0.2 lib/remote_table/executor.rb
remote_table-1.0.1 lib/remote_table/executor.rb
remote_table-1.0.0 lib/remote_table/executor.rb