Class: Omnizip::ArchiveHandlers::SevenZipHandler
- Inherits:
-
Object
- Object
- Omnizip::ArchiveHandlers::SevenZipHandler
- Defined in:
- lib/omnizip/archive_handlers/seven_zip_handler.rb
Overview
Adapter that exposes the canonical +create+/+extract_to+/+list+
interface for the 7z format. Wraps Omnizip::Formats::SevenZip.
Defined Under Namespace
Classes: FileProxy
Instance Method Summary collapse
-
#create(path, &block) ⇒ Object
Creates a .7z archive.
- #extract_to(path, output_dir, **options) ⇒ Object
- #list(path, details: false, **options) ⇒ Object
- #read_entry(_path, _entry_name) ⇒ Object
Instance Method Details
#create(path, &block) ⇒ Object
Creates a .7z archive. The yielded proxy only supports
add(name, source_path) for files — directory entries are not
part of the single-file convenience flow.
11 12 13 14 15 |
# File 'lib/omnizip/archive_handlers/seven_zip_handler.rb', line 11 def create(path, &block) Omnizip::Formats::SevenZip.create(path) do |writer| block&.call(FileProxy.new(writer)) end end |
#extract_to(path, output_dir, **options) ⇒ Object
17 18 19 20 21 |
# File 'lib/omnizip/archive_handlers/seven_zip_handler.rb', line 17 def extract_to(path, output_dir, **) Omnizip::Formats::SevenZip.open(path, ) do |reader| reader.extract_all(output_dir) end end |
#list(path, details: false, **options) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/omnizip/archive_handlers/seven_zip_handler.rb', line 23 def list(path, details: false, **) Omnizip::Formats::SevenZip.open(path, ) do |reader| files = reader.list_files return details ? files.map { |f| { name: f } } : files end end |
#read_entry(_path, _entry_name) ⇒ Object
30 31 32 33 34 |
# File 'lib/omnizip/archive_handlers/seven_zip_handler.rb', line 30 def read_entry(_path, _entry_name) raise NotImplementedError, "read_from_archive for .7z is not wired; use " \ "Formats::SevenZip.open" end |