omnizip 0.3.33 → 0.3.35

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: 0f3064a982a38257ff4ef606d6de52925a377e2138a3bacc7cb60033a6ff1ac1
4
- data.tar.gz: f24f28f6daac8df45542854f099c071d5b17f52deff99ae7f3bd5d009d6d7c0d
3
+ metadata.gz: e76fab599398d72d3eb4999e7d516dabb26e1ca625dbc75afb35d48b7d037dcf
4
+ data.tar.gz: 6afeb78f1f806ba12a7577bfe8c6fd2f6ba127047ec8546b0513be5516a7420a
5
5
  SHA512:
6
- metadata.gz: 7e08082742ca10c5156773d5d279c1e5c7fe6d035cbe06678e2c68509862d89880c1a7f3e40d4e7a69b433e2407546d3735846a7d53a3c139819fa271001b852
7
- data.tar.gz: 8d8551cf4cd26ae177b36e5aa67f217323853535ffaed26e4825f537e4384e998629b6084240a2dd82eaad276396dd51b22ab84a4d65f6f9f98475965ca6096e
6
+ metadata.gz: 7a46395d5faa8ed51438bb680839490c99dd15c01f2409b60a8cf9241af8269150b0fb98694fc176c330af90ded71bea99e64f0c11770f0c9d8259abf1719b8f
7
+ data.tar.gz: bec34c361902bc7954b98d4d9d1f50e53cdac36bb9b800b3d6d0109a1ffc9e36e5211fba84cb38f829ef54c27a3eba79f03b0df8be39af0026c378f5feeee773
data/CHANGELOG.md CHANGED
@@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ### Fixed
11
+ - `Omnizip.list_archive` on `.7z` returned raw Reader objects (the
12
+ SevenZip.open facade discards block return values) and
13
+ `read_from_archive` on `.7z` raised NotImplementedError. Both work
14
+ now: list returns entry names (or name/size/directory/mtime hashes
15
+ with `details: true`) and read returns entry bytes, wired through
16
+ the reader's `extract_entry_data`; missing entries raise
17
+ `Errno::ENOENT` like the ZIP handler.
18
+
19
+ ## [0.3.34] - 2026-08-27
20
+
21
+ ### Fixed
22
+ - `Omnizip.compress_directory` to `.7z` and `.tar` (both documented)
23
+ works now: the 7z handler treats directory entries as the no-op
24
+ they are in the format (7z derives the tree from file paths;
25
+ nested paths verified against `7zz`), and the Tar handler routes
26
+ bare directory entries to the writer's `add_directory` instead of
27
+ misreading them as CWD-relative paths. Both round-trip nested
28
+ subdirectories through `extract_archive`.
29
+
30
+ ## [0.3.33] - 2026-08-27
31
+
10
32
  ### Fixed
11
33
  - The convenience API (`compress_file`, `compress_directory`,
12
34
  `extract_archive`, `list_archive`, `read_from_archive`,
@@ -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
@@ -40,12 +64,12 @@ module Omnizip
40
64
  @writer = writer
41
65
  end
42
66
 
67
+ # Directory entries are a no-op: 7z archives derive the
68
+ # directory tree from the files' archive paths ("sub/f.txt"
69
+ # implies "sub/"), and the writer/reader handle slashed
70
+ # paths (verified against 7zz).
43
71
  def add(name, source_path = nil)
44
- if source_path.nil?
45
- raise ArgumentError,
46
- "directory entries are not supported in .7z " \
47
- "convenience compression"
48
- end
72
+ return if source_path.nil?
49
73
 
50
74
  @writer.add_file(source_path, name)
51
75
  end
@@ -6,7 +6,9 @@ module Omnizip
6
6
  # /+list+ interface for the TAR format. Wraps +Omnizip::Formats::Tar+.
7
7
  class TarHandler
8
8
  def create(path, &block)
9
- Omnizip::Formats::Tar.create(path, &block)
9
+ Omnizip::Formats::Tar.create(path) do |writer|
10
+ block&.call(EntryProxy.new(writer))
11
+ end
10
12
  end
11
13
 
12
14
  def open(path, &block)
@@ -34,6 +36,22 @@ module Omnizip
34
36
  end
35
37
  end
36
38
 
39
+ # Translates the generic +add(name, source_path)+ interface:
40
+ # a bare +add(name)+ is a directory ENTRY (no source on disk
41
+ # relative to the caller), which the Tar writer's own +add+
42
+ # would misread as a CWD-relative path.
43
+ class EntryProxy
44
+ def initialize(writer)
45
+ @writer = writer
46
+ end
47
+
48
+ def add(name, source_path = nil)
49
+ return @writer.add_directory(name) if source_path.nil?
50
+
51
+ @writer.add(name, source_path)
52
+ end
53
+ end
54
+
37
55
  def read_entry(path, entry_name)
38
56
  data = nil
39
57
  Omnizip::Formats::Tar.open(path) do |reader|
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Omnizip
4
- VERSION = "0.3.33"
4
+ VERSION = "0.3.35"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnizip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.33
4
+ version: 0.3.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.