tapioca 0.11.4 → 0.11.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97f174e338dbb90c09c1771832fa2ac9883a7bd0ed12a63db26d43d99f899c67
4
- data.tar.gz: 4bd1517cba1b4e7883f828250a647ba1ec9eadf00a4065994a74418d100f1029
3
+ metadata.gz: 8ee3bcaf55b533576a46aa60a0a03b946552ee3fba42f8b136108dea8d0888ba
4
+ data.tar.gz: b0d12f84750676a3b99eb7e76e10d3be64a92359f5a440c0c8c5ef9c7f3e5ac9
5
5
  SHA512:
6
- metadata.gz: e07bc3e08067de7327b0a05dff6fbe07ad9cf488cc57bc23111ee8a0834276b508ee90f0f0613224241eefe2d3f15abd0f9abb16387754e35fa89229dd7a25f1
7
- data.tar.gz: edce4b934a9f58ae032c93f1585c50f7dd845045503d03333ba437b8fd1d4c5105d488bf032ae7005080de74005bed22ede14c21896267cd6e5437745bf00d90
6
+ metadata.gz: cf6bb9e139fabc27048c5237f0e8662f5972051ae01fd1fcaae34f11c23fceb471f7d7118df9dabd507b24f7fccf8d4a6208dfd02d08ed37453b1ef2679ba04f
7
+ data.tar.gz: 2860aaa02b120a10182e7928fdc54f48d6eca933f4eee8ec51df78ae59043bc59c6cc839b1a65d2fe610c3ec545ad68b2caf400821b32c7ee029ca0046b88009
@@ -105,7 +105,7 @@ module Tapioca
105
105
  constant = T.cast(superclass, T.class_of(ActiveRecord::Base))
106
106
  end
107
107
 
108
- scope_methods
108
+ scope_methods.uniq
109
109
  end
110
110
 
111
111
  sig do
@@ -172,7 +172,6 @@ module Tapioca
172
172
  ).void
173
173
  end
174
174
  def create_index_fetch_by_methods(field, klass)
175
- field_length = field.key_fields.length
176
175
  fields_name = field.key_fields.join("_and_")
177
176
  name = "fetch_by_#{fields_name}"
178
177
  parameters = field.key_fields.map do |arg|
@@ -205,17 +204,15 @@ module Tapioca
205
204
  )
206
205
  end
207
206
 
208
- if field_length == 1
209
- klass.create_method(
210
- "fetch_multi_by_#{fields_name}",
211
- class_method: true,
212
- parameters: [
213
- create_param("index_values", type: "T::Enumerable[T.untyped]"),
214
- create_kw_opt_param("includes", default: "nil", type: "T.untyped"),
215
- ],
216
- return_type: COLLECTION_TYPE.call(constant),
217
- )
218
- end
207
+ klass.create_method(
208
+ "fetch_multi_by_#{fields_name}",
209
+ class_method: true,
210
+ parameters: [
211
+ create_param("index_values", type: "T::Enumerable[T.untyped]"),
212
+ create_kw_opt_param("includes", default: "nil", type: "T.untyped"),
213
+ ],
214
+ return_type: COLLECTION_TYPE.call(constant),
215
+ )
219
216
  end
220
217
 
221
218
  sig do
@@ -231,7 +231,8 @@ module Tapioca
231
231
  # Here we're going to check if the submsg_name is named according to
232
232
  # how Google names map entries.
233
233
  # https://github.com/protocolbuffers/protobuf/blob/f82e26/ruby/ext/google/protobuf_c/defs.c#L1963-L1966
234
- if descriptor.submsg_name.to_s.end_with?("_MapEntry_#{descriptor.name}")
234
+ if descriptor.submsg_name.to_s.end_with?("_MapEntry_#{descriptor.name}") ||
235
+ descriptor.submsg_name.to_s.end_with?("FieldsEntry")
235
236
  key = descriptor.subtype.lookup("key")
236
237
  value = descriptor.subtype.lookup("value")
237
238
 
@@ -23,7 +23,7 @@ module Tapioca
23
23
 
24
24
  attr_reader :__tapioca_secure_tokens
25
25
 
26
- def has_secure_token(attribute = :token, length: ::ActiveRecord::SecureToken::MINIMUM_TOKEN_LENGTH)
26
+ def has_secure_token(attribute = :token, **)
27
27
  @__tapioca_secure_tokens ||= []
28
28
  @__tapioca_secure_tokens << attribute
29
29
 
@@ -15,7 +15,7 @@ module Tapioca
15
15
  # be the minimum between the number of available processors (max) or the number of workers to make sure that each
16
16
  # one has at least 4 items to process
17
17
  @number_of_workers = T.let(
18
- number_of_workers || [Etc.nprocessors, (queue.length.to_f / MINIMUM_ITEMS_PER_WORKER).ceil].min,
18
+ number_of_workers || [max_processors, (queue.length.to_f / MINIMUM_ITEMS_PER_WORKER).ceil].min,
19
19
  Integer,
20
20
  )
21
21
  end
@@ -30,5 +30,13 @@ module Tapioca
30
30
  number_of_processes = @number_of_workers == 1 ? 0 : @number_of_workers
31
31
  Parallel.map(@queue, { in_processes: number_of_processes }, &block)
32
32
  end
33
+
34
+ private
35
+
36
+ sig { returns(Integer) }
37
+ def max_processors
38
+ env_max_processors = ENV["PARALLEL_PROCESSOR_COUNT"].to_i
39
+ env_max_processors.positive? ? env_max_processors : Etc.nprocessors
40
+ end
33
41
  end
34
42
  end
@@ -118,7 +118,7 @@ module Tapioca
118
118
  sanitized_parameters.each do |type, name|
119
119
  case type
120
120
  when :req
121
- rbi_method << RBI::Param.new(name)
121
+ rbi_method << RBI::ReqParam.new(name)
122
122
  when :opt
123
123
  rbi_method << RBI::OptParam.new(name, "T.unsafe(nil)")
124
124
  when :rest
@@ -40,7 +40,7 @@ module Tapioca
40
40
 
41
41
  sig { params(name: String, type: String).returns(RBI::TypedParam) }
42
42
  def create_param(name, type:)
43
- create_typed_param(RBI::Param.new(name), type)
43
+ create_typed_param(RBI::ReqParam.new(name), type)
44
44
  end
45
45
 
46
46
  sig { params(name: String, type: String, default: String).returns(RBI::TypedParam) }
@@ -145,7 +145,7 @@ module Tapioca
145
145
 
146
146
  class_attribute_writers.each do |attribute|
147
147
  mod << RBI::Method.new("#{attribute}=") do |method|
148
- method << RBI::Param.new("value")
148
+ method << RBI::ReqParam.new("value")
149
149
  end
150
150
  end
151
151
 
@@ -162,7 +162,7 @@ module Tapioca
162
162
 
163
163
  instance_attribute_writers.each do |attribute|
164
164
  mod << RBI::Method.new("#{attribute}=") do |method|
165
- method << RBI::Param.new("value")
165
+ method << RBI::ReqParam.new("value")
166
166
  end
167
167
  end
168
168
 
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Tapioca
5
- VERSION = "0.11.4"
5
+ VERSION = "0.11.6"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tapioca
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ufuk Kayserilioglu
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2023-03-31 00:00:00.000000000 Z
14
+ date: 2023-05-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -281,7 +281,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
281
281
  - !ruby/object:Gem::Version
282
282
  version: '0'
283
283
  requirements: []
284
- rubygems_version: 3.4.9
284
+ rubygems_version: 3.4.12
285
285
  signing_key:
286
286
  specification_version: 4
287
287
  summary: A Ruby Interface file generator for gems, core types and the Ruby standard