omnizip 0.3.34 → 0.3.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad5f2e41132ed61e2e80173f7550d75f3f0c8711d264e36a605fbee28e4a322e
4
- data.tar.gz: 6d2b1989b06bb359cf48f2a5d24e8eea4b697cde22404c144cfef72357fdfb2d
3
+ metadata.gz: 53eb9dfabf6b8f299e86de445f0b2e487dcb12531ad6c901d35f89b306e53e97
4
+ data.tar.gz: 2df326cef1acba3e9de77ee349c4714ba3ba20c559beab62637dd70b2d55c1d8
5
5
  SHA512:
6
- metadata.gz: 38afce515d452d0dd4b1ace8b32608b59ff72e86d76d7d0ccfe3985f2d8cae6c24f4e657dc2e48d92b1b9194de2bca7e6d38eedb499255f1b8dcc3da5e2660db
7
- data.tar.gz: dab546e8c4db730e7d257d29c89e903768e2112e858a87ef55daf3ac64305e584c715b3042a60e5caef7428357a8b12d4c2609e8ed2baa15612a5ada53ed3337
6
+ metadata.gz: 182da8c8f1f5ccf84552f1bb7741f00340165d90bf8a19edcb3299dcdff02d99644b98b87fa13969dd62090c70f9973c97950267b816a3cceda988c53df2430b
7
+ data.tar.gz: e8745b56c4aded2fa04e81d0dd0ec011360f4593d590b4127aa284fac62b42766c39e26ce53f67b9f77e6e7cbe024345465a89af544b4594213e5d8811d297a2
data/CHANGELOG.md CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Fixed
11
+ - `add_to_archive`/`remove_from_archive` errors name the resolved
12
+ format (`Format :seven_zip does not support adding entries`)
13
+ instead of always blaming `:zip`, the default parameter the caller
14
+ never passed.
15
+
16
+ ## [0.3.35] - 2026-08-28
17
+
18
+ ### Fixed
19
+ - `Omnizip.list_archive` on `.7z` returned raw Reader objects (the
20
+ SevenZip.open facade discards block return values) and
21
+ `read_from_archive` on `.7z` raised NotImplementedError. Both work
22
+ now: list returns entry names (or name/size/directory/mtime hashes
23
+ with `details: true`) and read returns entry bytes, wired through
24
+ the reader's `extract_entry_data`; missing entries raise
25
+ `Errno::ENOENT` like the ZIP handler.
26
+
27
+ ## [0.3.34] - 2026-08-27
28
+
10
29
  ### Fixed
11
30
  - `Omnizip.compress_directory` to `.7z` and `.tar` (both documented)
12
31
  works now: the 7z handler treats directory entries as the no-op
@@ -21,16 +21,40 @@ module Omnizip
21
21
  end
22
22
 
23
23
  def list(path, details: false, **options)
24
- Omnizip::Formats::SevenZip.open(path, options) do |reader|
25
- files = reader.list_files
26
- return details ? files.map { |f| { name: f } } : files
24
+ with_reader(path, options) do |reader|
25
+ entries = reader.list_files
26
+ if details
27
+ entries.map do |e|
28
+ { name: e.name, size: e.size, directory: e.is_dir,
29
+ mtime: e.mtime }
30
+ end
31
+ else
32
+ entries.map(&:name)
33
+ end
27
34
  end
28
35
  end
29
36
 
30
- def read_entry(_path, _entry_name)
31
- raise NotImplementedError,
32
- "read_from_archive for .7z is not wired; use " \
33
- "Formats::SevenZip.open"
37
+ def read_entry(path, entry_name, **options)
38
+ with_reader(path, options) do |reader|
39
+ entry = reader.list_files.find { |e| e.name == entry_name }
40
+ raise Errno::ENOENT, "Entry not found: #{entry_name}" unless entry
41
+
42
+ reader.extract_entry_data(File.open(path, "rb"), entry)
43
+ end
44
+ end
45
+
46
+ private
47
+
48
+ # The SevenZip.open facade returns the reader, discarding the
49
+ # block's value — so drive the Reader directly.
50
+ def with_reader(path, options)
51
+ reader = Omnizip::Formats::SevenZip::Reader.new(path, options)
52
+ reader.open
53
+ begin
54
+ yield reader
55
+ ensure
56
+ reader.split_reader&.close
57
+ end
34
58
  end
35
59
 
36
60
  # Translates the generic +add(name, source_path)+ interface to
@@ -131,13 +131,14 @@ module Omnizip
131
131
  raise Errno::ENOENT, "Source file not found: #{source_path}"
132
132
  end
133
133
 
134
- handler = Omnizip::ArchiveHandler.for(resolve_archive_format(archive_path, format))
134
+ resolved = resolve_archive_format(archive_path, format)
135
+ handler = Omnizip::ArchiveHandler.for(resolved)
135
136
  # allowed: handler is a registered duck; missing add_entry raises below
136
137
  if handler.respond_to?(:add_entry)
137
138
  handler.add_entry(archive_path, entry_name, source_path)
138
139
  else
139
140
  raise Omnizip::UnsupportedFormatError,
140
- "Format #{format.inspect} does not support adding entries"
141
+ "Format #{resolved.inspect} does not support adding entries"
141
142
  end
142
143
 
143
144
  archive_path
@@ -151,11 +152,12 @@ module Omnizip
151
152
  # @return [String] +archive_path+
152
153
  def remove_from_archive(archive_path, entry_name, format: DEFAULT_FORMAT)
153
154
  require_archive!(archive_path)
154
- handler = Omnizip::ArchiveHandler.for(resolve_archive_format(archive_path, format))
155
+ resolved = resolve_archive_format(archive_path, format)
156
+ handler = Omnizip::ArchiveHandler.for(resolved)
155
157
  # allowed: handler is a registered duck; missing remove_entry raises below
156
158
  unless handler.respond_to?(:remove_entry)
157
159
  raise Omnizip::UnsupportedFormatError,
158
- "Format #{format.inspect} does not support removing entries"
160
+ "Format #{resolved.inspect} does not support removing entries"
159
161
  end
160
162
 
161
163
  handler.remove_entry(archive_path, entry_name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Omnizip
4
- VERSION = "0.3.34"
4
+ VERSION = "0.3.36"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnizip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.34
4
+ version: 0.3.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-08-27 00:00:00.000000000 Z
11
+ date: 2026-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64