tapioca 0.11.3 → 0.11.5

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: '0409ff7f6d35e2767d201fc3b920d9c3febdd94017dd2f51dda7ddbade8cf322'
4
- data.tar.gz: 2a328485d2bd7b961531edd123e8f9b88172078d32f63dcf1bc7d8d120725640
3
+ metadata.gz: 49ff67fe6f34923e27d8c7ab2dbb0f616fa056d0f57905cbff5284a9abb5fb40
4
+ data.tar.gz: fa92f0074e930ffbdc1fcf6ad0c1462e6e3aa3bbf05ae3febf467252763e8c9b
5
5
  SHA512:
6
- metadata.gz: f815bf33068255e641484a8e642c665a782416a08d5b0c4ca7e30690a0ae2034a34fb7a75a2ed159bddaf9271e103f62dadaf16642adc918a3be81b1853efdf2
7
- data.tar.gz: 88d826dc3de171edca2dd81d4157ba6c91d6c0177b2a354aa7ccd3b9b9bac35030213f03b1fc256abd91b35f671ce370dd579d3c9c829ef82a5b750b0d4fe28c
6
+ metadata.gz: 3ba1fa737b5474b4433dd30ebb9104974c0d9a61c92e597546595ea142f2dadd7bea6b3915b742920176fec7d2670a1cf453d29f1ec633705373bb7b50958927
7
+ data.tar.gz: 2dc119e28e7d09d6dfe6bda01dfb185358a1a7db2d9d433a99d470a210eab40c9f476e9fb065cc6d6156f68cff6c16e3c1016f040cc86262afda1827892685cb
@@ -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
@@ -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
 
@@ -69,10 +69,10 @@ module Tapioca
69
69
  "::String"
70
70
  when ActiveRecord::Type::Serialized
71
71
  serialized_column_type(column_type)
72
- when defined?(ActiveRecord::ConnectionAdapters::PostgreSQL) &&
72
+ when defined?(ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Hstore) &&
73
73
  ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Hstore
74
74
  "T::Hash[::String, ::String]"
75
- when defined?(ActiveRecord::ConnectionAdapters::PostgreSQL) &&
75
+ when defined?(ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array) &&
76
76
  ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array
77
77
  "T::Array[#{type_for_activerecord_value(column_type.subtype)}]"
78
78
  else
data/lib/tapioca/dsl.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "rbi"
5
+ require "spoom"
5
6
 
6
7
  require "tapioca"
7
8
  require "tapioca/runtime/reflection"
@@ -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
@@ -10,7 +10,7 @@ module Tapioca
10
10
  app_dir = to_realpath(app_dir)
11
11
  full_gem_path = to_realpath(full_gem_path)
12
12
 
13
- !gem_in_bundle_path?(full_gem_path) && path_in_dir?(full_gem_path, app_dir)
13
+ !gem_in_bundle_path?(full_gem_path) && !gem_in_ruby_path?(full_gem_path) && path_in_dir?(full_gem_path, app_dir)
14
14
  end
15
15
 
16
16
  sig { params(full_gem_path: String).returns(T::Boolean) }
@@ -18,6 +18,11 @@ module Tapioca
18
18
  path_in_dir?(full_gem_path, Bundler.bundle_path) || path_in_dir?(full_gem_path, Bundler.app_cache)
19
19
  end
20
20
 
21
+ sig { params(full_gem_path: String).returns(T::Boolean) }
22
+ def gem_in_ruby_path?(full_gem_path)
23
+ path_in_dir?(full_gem_path, RbConfig::CONFIG["rubylibprefix"])
24
+ end
25
+
21
26
  sig { params(path: T.any(String, Pathname)).returns(String) }
22
27
  def to_realpath(path)
23
28
  path_string = path.to_s
@@ -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) }
@@ -19,6 +19,8 @@ module Tapioca
19
19
 
20
20
  SORBET_PAYLOAD_URL = "https://github.com/sorbet/sorbet/tree/master/rbi"
21
21
 
22
+ SPOOM_CONTEXT = T.let(Spoom::Context.new("."), Spoom::Context)
23
+
22
24
  FEATURE_REQUIREMENTS = T.let(
23
25
  {
24
26
  # feature_name: ::Gem::Requirement.new(">= ___"), # https://github.com/sorbet/sorbet/pull/___
@@ -29,7 +31,7 @@ module Tapioca
29
31
 
30
32
  sig { params(sorbet_args: String).returns(Spoom::ExecResult) }
31
33
  def sorbet(*sorbet_args)
32
- Spoom::Sorbet.srb(sorbet_args.join(" "), sorbet_bin: sorbet_path, capture_err: true)
34
+ SPOOM_CONTEXT.srb(sorbet_args.join(" "), sorbet_bin: sorbet_path)
33
35
  end
34
36
 
35
37
  sig { returns(String) }
@@ -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.3"
5
+ VERSION = "0.11.5"
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.3
4
+ version: 0.11.5
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-21 00:00:00.000000000 Z
14
+ date: 2023-04-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -95,20 +95,20 @@ dependencies:
95
95
  requirements:
96
96
  - - "~>"
97
97
  - !ruby/object:Gem::Version
98
- version: 1.1.0
98
+ version: 1.2.0
99
99
  - - ">="
100
100
  - !ruby/object:Gem::Version
101
- version: 1.1.11
101
+ version: 1.2.0
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
106
  - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: 1.1.0
108
+ version: 1.2.0
109
109
  - - ">="
110
110
  - !ruby/object:Gem::Version
111
- version: 1.1.11
111
+ version: 1.2.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: thor
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -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.3.3
284
+ rubygems_version: 3.4.10
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