Class: Omnizip::ArchiveHandlers::RpmHandler
- Inherits:
-
Object
- Object
- Omnizip::ArchiveHandlers::RpmHandler
- Defined in:
- lib/omnizip/archive_handlers/rpm_handler.rb
Overview
Read-only adapter for the RPM package format: extraction and listing over the CPIO payload; package metadata lives in Formats::Rpm.info. RPM writing exists at the format level but is not exposed through the convenience archive API.
Instance Method Summary collapse
- #create(_path, **_options) ⇒ Object
- #extract_to(path, output_dir, **_) ⇒ Object
- #list(path, details: false, **_) ⇒ Object
- #read_entry(path, entry_name, **_) ⇒ Object
Instance Method Details
#create(_path, **_options) ⇒ Object
12 13 14 15 16 |
# File 'lib/omnizip/archive_handlers/rpm_handler.rb', line 12 def create(_path, **) raise Omnizip::UnsupportedFormatError, "rpm archives cannot be created through the convenience " \ "API; use Omnizip::Formats::Rpm::Writer directly" end |
#extract_to(path, output_dir, **_) ⇒ Object
18 19 20 21 22 |
# File 'lib/omnizip/archive_handlers/rpm_handler.rb', line 18 def extract_to(path, output_dir, **_) Omnizip::Formats::Rpm.extract(path, output_dir) Dir.glob(File.join(output_dir, "**", "*")) .select { |f| File.file?(f) } end |
#list(path, details: false, **_) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/omnizip/archive_handlers/rpm_handler.rb', line 24 def list(path, details: false, **_) entries = Omnizip::Formats::Rpm.list(path) return entries unless details entries.map { |name| { name: name, size: nil, directory: false } } end |
#read_entry(path, entry_name, **_) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/omnizip/archive_handlers/rpm_handler.rb', line 31 def read_entry(path, entry_name, **_) Dir.mktmpdir("omnizip-rpm-entry") do |dir| Omnizip::Formats::Rpm.extract(path, dir) dest = File.join(dir, entry_name) raise Errno::ENOENT, "Entry not found: #{entry_name}" unless File.exist?(dest) File.binread(dest) end end |