ruby-lzws 1.1.5 → 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 +75 -74
- data/ext/extconf.rb +12 -3
- data/ext/lzws_ext/buffer.c +21 -7
- data/ext/lzws_ext/buffer.h +5 -5
- data/ext/lzws_ext/error.c +11 -11
- data/ext/lzws_ext/error.h +2 -1
- data/ext/lzws_ext/gvl.h +24 -0
- data/ext/lzws_ext/io.c +83 -19
- data/ext/lzws_ext/main.c +2 -0
- data/ext/lzws_ext/option.c +46 -10
- data/ext/lzws_ext/option.h +30 -24
- data/ext/lzws_ext/stream/compressor.c +84 -40
- data/ext/lzws_ext/stream/compressor.h +4 -1
- data/ext/lzws_ext/stream/decompressor.c +56 -29
- data/ext/lzws_ext/stream/decompressor.h +4 -1
- data/ext/lzws_ext/string.c +159 -92
- data/lib/lzws/file.rb +2 -2
- data/lib/lzws/option.rb +60 -31
- 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 +74 -17
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
@@ -8,45 +8,62 @@ require_relative "validation"
|
|
8
8
|
|
9
9
|
module LZWS
|
10
10
|
module Option
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:quiet => false
|
11
|
+
DEFAULT_BUFFER_LENGTH = 0
|
12
|
+
|
13
|
+
COMPRESSOR_DEFAULTS = {
|
14
|
+
:gvl => false,
|
15
|
+
:max_code_bit_length => nil,
|
16
|
+
:without_magic_header => nil,
|
17
|
+
:block_mode => nil,
|
18
|
+
:msb => nil,
|
19
|
+
:unaligned_bit_groups => nil,
|
20
|
+
:quiet => nil
|
22
21
|
}
|
23
22
|
.freeze
|
24
23
|
|
25
|
-
|
26
|
-
:
|
27
|
-
:
|
28
|
-
|
24
|
+
DECOMPRESSOR_DEFAULTS = {
|
25
|
+
:gvl => false,
|
26
|
+
:without_magic_header => nil,
|
27
|
+
:msb => nil,
|
28
|
+
:unaligned_bit_groups => nil,
|
29
|
+
:quiet => nil
|
30
|
+
}
|
29
31
|
.freeze
|
30
32
|
|
31
33
|
def self.get_compressor_options(options, buffer_length_names)
|
32
34
|
Validation.validate_hash options
|
33
35
|
|
34
|
-
buffer_length_defaults = buffer_length_names.each_with_object({})
|
35
|
-
|
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
|
36
41
|
|
37
42
|
buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
|
38
43
|
|
44
|
+
Validation.validate_bool options[:gvl]
|
45
|
+
|
39
46
|
max_code_bit_length = options[:max_code_bit_length]
|
40
|
-
|
47
|
+
unless max_code_bit_length.nil?
|
48
|
+
Validation.validate_positive_integer max_code_bit_length
|
49
|
+
raise ValidateError, "invalid max code bit length" if
|
50
|
+
max_code_bit_length < LOWEST_MAX_CODE_BIT_LENGTH || max_code_bit_length > BIGGEST_MAX_CODE_BIT_LENGTH
|
51
|
+
end
|
52
|
+
|
53
|
+
without_magic_header = options[:without_magic_header]
|
54
|
+
Validation.validate_bool without_magic_header unless without_magic_header.nil?
|
41
55
|
|
42
|
-
|
43
|
-
|
56
|
+
block_mode = options[:block_mode]
|
57
|
+
Validation.validate_bool block_mode unless block_mode.nil?
|
44
58
|
|
45
|
-
|
46
|
-
Validation.validate_bool
|
47
|
-
|
48
|
-
|
49
|
-
Validation.validate_bool
|
59
|
+
msb = options[:msb]
|
60
|
+
Validation.validate_bool msb unless msb.nil?
|
61
|
+
|
62
|
+
unaligned_bit_groups = options[:unaligned_bit_groups]
|
63
|
+
Validation.validate_bool unaligned_bit_groups unless unaligned_bit_groups.nil?
|
64
|
+
|
65
|
+
quiet = options[:quiet]
|
66
|
+
Validation.validate_bool quiet unless quiet.nil?
|
50
67
|
|
51
68
|
options
|
52
69
|
end
|
@@ -54,15 +71,27 @@ module LZWS
|
|
54
71
|
def self.get_decompressor_options(options, buffer_length_names)
|
55
72
|
Validation.validate_hash options
|
56
73
|
|
57
|
-
buffer_length_defaults = buffer_length_names.each_with_object({})
|
58
|
-
|
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
|
59
79
|
|
60
80
|
buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
|
61
81
|
|
62
|
-
Validation.validate_bool options[:
|
63
|
-
|
64
|
-
|
65
|
-
Validation.validate_bool
|
82
|
+
Validation.validate_bool options[:gvl]
|
83
|
+
|
84
|
+
without_magic_header = options[:without_magic_header]
|
85
|
+
Validation.validate_bool without_magic_header unless without_magic_header.nil?
|
86
|
+
|
87
|
+
msb = options[:msb]
|
88
|
+
Validation.validate_bool msb unless msb.nil?
|
89
|
+
|
90
|
+
unaligned_bit_groups = options[:unaligned_bit_groups]
|
91
|
+
Validation.validate_bool unaligned_bit_groups unless unaligned_bit_groups.nil?
|
92
|
+
|
93
|
+
quiet = options[:quiet]
|
94
|
+
Validation.validate_bool quiet unless quiet.nil?
|
66
95
|
|
67
96
|
options
|
68
97
|
end
|
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.1
|
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
|
@@ -44,28 +58,42 @@ dependencies:
|
|
44
58
|
requirements:
|
45
59
|
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version: '5.
|
61
|
+
version: '5.14'
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
66
|
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version: '5.
|
68
|
+
version: '5.14'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: ocg
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
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'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: parallel
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: rake
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,28 +128,56 @@ dependencies:
|
|
100
128
|
requirements:
|
101
129
|
- - "~>"
|
102
130
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
131
|
+
version: '1.16'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::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'
|
104
146
|
type: :development
|
105
147
|
prerelease: false
|
106
148
|
version_requirements: !ruby/object:Gem::Requirement
|
107
149
|
requirements:
|
108
150
|
- - "~>"
|
109
151
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0.
|
152
|
+
version: '0.12'
|
111
153
|
- !ruby/object:Gem::Dependency
|
112
154
|
name: rubocop-performance
|
113
155
|
requirement: !ruby/object:Gem::Requirement
|
114
156
|
requirements:
|
115
157
|
- - "~>"
|
116
158
|
- !ruby/object:Gem::Version
|
117
|
-
version: '1.
|
159
|
+
version: '1.11'
|
118
160
|
type: :development
|
119
161
|
prerelease: false
|
120
162
|
version_requirements: !ruby/object:Gem::Requirement
|
121
163
|
requirements:
|
122
164
|
- - "~>"
|
123
165
|
- !ruby/object:Gem::Version
|
124
|
-
version: '1.
|
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'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.5'
|
125
181
|
- !ruby/object:Gem::Dependency
|
126
182
|
name: simplecov
|
127
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +192,7 @@ dependencies:
|
|
136
192
|
- - ">="
|
137
193
|
- !ruby/object:Gem::Version
|
138
194
|
version: '0'
|
139
|
-
description:
|
195
|
+
description:
|
140
196
|
email: aladjev.andrew@gmail.com
|
141
197
|
executables: []
|
142
198
|
extensions:
|
@@ -152,6 +208,7 @@ files:
|
|
152
208
|
- ext/lzws_ext/common.h
|
153
209
|
- ext/lzws_ext/error.c
|
154
210
|
- ext/lzws_ext/error.h
|
211
|
+
- ext/lzws_ext/gvl.h
|
155
212
|
- ext/lzws_ext/io.c
|
156
213
|
- ext/lzws_ext/io.h
|
157
214
|
- ext/lzws_ext/macro.h
|
@@ -185,7 +242,7 @@ homepage: https://github.com/andrew-aladev/ruby-lzws
|
|
185
242
|
licenses:
|
186
243
|
- MIT
|
187
244
|
metadata: {}
|
188
|
-
post_install_message:
|
245
|
+
post_install_message:
|
189
246
|
rdoc_options: []
|
190
247
|
require_paths:
|
191
248
|
- lib
|
@@ -193,15 +250,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
193
250
|
requirements:
|
194
251
|
- - ">="
|
195
252
|
- !ruby/object:Gem::Version
|
196
|
-
version: '
|
253
|
+
version: '2.5'
|
197
254
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
198
255
|
requirements:
|
199
256
|
- - ">="
|
200
257
|
- !ruby/object:Gem::Version
|
201
258
|
version: '0'
|
202
259
|
requirements: []
|
203
|
-
rubygems_version: 3.
|
204
|
-
signing_key:
|
260
|
+
rubygems_version: 3.2.15
|
261
|
+
signing_key:
|
205
262
|
specification_version: 4
|
206
|
-
summary: Ruby bindings for lzws library.
|
263
|
+
summary: Ruby bindings for lzws library (compatible with UNIX compress).
|
207
264
|
test_files: []
|