Module: Utilities

Defined in:
lib/github_snapshot/utilities.rb

Constant Summary collapse

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

Class Method Summary collapse

Class Method Details

.exec(cmd, logger) ⇒ Object



7
8
9
10
11
12
13
14
15
# File 'lib/github_snapshot/utilities.rb', line 7

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

.tar(file, logger) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/github_snapshot/utilities.rb', line 17

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