ruby-brs 1.1.4 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/brs/option.rb CHANGED
@@ -11,16 +11,20 @@ module BRS
11
11
  DEFAULT_BUFFER_LENGTH = 0
12
12
 
13
13
  COMPRESSOR_DEFAULTS = {
14
+ :gvl => false,
14
15
  :mode => nil,
15
16
  :quality => nil,
16
17
  :lgwin => nil,
17
18
  :lgblock => nil,
19
+ :npostfix => nil,
20
+ :ndirect => nil,
18
21
  :disable_literal_context_modeling => nil,
19
22
  :large_window => nil
20
23
  }
21
24
  .freeze
22
25
 
23
26
  DECOMPRESSOR_DEFAULTS = {
27
+ :gvl => false,
24
28
  :disable_ring_buffer_reallocation => nil,
25
29
  :large_window => nil
26
30
  }
@@ -29,11 +33,16 @@ module BRS
29
33
  def self.get_compressor_options(options, buffer_length_names)
30
34
  Validation.validate_hash options
31
35
 
32
- buffer_length_defaults = buffer_length_names.each_with_object({}) { |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH }
33
- 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
34
41
 
35
42
  buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
36
43
 
44
+ Validation.validate_bool options[:gvl]
45
+
37
46
  mode = options[:mode]
38
47
  unless mode.nil?
39
48
  Validation.validate_symbol mode
@@ -58,6 +67,24 @@ module BRS
58
67
  raise ValidateError, "invalid lgblock" if lgblock < MIN_LGBLOCK || lgblock > MAX_LGBLOCK
59
68
  end
60
69
 
70
+ npostfix = options[:npostfix]
71
+ unless npostfix.nil?
72
+ Validation.validate_not_negative_integer npostfix
73
+ raise ValidateError, "invalid npostfix" if npostfix < MIN_NPOSTFIX || npostfix > MAX_NPOSTFIX
74
+ end
75
+
76
+ ndirect = options[:ndirect]
77
+ unless ndirect.nil?
78
+ Validation.validate_not_negative_integer ndirect
79
+ raise ValidateError, "invalid ndirect" if ndirect < MIN_NDIRECT || ndirect > MAX_NDIRECT
80
+
81
+ raise ValidateError, "invalid ndirect" if
82
+ !npostfix.nil? && (
83
+ (ndirect - MIN_NDIRECT) % (NDIRECT_NPOSTFIX_STEP_BASE << npostfix) != 0 ||
84
+ (ndirect - MIN_NDIRECT) > (NDIRECT_NPOSTFIX_MAX_BASE << npostfix)
85
+ )
86
+ end
87
+
61
88
  disable_literal_context_modeling = options[:disable_literal_context_modeling]
62
89
  Validation.validate_bool disable_literal_context_modeling unless disable_literal_context_modeling.nil?
63
90
 
@@ -70,11 +97,16 @@ module BRS
70
97
  def self.get_decompressor_options(options, buffer_length_names)
71
98
  Validation.validate_hash options
72
99
 
73
- buffer_length_defaults = buffer_length_names.each_with_object({}) { |name, defaults| defaults[name] = DEFAULT_BUFFER_LENGTH }
74
- options = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
100
+ buffer_length_defaults = buffer_length_names.each_with_object({}) do |name, defaults|
101
+ defaults[name] = DEFAULT_BUFFER_LENGTH
102
+ end
103
+
104
+ options = DECOMPRESSOR_DEFAULTS.merge(buffer_length_defaults).merge options
75
105
 
76
106
  buffer_length_names.each { |name| Validation.validate_not_negative_integer options[name] }
77
107
 
108
+ Validation.validate_bool options[:gvl]
109
+
78
110
  disable_ring_buffer_reallocation = options[:disable_ring_buffer_reallocation]
79
111
  Validation.validate_bool disable_ring_buffer_reallocation unless disable_ring_buffer_reallocation.nil?
80
112
 
@@ -12,7 +12,8 @@ module BRS
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 BRS
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 BRS
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 BRS
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
@@ -47,7 +47,9 @@ module BRS
47
47
  end
48
48
 
49
49
  def self.validate_proc(value)
50
- raise ValidateError, "invalid proc" unless value.is_a?(::Proc) || value.is_a?(::Method) || value.is_a?(::UnboundMethod)
50
+ unless value.is_a?(::Proc) || value.is_a?(::Method) || value.is_a?(::UnboundMethod)
51
+ raise ValidateError, "invalid proc"
52
+ end
51
53
  end
52
54
  end
53
55
  end
data/lib/brs/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # Copyright (c) 2019 AUTHORS, MIT License.
3
3
 
4
4
  module BRS
5
- VERSION = "1.1.4".freeze
5
+ VERSION = "1.3.0".freeze
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-brs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.3.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-02 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'
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.5'
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'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
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:
@@ -151,6 +207,7 @@ files:
151
207
  - ext/brs_ext/common.h
152
208
  - ext/brs_ext/error.c
153
209
  - ext/brs_ext/error.h
210
+ - ext/brs_ext/gvl.h
154
211
  - ext/brs_ext/io.c
155
212
  - ext/brs_ext/io.h
156
213
  - ext/brs_ext/macro.h
@@ -185,23 +242,23 @@ homepage: https://github.com/andrew-aladev/ruby-brs
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
192
249
  required_ruby_version: !ruby/object:Gem::Requirement
193
250
  requirements:
194
- - - "~>"
251
+ - - ">="
195
252
  - !ruby/object:Gem::Version
196
- version: '2.7'
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.1.2
204
- signing_key:
260
+ rubygems_version: 3.2.22
261
+ signing_key:
205
262
  specification_version: 4
206
263
  summary: Ruby bindings for brotli library.
207
264
  test_files: []