lib/github_snapshot/utilities.rb in github_snapshot-0.1.1 vs lib/github_snapshot/utilities.rb in github_snapshot-0.1.2

- old
+ new

@@ -1,12 +1,25 @@ 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(err + " command was: #{cmd}") + 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