class Caco::Unpacker

Public Instance Methods

build_integrity_command(ctx, pack:, mime_type:, **) click to toggle source
# File lib/caco/unpacker.rb, line 57
def build_integrity_command(ctx, pack:, mime_type:, **)
  return (ctx[:integrity_command] = "tar tzf #{pack}") if mime_type == "application/gzip"
  return (ctx[:integrity_command] = "tar tjf #{pack}") if mime_type == "application/x-bzip"
  return (ctx[:integrity_command] = "tar tf #{pack}") if mime_type == "application/x-tar"
  ctx[:integrity_command] = "tar tf #{pack}"
end
build_unknown_command(ctx, pack:, dest:, mime_type:, **) click to toggle source
# File lib/caco/unpacker.rb, line 70
def build_unknown_command(ctx, pack:, dest:, mime_type:, **)
  basename = File.basename(pack)
  return ctx[:command] = "gunzip -c #{pack} > #{dest}/#{basename}" if mime_type == "application/gzip"
  ctx[:failure_reason] = "unknown_format"
  false
end
find_format(ctx, pack:, dest:, **) click to toggle source
# File lib/caco/unpacker.rb, line 64
def find_format(ctx, pack:, dest:, **)
  ctx[:unknown_file_mime] = Marcel::MimeType.for pack
rescue StandardError
  false
end