minitar 1.1.1 → 1.2.0
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 +4 -4
- data/CHANGELOG.md +14 -5
- data/lib/minitar/reader.rb +16 -4
- data/lib/minitar/version.rb +1 -1
- data/test/test_tar_reader.rb +17 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4d63d57bffbc9767103b43d388bc963d21328b552fc8d24931cc3a038dfd3711
|
|
4
|
+
data.tar.gz: '0853ab22f6156d7b7ff8a0f3c1eb2751471937b2afc61a722114a9f950297ebc'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c3f0aa730db48594ec62b100f48cc76915fcabe72a0bfd52d9c10d27f82360d1913e604e06d330cf9d0704568812eea2d26b23332c56b7ebe6ffedba7c1cad11
|
|
7
|
+
data.tar.gz: 2b3a18c4c3ca23ddef71bdfd97cdf67a4e3ce03bae23f81389c247b0b1ed4e64e1863dba73a8739ec7e16687f82f78ec1ddf62114d44750e897747cddca4b050
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.2.0 / 2026-11-11
|
|
4
|
+
|
|
5
|
+
- Enhancements:
|
|
6
|
+
|
|
7
|
+
- Richard Degenne extended `Minitar::Reader::EntryStream#read` to accept a
|
|
8
|
+
second parameter, `out_string`, where the data read from the stream will
|
|
9
|
+
be read. [#166][pull-166]
|
|
10
|
+
|
|
11
|
+
- Documentation:
|
|
12
|
+
|
|
13
|
+
- Removed duplicate documentation files and updated the RDoc to match the
|
|
14
|
+
configuration.
|
|
15
|
+
|
|
3
16
|
## 1.1.1 / 2026-11-11
|
|
4
17
|
|
|
5
18
|
- Security:
|
|
@@ -33,11 +46,6 @@
|
|
|
33
46
|
Names such as `dirname../file` were previously rejected incorrectly on all
|
|
34
47
|
platforms.
|
|
35
48
|
|
|
36
|
-
- Documentation:
|
|
37
|
-
|
|
38
|
-
- Removed duplicate documentation files and updated the RDoc to match the
|
|
39
|
-
configuration.
|
|
40
|
-
|
|
41
49
|
## 1.1.0 / 2025-09-07
|
|
42
50
|
|
|
43
51
|
- Enhancements:
|
|
@@ -323,4 +331,5 @@
|
|
|
323
331
|
[pull-43]: https://github.com/halostatue/minitar/pull/43
|
|
324
332
|
[pull-47]: https://github.com/halostatue/minitar/pull/47
|
|
325
333
|
[pull-121]: https://github.com/halostatue/minitar/pull/121
|
|
334
|
+
[pull-166]: https://github.com/halostatue/minitar/pull/166
|
|
326
335
|
[tidelift]: https://tidelift.com/security
|
data/lib/minitar/reader.rb
CHANGED
|
@@ -51,13 +51,25 @@ class Minitar::Reader
|
|
|
51
51
|
end
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
# Reads `len` bytes (or all remaining data) from the entry.
|
|
55
|
-
# is
|
|
56
|
-
|
|
54
|
+
# Reads `len` bytes (or all remaining data) from the entry. If `out_string`
|
|
55
|
+
# is provided, the read data is stored there instead of allocating a new
|
|
56
|
+
# string. Returns `nil` if there is no more data to read.
|
|
57
|
+
def read(len = nil, out_string = nil)
|
|
57
58
|
return nil if @read >= @size
|
|
58
59
|
len ||= @size - @read
|
|
59
60
|
max_read = [len, @size - @read].min
|
|
60
|
-
|
|
61
|
+
|
|
62
|
+
ret =
|
|
63
|
+
if out_string
|
|
64
|
+
begin
|
|
65
|
+
@io.read(max_read, out_string)
|
|
66
|
+
rescue ArgumentError # If `@io` does not support `out_string`
|
|
67
|
+
out_string.replace(@io.read(max_read))
|
|
68
|
+
end
|
|
69
|
+
else
|
|
70
|
+
@io.read(max_read)
|
|
71
|
+
end
|
|
72
|
+
|
|
61
73
|
@read += ret.bytesize
|
|
62
74
|
ret
|
|
63
75
|
end
|
data/lib/minitar/version.rb
CHANGED
data/test/test_tar_reader.rb
CHANGED
|
@@ -28,7 +28,7 @@ class TestTarReader < Minitest::Test
|
|
|
28
28
|
sizes = [10, 0, 0, 0]
|
|
29
29
|
isdir = [false, false, true, true]
|
|
30
30
|
isfile = [true, true, false, false]
|
|
31
|
-
Minitar::Reader.
|
|
31
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
32
32
|
i = 0
|
|
33
33
|
is.each_entry do |entry|
|
|
34
34
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
@@ -54,7 +54,7 @@ class TestTarReader < Minitest::Test
|
|
|
54
54
|
str = build_tar_file_header("lib/foo", "", 0o10644, content.bytesize) +
|
|
55
55
|
content + "\0" * (512 - content.bytesize)
|
|
56
56
|
str << "\0" * 1024
|
|
57
|
-
Minitar::Reader.
|
|
57
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
58
58
|
is.each_entry do |entry|
|
|
59
59
|
3.times do
|
|
60
60
|
entry.rewind
|
|
@@ -70,7 +70,7 @@ class TestTarReader < Minitest::Test
|
|
|
70
70
|
str = build_tar_file_header("lib/foo", "", 0o10644, content.bytesize) +
|
|
71
71
|
content + "\0" * (512 - content.bytesize)
|
|
72
72
|
str << "\0" * 1024
|
|
73
|
-
Minitar::Reader.
|
|
73
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
74
74
|
3.times do
|
|
75
75
|
is.rewind
|
|
76
76
|
i = 0
|
|
@@ -87,7 +87,7 @@ class TestTarReader < Minitest::Test
|
|
|
87
87
|
contents = ("a".."z").inject(+"") { |a, e| a << e * 100 }
|
|
88
88
|
str = build_tar_file_header("lib/foo", "", 0o10644, contents.bytesize) + contents
|
|
89
89
|
str += "\0" * (512 - (str.bytesize % 512))
|
|
90
|
-
Minitar::Reader.
|
|
90
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
91
91
|
is.each_entry do |entry|
|
|
92
92
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
93
93
|
data = entry.read(3000) # bigger than contents.bytesize
|
|
@@ -95,7 +95,7 @@ class TestTarReader < Minitest::Test
|
|
|
95
95
|
assert entry.eof?
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
|
-
Minitar::Reader.
|
|
98
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
99
99
|
is.each_entry do |entry|
|
|
100
100
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
101
101
|
data = entry.read(100)
|
|
@@ -105,7 +105,7 @@ class TestTarReader < Minitest::Test
|
|
|
105
105
|
assert entry.eof?
|
|
106
106
|
end
|
|
107
107
|
end
|
|
108
|
-
Minitar::Reader.
|
|
108
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
109
109
|
is.each_entry do |entry|
|
|
110
110
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
111
111
|
data = entry.read
|
|
@@ -116,11 +116,19 @@ class TestTarReader < Minitest::Test
|
|
|
116
116
|
assert entry.eof?
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
120
|
+
is.each_entry do |entry|
|
|
121
|
+
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
122
|
+
buffer = +""
|
|
123
|
+
entry.read(nil, buffer)
|
|
124
|
+
assert_equal contents, buffer
|
|
125
|
+
end
|
|
126
|
+
end
|
|
119
127
|
end
|
|
120
128
|
|
|
121
129
|
def test_eof_works
|
|
122
130
|
str = build_tar_file_header("bar", "baz", 0o644, 0)
|
|
123
|
-
Minitar::Reader.
|
|
131
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
124
132
|
is.each_entry do |entry|
|
|
125
133
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
126
134
|
data = entry.read
|
|
@@ -132,7 +140,7 @@ class TestTarReader < Minitest::Test
|
|
|
132
140
|
end
|
|
133
141
|
end
|
|
134
142
|
str = build_tar_dir_header("foo", "bar", 0o12345)
|
|
135
|
-
Minitar::Reader.
|
|
143
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
136
144
|
is.each_entry do |entry|
|
|
137
145
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
138
146
|
data = entry.read
|
|
@@ -146,7 +154,7 @@ class TestTarReader < Minitest::Test
|
|
|
146
154
|
str = build_tar_dir_header("foo", "bar", 0o12345)
|
|
147
155
|
str += build_tar_file_header("bar", "baz", 0o644, 0)
|
|
148
156
|
str += build_tar_file_header("bar", "baz", 0o644, 0)
|
|
149
|
-
Minitar::Reader.
|
|
157
|
+
Minitar::Reader.open(StringIO.new(str)) do |is|
|
|
150
158
|
is.each_entry do |entry|
|
|
151
159
|
assert_kind_of Minitar::Reader::EntryStream, entry
|
|
152
160
|
data = entry.read
|