ruby-lzws 1.1.7 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/lzws/option.rb CHANGED
@@ -8,45 +8,62 @@ require_relative "validation"
8
8
 
9
9
  module LZWS
10
10
  module Option
11
- # Default options will be compatible with UNIX compress.
12
-
13
- DEFAULT_BUFFER_LENGTH = 0
14
- LOWEST_MAX_CODE_BIT_LENGTH = 9
15
- BIGGEST_MAX_CODE_BIT_LENGTH = 16
16
-
17
- DECOMPRESSOR_DEFAULTS = {
18
- :without_magic_header => false,
19
- :msb => false,
20
- :unaligned_bit_groups => false,
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
- COMPRESSOR_DEFAULTS = DECOMPRESSOR_DEFAULTS.merge(
26
- :max_code_bit_length => BIGGEST_MAX_CODE_BIT_LENGTH,
27
- :block_mode => true
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({}) { |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH }
35
- options = COMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
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
- Validation.validate_positive_integer max_code_bit_length
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
- raise ValidateError, "invalid max code bit length" if
43
- max_code_bit_length < LOWEST_MAX_CODE_BIT_LENGTH || max_code_bit_length > BIGGEST_MAX_CODE_BIT_LENGTH
56
+ block_mode = options[:block_mode]
57
+ Validation.validate_bool block_mode unless block_mode.nil?
44
58
 
45
- Validation.validate_bool options[:without_magic_header]
46
- Validation.validate_bool options[:block_mode]
47
- Validation.validate_bool options[:msb]
48
- Validation.validate_bool options[:unaligned_bit_groups]
49
- Validation.validate_bool options[:quiet]
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({}) { |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH }
58
- options = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
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[:without_magic_header]
63
- Validation.validate_bool options[:msb]
64
- Validation.validate_bool options[:unaligned_bit_groups]
65
- Validation.validate_bool options[:quiet]
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
@@ -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 consumed from source and bytes written to destination by design.
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
- Validation.validate_string internal_encoding \
93
- unless internal_encoding.nil? || internal_encoding.is_a?(::Encoding)
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?
@@ -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 = Buffer::DEFAULT_SOURCE_BUFFER_LENGTH_FOR_DECOMPRESSOR \
37
- if source_buffer_length.nil? || source_buffer_length.zero?
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
@@ -143,7 +143,7 @@ module LZWS
143
143
  end
144
144
 
145
145
  protected def each_string(each_proc, &block)
146
- return enum_for __method__ unless block.is_a? ::Proc
146
+ return enum_for __method__, each_proc unless block.is_a? ::Proc
147
147
 
148
148
  loop do
149
149
  string = each_proc.call
@@ -43,7 +43,9 @@ module LZWS
43
43
  end
44
44
 
45
45
  def self.validate_proc(value)
46
- raise ValidateError, "invalid proc" unless value.is_a?(::Proc) || value.is_a?(::Method) || value.is_a?(::UnboundMethod)
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
@@ -2,5 +2,5 @@
2
2
  # Copyright (c) 2019 AUTHORS, MIT License.
3
3
 
4
4
  module LZWS
5
- VERSION = "1.1.7".freeze
5
+ VERSION = "1.4.0".freeze
6
6
  end
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.7
4
+ version: 1.4.0
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: 2020-10-09 00:00:00.000000000 Z
11
+ date: 2021-09-30 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.12'
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.12'
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.1'
75
+ version: '1.4'
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.1'
82
+ version: '1.4'
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: '0.75'
131
+ version: '1.22'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '1.22'
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.15'
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.75'
152
+ version: '0.15'
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.5'
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.6'
118
174
  type: :development
119
175
  prerelease: false
120
176
  version_requirements: !ruby/object:Gem::Requirement
121
177
  requirements:
122
178
  - - "~>"
123
179
  - !ruby/object:Gem::Version
124
- version: '1.5'
180
+ version: '0.6'
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
@@ -200,8 +257,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
257
  - !ruby/object:Gem::Version
201
258
  version: '0'
202
259
  requirements: []
203
- rubygems_version: 3.1.4
204
- signing_key:
260
+ rubygems_version: 3.2.22
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: []