class Excavate::Extractors::RpmExtractor

Public Instance Methods

extract(target) click to toggle source
# File lib/excavate/extractors/rpm_extractor.rb, line 12
def extract(target)
  File.open(@archive, "rb") do |file|
    rpm = RPM::File.new(file)
    content = rpm.payload.read
    path = target_path(@archive, rpm.tags, target)

    File.write(path, content, mode: "wb")
  end
end

Private Instance Methods

target_path(archive, tags, dir) click to toggle source
# File lib/excavate/extractors/rpm_extractor.rb, line 24
def target_path(archive, tags, dir)
  archive_format = tags[:payloadformat]
  compression_format = tags[:payloadcompressor] == "gzip" ? "gz" : tags[:payloadcompressor]
  basename = File.basename(archive, ".*")
  filename = basename + "." + archive_format + "." + compression_format
  File.join(dir, filename)
end