Sha256: 07f434c028b5ca2b2937c06f9529b1c6fc14456d6eb60a26ccddf6927490a6aa

Contents?: true

Size: 556 Bytes

Versions: 3

Compression:

Stored size: 556 Bytes

Contents

module Utilities
  Error     = Class.new(RuntimeError)
  ExecError = Class.new(Error)

  module_function

  def exec(cmd, logger)
    out, err, status = Open3.capture3 cmd
    if err.empty?
      logger.debug out unless out.empty?
    else
      logger.error "Open3 error:\n#{'='*79}\n#{err}Command was:\n#{cmd}\n#{'='*79}\n"
      raise Utilities::ExecError
    end
  end

  def tar(file, logger)
    if File.exists? file
      Utilities.exec "tar zcf #{file}.tar.gz #{file}", logger
    else
      logger.error "Unable to tar #{file}"
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
github_snapshot-0.1.4 lib/github_snapshot/utilities.rb
github_snapshot-0.1.3 lib/github_snapshot/utilities.rb
github_snapshot-0.1.2 lib/github_snapshot/utilities.rb