ruby-lzws 1.3.0 → 1.3.1
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/README.md +35 -14
- data/ext/extconf.rb +1 -1
- data/ext/lzws_ext/error.c +11 -11
- data/lib/lzws/file.rb +2 -2
- data/lib/lzws/option.rb +10 -4
- data/lib/lzws/stream/abstract.rb +5 -3
- data/lib/lzws/stream/reader.rb +3 -2
- data/lib/lzws/stream/reader_helpers.rb +1 -1
- data/lib/lzws/validation.rb +3 -1
- data/lib/lzws/version.rb +1 -1
- metadata +55 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72fd9e1b55088bd5ba7a6d57edc857322ede1d9764b6b2eb3aeafe85193605ad
|
4
|
+
data.tar.gz: 2f08eb4371bef83f138233ab62a5a54b5fa01f5a2904d6d1f64ee00fb9aebd1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: beff1dd2f2016bb9660f26bd62f3eaf1fdab8af9e70c24a65bfda4090190c4c02ef66ff943346b9483f5b588ceff6b5964f33d32dfc15e017b3e7964877ce7f9
|
7
|
+
data.tar.gz: a5c0074902b21193725bb0f215cef8ebaad55b3a029e20d0d0b54c0382e527a86c3460feca7a36ed7754b96254497eacb4a08900a425c7bfda70fa44153e60b6
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# Ruby bindings for lzws library
|
2
2
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
| [](https://ci.appveyor.com/project/andrew-aladev/ruby-lzws/branch/master) | [](https://circleci.com/gh/andrew-aladev/ruby-lzws/tree/master) | [](https://github.com/andrew-aladev/ruby-lzws/actions) | [](https://codecov.io/gh/andrew-aladev/ruby-lzws) | [](https://rubygems.org/gems/ruby-lzws) |
|
6
6
|
|
7
7
|
See [lzws library](https://github.com/andrew-aladev/lzws).
|
8
8
|
|
@@ -61,7 +61,7 @@ ensure
|
|
61
61
|
end
|
62
62
|
```
|
63
63
|
|
64
|
-
You can create and read `tar.Z` archives with [minitar](https://github.com/halostatue/minitar)
|
64
|
+
You can create and read `tar.Z` archives with [minitar](https://github.com/halostatue/minitar).
|
65
65
|
LZWS is compatible with [UNIX compress](https://en.wikipedia.org/wiki/Compress) (with default options).
|
66
66
|
|
67
67
|
```ruby
|
@@ -96,6 +96,18 @@ get "/" do
|
|
96
96
|
end
|
97
97
|
```
|
98
98
|
|
99
|
+
All functionality (including streaming) can be used inside multiple threads with [parallel](https://github.com/grosser/parallel).
|
100
|
+
This code will provide heavy load for your CPU.
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
require "lzws"
|
104
|
+
require "parallel"
|
105
|
+
|
106
|
+
Parallel.each large_datas do |large_data|
|
107
|
+
LZWS::String.compress large_data
|
108
|
+
end
|
109
|
+
```
|
110
|
+
|
99
111
|
## Options
|
100
112
|
|
101
113
|
| Option | Values | Default | Description |
|
@@ -183,7 +195,7 @@ File maintains both source and destination buffers, it accepts both `source_buff
|
|
183
195
|
|
184
196
|
## Stream::Writer
|
185
197
|
|
186
|
-
Its behaviour is similar to builtin [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib
|
198
|
+
Its behaviour is similar to builtin [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib/libdoc/zlib/rdoc/Zlib/GzipWriter.html).
|
187
199
|
|
188
200
|
Writer maintains destination buffer only, so it accepts `destination_buffer_length` option only.
|
189
201
|
|
@@ -217,7 +229,7 @@ Set another encodings, `nil` is just for compatibility with `IO`.
|
|
217
229
|
#tell
|
218
230
|
```
|
219
231
|
|
220
|
-
See [`IO`](https://ruby-doc.org/core
|
232
|
+
See [`IO`](https://ruby-doc.org/core/IO.html) docs.
|
221
233
|
|
222
234
|
```
|
223
235
|
#write(*objects)
|
@@ -227,7 +239,7 @@ See [`IO`](https://ruby-doc.org/core-2.7.0/IO.html) docs.
|
|
227
239
|
#closed?
|
228
240
|
```
|
229
241
|
|
230
|
-
See [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib
|
242
|
+
See [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib/libdoc/zlib/rdoc/Zlib/GzipWriter.html) docs.
|
231
243
|
|
232
244
|
```
|
233
245
|
#write_nonblock(object, *options)
|
@@ -241,6 +253,9 @@ Special asynchronous methods missing in `Zlib::GzipWriter`.
|
|
241
253
|
So it is possible to have asynchronous variants for these synchronous methods.
|
242
254
|
Behaviour is the same as `IO#write_nonblock` method.
|
243
255
|
|
256
|
+
All nonblock operations for file will raise `EBADF` error on Windows.
|
257
|
+
Setting file into nonblocking mode is [not available on Windows](https://github.com/ruby/ruby/blob/master/win32/win32.c#L4388).
|
258
|
+
|
244
259
|
```
|
245
260
|
#<<(object)
|
246
261
|
#print(*objects)
|
@@ -249,11 +264,11 @@ Behaviour is the same as `IO#write_nonblock` method.
|
|
249
264
|
#puts(*objects)
|
250
265
|
```
|
251
266
|
|
252
|
-
Typical helpers, see [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib
|
267
|
+
Typical helpers, see [`Zlib::GzipWriter`](https://ruby-doc.org/stdlib/libdoc/zlib/rdoc/Zlib/GzipWriter.html) docs.
|
253
268
|
|
254
269
|
## Stream::Reader
|
255
270
|
|
256
|
-
Its behaviour is similar to builtin [`Zlib::GzipReader`](https://ruby-doc.org/stdlib
|
271
|
+
Its behaviour is similar to builtin [`Zlib::GzipReader`](https://ruby-doc.org/stdlib/libdoc/zlib/rdoc/Zlib/GzipReader.html).
|
257
272
|
|
258
273
|
Reader maintains both source and destination buffers, it accepts both `source_buffer_length` and `destination_buffer_length` options.
|
259
274
|
|
@@ -288,7 +303,7 @@ Set another encodings.
|
|
288
303
|
#tell
|
289
304
|
```
|
290
305
|
|
291
|
-
See [`IO`](https://ruby-doc.org/core
|
306
|
+
See [`IO`](https://ruby-doc.org/core/IO.html) docs.
|
292
307
|
|
293
308
|
```
|
294
309
|
#read(bytes_to_read = nil, out_buffer = nil)
|
@@ -298,14 +313,14 @@ See [`IO`](https://ruby-doc.org/core-2.7.0/IO.html) docs.
|
|
298
313
|
#closed?
|
299
314
|
```
|
300
315
|
|
301
|
-
See [`Zlib::GzipReader`](https://ruby-doc.org/stdlib
|
316
|
+
See [`Zlib::GzipReader`](https://ruby-doc.org/stdlib/libdoc/zlib/rdoc/Zlib/GzipReader.html) docs.
|
302
317
|
|
303
318
|
```
|
304
319
|
#readpartial(bytes_to_read = nil, out_buffer = nil)
|
305
320
|
#read_nonblock(bytes_to_read, out_buffer = nil, *options)
|
306
321
|
```
|
307
322
|
|
308
|
-
See [`IO`](https://ruby-doc.org/core
|
323
|
+
See [`IO`](https://ruby-doc.org/core/IO.html) docs.
|
309
324
|
|
310
325
|
```
|
311
326
|
#getbyte
|
@@ -328,7 +343,7 @@ See [`IO`](https://ruby-doc.org/core-2.7.0/IO.html) docs.
|
|
328
343
|
#ungetline(line)
|
329
344
|
```
|
330
345
|
|
331
|
-
Typical helpers, see [`Zlib::GzipReader`](https://ruby-doc.org/stdlib
|
346
|
+
Typical helpers, see [`Zlib::GzipReader`](https://ruby-doc.org/stdlib/libdoc/zlib/rdoc/Zlib/GzipReader.html) docs.
|
332
347
|
|
333
348
|
## Thread safety
|
334
349
|
|
@@ -336,11 +351,17 @@ Typical helpers, see [`Zlib::GzipReader`](https://ruby-doc.org/stdlib-2.7.0/libd
|
|
336
351
|
Please be careful: bindings are not thread safe.
|
337
352
|
You should lock all shared data between threads.
|
338
353
|
|
354
|
+
For example: you should not use same compressor/decompressor inside multiple threads.
|
355
|
+
Please verify that you are using each processor inside single thread at the same time.
|
356
|
+
|
357
|
+
## Operating systems
|
358
|
+
|
359
|
+
GNU/Linux, FreeBSD, OSX, Windows (MinGW).
|
360
|
+
|
339
361
|
## CI
|
340
362
|
|
341
363
|
Please visit [scripts/test-images](scripts/test-images).
|
342
364
|
See universal test script [scripts/ci_test.sh](scripts/ci_test.sh) for CI.
|
343
|
-
You can run this script using many native and cross images.
|
344
365
|
|
345
366
|
## License
|
346
367
|
|
data/ext/extconf.rb
CHANGED
data/ext/lzws_ext/error.c
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
#include "ruby.h"
|
7
7
|
|
8
|
-
static inline NORETURN(void
|
8
|
+
static inline NORETURN(void raise_error(const char* name, const char* description))
|
9
9
|
{
|
10
10
|
VALUE module = rb_define_module(LZWS_EXT_MODULE_NAME);
|
11
11
|
VALUE error = rb_const_get(module, rb_intern(name));
|
@@ -16,28 +16,28 @@ void lzws_ext_raise_error(lzws_ext_result_t ext_result)
|
|
16
16
|
{
|
17
17
|
switch (ext_result) {
|
18
18
|
case LZWS_EXT_ERROR_ALLOCATE_FAILED:
|
19
|
-
|
19
|
+
raise_error("AllocateError", "allocate error");
|
20
20
|
case LZWS_EXT_ERROR_VALIDATE_FAILED:
|
21
|
-
|
21
|
+
raise_error("ValidateError", "validate error");
|
22
22
|
|
23
23
|
case LZWS_EXT_ERROR_USED_AFTER_CLOSE:
|
24
|
-
|
24
|
+
raise_error("UsedAfterCloseError", "used after closed");
|
25
25
|
case LZWS_EXT_ERROR_NOT_ENOUGH_SOURCE_BUFFER:
|
26
|
-
|
26
|
+
raise_error("NotEnoughSourceBufferError", "not enough source buffer");
|
27
27
|
case LZWS_EXT_ERROR_NOT_ENOUGH_DESTINATION_BUFFER:
|
28
|
-
|
28
|
+
raise_error("NotEnoughDestinationBufferError", "not enough destination buffer");
|
29
29
|
case LZWS_EXT_ERROR_DECOMPRESSOR_CORRUPTED_SOURCE:
|
30
|
-
|
30
|
+
raise_error("DecompressorCorruptedSourceError", "decompressor received corrupted source");
|
31
31
|
|
32
32
|
case LZWS_EXT_ERROR_ACCESS_IO:
|
33
|
-
|
33
|
+
raise_error("AccessIOError", "failed to access IO");
|
34
34
|
case LZWS_EXT_ERROR_READ_IO:
|
35
|
-
|
35
|
+
raise_error("ReadIOError", "failed to read IO");
|
36
36
|
case LZWS_EXT_ERROR_WRITE_IO:
|
37
|
-
|
37
|
+
raise_error("WriteIOError", "failed to write IO");
|
38
38
|
|
39
39
|
default:
|
40
40
|
// LZWS_EXT_ERROR_UNEXPECTED
|
41
|
-
|
41
|
+
raise_error("UnexpectedError", "unexpected error");
|
42
42
|
}
|
43
43
|
}
|
data/lib/lzws/file.rb
CHANGED
@@ -17,7 +17,7 @@ module LZWS
|
|
17
17
|
|
18
18
|
options = Option.get_compressor_options options, BUFFER_LENGTH_NAMES
|
19
19
|
|
20
|
-
open_files
|
20
|
+
open_files source, destination do |source_io, destination_io|
|
21
21
|
LZWS._native_compress_io source_io, destination_io, options
|
22
22
|
end
|
23
23
|
|
@@ -30,7 +30,7 @@ module LZWS
|
|
30
30
|
|
31
31
|
options = Option.get_decompressor_options options, BUFFER_LENGTH_NAMES
|
32
32
|
|
33
|
-
open_files
|
33
|
+
open_files source, destination do |source_io, destination_io|
|
34
34
|
LZWS._native_decompress_io source_io, destination_io, options
|
35
35
|
end
|
36
36
|
|
data/lib/lzws/option.rb
CHANGED
@@ -33,8 +33,11 @@ module LZWS
|
|
33
33
|
def self.get_compressor_options(options, buffer_length_names)
|
34
34
|
Validation.validate_hash options
|
35
35
|
|
36
|
-
buffer_length_defaults = buffer_length_names.each_with_object({})
|
37
|
-
|
36
|
+
buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults|
|
37
|
+
defaults[name] = DEFAULT_BUFFER_LENGTH
|
38
|
+
end
|
39
|
+
|
40
|
+
options = COMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
|
38
41
|
|
39
42
|
buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
|
40
43
|
|
@@ -68,8 +71,11 @@ module LZWS
|
|
68
71
|
def self.get_decompressor_options(options, buffer_length_names)
|
69
72
|
Validation.validate_hash options
|
70
73
|
|
71
|
-
buffer_length_defaults = buffer_length_names.each_with_object({})
|
72
|
-
|
74
|
+
buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults|
|
75
|
+
defaults[name] = DEFAULT_BUFFER_LENGTH
|
76
|
+
end
|
77
|
+
|
78
|
+
options = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
|
73
79
|
|
74
80
|
buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
|
75
81
|
|
data/lib/lzws/stream/abstract.rb
CHANGED
@@ -12,7 +12,8 @@ module LZWS
|
|
12
12
|
# Native stream is not seekable by design.
|
13
13
|
# Related methods like "seek" and "pos=" can't be implemented.
|
14
14
|
|
15
|
-
# It is not possible to maintain correspondance between bytes
|
15
|
+
# It is not possible to maintain correspondance between bytes
|
16
|
+
# consumed from source and bytes written to destination by design.
|
16
17
|
# We will consume all source bytes and maintain buffer with remaining destination data.
|
17
18
|
|
18
19
|
include Delegates
|
@@ -89,8 +90,9 @@ module LZWS
|
|
89
90
|
end
|
90
91
|
|
91
92
|
internal_encoding = args[1]
|
92
|
-
|
93
|
-
|
93
|
+
unless internal_encoding.nil? || internal_encoding.is_a?(::Encoding)
|
94
|
+
Validation.validate_string internal_encoding
|
95
|
+
end
|
94
96
|
|
95
97
|
transcode_options = args[2]
|
96
98
|
Validation.validate_hash transcode_options unless transcode_options.nil?
|
data/lib/lzws/stream/reader.rb
CHANGED
@@ -33,8 +33,9 @@ module LZWS
|
|
33
33
|
source_buffer_length = @options[:source_buffer_length]
|
34
34
|
Validation.validate_not_negative_integer source_buffer_length unless source_buffer_length.nil?
|
35
35
|
|
36
|
-
source_buffer_length
|
37
|
-
|
36
|
+
if source_buffer_length.nil? || source_buffer_length.zero?
|
37
|
+
source_buffer_length = Buffer::DEFAULT_SOURCE_BUFFER_LENGTH_FOR_DECOMPRESSOR
|
38
|
+
end
|
38
39
|
|
39
40
|
@source_buffer_length = source_buffer_length
|
40
41
|
end
|
data/lib/lzws/validation.rb
CHANGED
@@ -43,7 +43,9 @@ module LZWS
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def self.validate_proc(value)
|
46
|
-
|
46
|
+
unless value.is_a?(::Proc) || value.is_a?(::Method) || value.is_a?(::UnboundMethod)
|
47
|
+
raise ValidateError, "invalid proc"
|
48
|
+
end
|
47
49
|
end
|
48
50
|
end
|
49
51
|
end
|
data/lib/lzws/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-lzws
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Aladjev
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: codecov
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: minitar
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +72,14 @@ dependencies:
|
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
75
|
+
version: '1.3'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
82
|
+
version: '1.3'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: parallel
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,28 +128,56 @@ dependencies:
|
|
114
128
|
requirements:
|
115
129
|
- - "~>"
|
116
130
|
- !ruby/object:Gem::Version
|
117
|
-
version: '
|
131
|
+
version: '1.16'
|
118
132
|
type: :development
|
119
133
|
prerelease: false
|
120
134
|
version_requirements: !ruby/object:Gem::Requirement
|
121
135
|
requirements:
|
122
136
|
- - "~>"
|
123
137
|
- !ruby/object:Gem::Version
|
124
|
-
version: '
|
138
|
+
version: '1.16'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rubocop-minitest
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0.12'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0.12'
|
125
153
|
- !ruby/object:Gem::Dependency
|
126
154
|
name: rubocop-performance
|
127
155
|
requirement: !ruby/object:Gem::Requirement
|
128
156
|
requirements:
|
129
157
|
- - "~>"
|
130
158
|
- !ruby/object:Gem::Version
|
131
|
-
version: '1.
|
159
|
+
version: '1.11'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '1.11'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop-rake
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.5'
|
132
174
|
type: :development
|
133
175
|
prerelease: false
|
134
176
|
version_requirements: !ruby/object:Gem::Requirement
|
135
177
|
requirements:
|
136
178
|
- - "~>"
|
137
179
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
180
|
+
version: '0.5'
|
139
181
|
- !ruby/object:Gem::Dependency
|
140
182
|
name: simplecov
|
141
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,7 +192,7 @@ dependencies:
|
|
150
192
|
- - ">="
|
151
193
|
- !ruby/object:Gem::Version
|
152
194
|
version: '0'
|
153
|
-
description:
|
195
|
+
description:
|
154
196
|
email: aladjev.andrew@gmail.com
|
155
197
|
executables: []
|
156
198
|
extensions:
|
@@ -200,7 +242,7 @@ homepage: https://github.com/andrew-aladev/ruby-lzws
|
|
200
242
|
licenses:
|
201
243
|
- MIT
|
202
244
|
metadata: {}
|
203
|
-
post_install_message:
|
245
|
+
post_install_message:
|
204
246
|
rdoc_options: []
|
205
247
|
require_paths:
|
206
248
|
- lib
|
@@ -215,8 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
215
257
|
- !ruby/object:Gem::Version
|
216
258
|
version: '0'
|
217
259
|
requirements: []
|
218
|
-
rubygems_version: 3.
|
219
|
-
signing_key:
|
260
|
+
rubygems_version: 3.2.15
|
261
|
+
signing_key:
|
220
262
|
specification_version: 4
|
221
263
|
summary: Ruby bindings for lzws library (compatible with UNIX compress).
|
222
264
|
test_files: []
|