ruby-lzws 1.4.1 → 1.4.2
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 +3 -5
- data/ext/lzws_ext/gvl.h +2 -2
- data/ext/lzws_ext/macro.h +1 -1
- data/lib/lzws/stream/abstract.rb +9 -5
- data/lib/lzws/stream/reader.rb +9 -0
- data/lib/lzws/stream/writer.rb +26 -2
- data/lib/lzws/validation.rb +8 -25
- data/lib/lzws/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0e48df46a2a929a961d72881cf20a4c087769576f3208cc2dee02a31b3d1f00a
|
|
4
|
+
data.tar.gz: f5fe984d47acaa03d91ca5f7d19a5e87c49b029aea37323fbd2e2c72a5f57491
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3ea80697e381e1a350bb49c0c267791b41783e09ccfca10348ae1c02afa090de7930d06f1a2ca8fd6ff81929f86f34ff6bf46d9b51ac83fe4dc09c558227385c
|
|
7
|
+
data.tar.gz: 7c6843ea9729056bea5bd149b31d25409e9f5d225b43e12f6305353bf5a4b820eb94104e192d02dda454cccc0adf684e17dc953719184a7b5a846570f9575225
|
data/README.md
CHANGED
|
@@ -8,7 +8,9 @@ See [lzws library](https://github.com/andrew-aladev/lzws).
|
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
Operating systems: GNU/Linux, FreeBSD, OSX, Windows (MinGW).
|
|
12
|
+
|
|
13
|
+
Dependencies: [lzws](https://github.com/andrew-aladev/lzws) 1.4.0+ version.
|
|
12
14
|
|
|
13
15
|
```sh
|
|
14
16
|
gem install ruby-lzws
|
|
@@ -354,10 +356,6 @@ You should lock all shared data between threads.
|
|
|
354
356
|
For example: you should not use same compressor/decompressor inside multiple threads.
|
|
355
357
|
Please verify that you are using each processor inside single thread at the same time.
|
|
356
358
|
|
|
357
|
-
## Operating systems
|
|
358
|
-
|
|
359
|
-
GNU/Linux, FreeBSD, OSX, Windows (MinGW).
|
|
360
|
-
|
|
361
359
|
## CI
|
|
362
360
|
|
|
363
361
|
Please visit [scripts/test-images](scripts/test-images).
|
data/ext/lzws_ext/gvl.h
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
#if !defined(LZWS_EXT_GVL_H)
|
|
5
5
|
#define LZWS_EXT_GVL_H
|
|
6
6
|
|
|
7
|
-
#
|
|
7
|
+
#if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
|
|
8
8
|
|
|
9
9
|
#include "ruby/thread.h"
|
|
10
10
|
|
|
@@ -19,6 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
#define LZWS_EXT_GVL_WRAP(_gvl, function, data) function((void*) data);
|
|
21
21
|
|
|
22
|
-
#endif
|
|
22
|
+
#endif // HAVE_RB_THREAD_CALL_WITHOUT_GVL
|
|
23
23
|
|
|
24
24
|
#endif // LZWS_EXT_GVL_H
|
data/ext/lzws_ext/macro.h
CHANGED
data/lib/lzws/stream/abstract.rb
CHANGED
|
@@ -24,9 +24,7 @@ module LZWS
|
|
|
24
24
|
|
|
25
25
|
def initialize(io, options = {})
|
|
26
26
|
@raw_stream = create_raw_stream
|
|
27
|
-
|
|
28
|
-
Validation.validate_io io
|
|
29
|
-
@io = io
|
|
27
|
+
@io = io
|
|
30
28
|
|
|
31
29
|
@stat = Stat.new @io.stat if @io.respond_to? :stat
|
|
32
30
|
|
|
@@ -135,13 +133,19 @@ module LZWS
|
|
|
135
133
|
end
|
|
136
134
|
|
|
137
135
|
def close
|
|
138
|
-
@io.close
|
|
136
|
+
@io.close if @io.respond_to? :close
|
|
139
137
|
|
|
140
138
|
nil
|
|
141
139
|
end
|
|
142
140
|
|
|
143
141
|
def closed?
|
|
144
|
-
|
|
142
|
+
return false unless @raw_stream.closed?
|
|
143
|
+
|
|
144
|
+
if @io.respond_to? :closed
|
|
145
|
+
@io.closed?
|
|
146
|
+
else
|
|
147
|
+
true
|
|
148
|
+
end
|
|
145
149
|
end
|
|
146
150
|
|
|
147
151
|
def to_io
|
data/lib/lzws/stream/reader.rb
CHANGED
|
@@ -54,6 +54,9 @@ module LZWS
|
|
|
54
54
|
Validation.validate_not_negative_integer bytes_to_read unless bytes_to_read.nil?
|
|
55
55
|
Validation.validate_string out_buffer unless out_buffer.nil?
|
|
56
56
|
|
|
57
|
+
raise ValidateError, "io should be responsible to read and eof" unless
|
|
58
|
+
@io.respond_to?(:read) && @io.respond_to?(:eof?)
|
|
59
|
+
|
|
57
60
|
unless bytes_to_read.nil?
|
|
58
61
|
return ::String.new :encoding => ::Encoding::BINARY if bytes_to_read.zero?
|
|
59
62
|
return nil if eof?
|
|
@@ -86,16 +89,22 @@ module LZWS
|
|
|
86
89
|
end
|
|
87
90
|
|
|
88
91
|
def eof?
|
|
92
|
+
raise ValidateError, "io should be responsible to eof" unless @io.respond_to? :eof?
|
|
93
|
+
|
|
89
94
|
empty? && @io.eof?
|
|
90
95
|
end
|
|
91
96
|
|
|
92
97
|
# -- asynchronous --
|
|
93
98
|
|
|
94
99
|
def readpartial(bytes_to_read, out_buffer = nil)
|
|
100
|
+
raise ValidateError, "io should be responsible to readpartial" unless @io.respond_to? :readpartial
|
|
101
|
+
|
|
95
102
|
read_more_nonblock(bytes_to_read, out_buffer) { @io.readpartial @source_buffer_length }
|
|
96
103
|
end
|
|
97
104
|
|
|
98
105
|
def read_nonblock(bytes_to_read, out_buffer = nil, *options)
|
|
106
|
+
raise ValidateError, "io should be responsible to read nonblock" unless @io.respond_to? :read_nonblock
|
|
107
|
+
|
|
99
108
|
read_more_nonblock(bytes_to_read, out_buffer) { @io.read_nonblock(@source_buffer_length, *options) }
|
|
100
109
|
end
|
|
101
110
|
|
data/lib/lzws/stream/writer.rb
CHANGED
|
@@ -23,6 +23,8 @@ module LZWS
|
|
|
23
23
|
# -- synchronous --
|
|
24
24
|
|
|
25
25
|
def write(*objects)
|
|
26
|
+
validate_write
|
|
27
|
+
|
|
26
28
|
write_remaining_buffer
|
|
27
29
|
|
|
28
30
|
bytes_written = 0
|
|
@@ -38,20 +40,26 @@ module LZWS
|
|
|
38
40
|
end
|
|
39
41
|
|
|
40
42
|
def flush
|
|
43
|
+
validate_write
|
|
44
|
+
|
|
41
45
|
finish :flush
|
|
42
46
|
|
|
43
|
-
@io.flush
|
|
47
|
+
@io.flush if @io.respond_to? :flush
|
|
44
48
|
|
|
45
49
|
self
|
|
46
50
|
end
|
|
47
51
|
|
|
48
52
|
def rewind
|
|
53
|
+
validate_write
|
|
54
|
+
|
|
49
55
|
finish :close
|
|
50
56
|
|
|
51
57
|
super
|
|
52
58
|
end
|
|
53
59
|
|
|
54
60
|
def close
|
|
61
|
+
validate_write
|
|
62
|
+
|
|
55
63
|
finish :close
|
|
56
64
|
|
|
57
65
|
super
|
|
@@ -75,6 +83,10 @@ module LZWS
|
|
|
75
83
|
@raw_stream.send(method_name, *args) { |portion| @io.write portion }
|
|
76
84
|
end
|
|
77
85
|
|
|
86
|
+
def validate_write
|
|
87
|
+
raise ValidateError, "io should be responsible to write" unless @io.respond_to? :write
|
|
88
|
+
end
|
|
89
|
+
|
|
78
90
|
# -- asynchronous --
|
|
79
91
|
|
|
80
92
|
# IO write nonblock can raise wait writable error.
|
|
@@ -83,6 +95,8 @@ module LZWS
|
|
|
83
95
|
# So we have to accept content after processing IO write nonblock.
|
|
84
96
|
# It means that first write nonblock won't call IO write nonblock.
|
|
85
97
|
def write_nonblock(object, *options)
|
|
98
|
+
validate_write_nonblock
|
|
99
|
+
|
|
86
100
|
return 0 unless write_remaining_buffer_nonblock(*options)
|
|
87
101
|
|
|
88
102
|
source = transcode object.to_s
|
|
@@ -93,14 +107,18 @@ module LZWS
|
|
|
93
107
|
end
|
|
94
108
|
|
|
95
109
|
def flush_nonblock(*options)
|
|
110
|
+
validate_write_nonblock
|
|
111
|
+
|
|
96
112
|
return false unless finish_nonblock :flush, *options
|
|
97
113
|
|
|
98
|
-
@io.flush
|
|
114
|
+
@io.flush if @io.respond_to? :flush
|
|
99
115
|
|
|
100
116
|
true
|
|
101
117
|
end
|
|
102
118
|
|
|
103
119
|
def rewind_nonblock(*options)
|
|
120
|
+
validate_write_nonblock
|
|
121
|
+
|
|
104
122
|
return false unless finish_nonblock :close, *options
|
|
105
123
|
|
|
106
124
|
method(:rewind).super_method.call
|
|
@@ -109,6 +127,8 @@ module LZWS
|
|
|
109
127
|
end
|
|
110
128
|
|
|
111
129
|
def close_nonblock(*options)
|
|
130
|
+
validate_write_nonblock
|
|
131
|
+
|
|
112
132
|
return false unless finish_nonblock :close, *options
|
|
113
133
|
|
|
114
134
|
method(:close).super_method.call
|
|
@@ -139,6 +159,10 @@ module LZWS
|
|
|
139
159
|
@raw_stream.send(method_name, *args) { |portion| @buffer << portion }
|
|
140
160
|
end
|
|
141
161
|
|
|
162
|
+
def validate_write_nonblock
|
|
163
|
+
raise ValidateError, "io should be responsible to write nonblock" unless @io.respond_to? :write_nonblock
|
|
164
|
+
end
|
|
165
|
+
|
|
142
166
|
# -- common --
|
|
143
167
|
|
|
144
168
|
protected def transcode(data)
|
data/lib/lzws/validation.rb
CHANGED
|
@@ -5,41 +5,20 @@ require_relative "error"
|
|
|
5
5
|
|
|
6
6
|
module LZWS
|
|
7
7
|
module Validation
|
|
8
|
-
IO_METHODS = %i[
|
|
9
|
-
read
|
|
10
|
-
write
|
|
11
|
-
readpartial
|
|
12
|
-
read_nonblock
|
|
13
|
-
write_nonblock
|
|
14
|
-
eof?
|
|
15
|
-
flush
|
|
16
|
-
close
|
|
17
|
-
closed?
|
|
18
|
-
]
|
|
19
|
-
.freeze
|
|
20
|
-
|
|
21
8
|
def self.validate_bool(value)
|
|
22
9
|
raise ValidateError, "invalid bool" unless value.is_a?(::TrueClass) || value.is_a?(::FalseClass)
|
|
23
10
|
end
|
|
24
11
|
|
|
25
|
-
def self.
|
|
26
|
-
raise ValidateError, "invalid
|
|
12
|
+
def self.validate_hash(value)
|
|
13
|
+
raise ValidateError, "invalid hash" unless value.is_a? ::Hash
|
|
27
14
|
end
|
|
28
15
|
|
|
29
16
|
def self.validate_not_negative_integer(value)
|
|
30
17
|
raise ValidateError, "invalid not negative integer" unless value.is_a?(::Integer) && value >= 0
|
|
31
18
|
end
|
|
32
19
|
|
|
33
|
-
def self.
|
|
34
|
-
raise ValidateError, "invalid
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def self.validate_io(value)
|
|
38
|
-
raise ValidateError, "invalid io" unless IO_METHODS.all? { |method| value.respond_to? method }
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def self.validate_hash(value)
|
|
42
|
-
raise ValidateError, "invalid hash" unless value.is_a? ::Hash
|
|
20
|
+
def self.validate_positive_integer(value)
|
|
21
|
+
raise ValidateError, "invalid positive integer" unless value.is_a?(::Integer) && value.positive?
|
|
43
22
|
end
|
|
44
23
|
|
|
45
24
|
def self.validate_proc(value)
|
|
@@ -47,5 +26,9 @@ module LZWS
|
|
|
47
26
|
raise ValidateError, "invalid proc"
|
|
48
27
|
end
|
|
49
28
|
end
|
|
29
|
+
|
|
30
|
+
def self.validate_string(value)
|
|
31
|
+
raise ValidateError, "invalid string" unless value.is_a? ::String
|
|
32
|
+
end
|
|
50
33
|
end
|
|
51
34
|
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.4.
|
|
4
|
+
version: 1.4.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrew Aladjev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2022-
|
|
11
|
+
date: 2022-03-18 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: codecov
|
|
@@ -128,14 +128,14 @@ dependencies:
|
|
|
128
128
|
requirements:
|
|
129
129
|
- - "~>"
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version: '1.
|
|
131
|
+
version: '1.26'
|
|
132
132
|
type: :development
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - "~>"
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version: '1.
|
|
138
|
+
version: '1.26'
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: rubocop-minitest
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -258,7 +258,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
258
258
|
- !ruby/object:Gem::Version
|
|
259
259
|
version: '0'
|
|
260
260
|
requirements: []
|
|
261
|
-
rubygems_version: 3.3.
|
|
261
|
+
rubygems_version: 3.3.7
|
|
262
262
|
signing_key:
|
|
263
263
|
specification_version: 4
|
|
264
264
|
summary: Ruby bindings for lzws library (compatible with UNIX compress).
|