tapioca 0.10.1 → 0.10.3
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 +9 -3
- data/lib/tapioca/cli.rb +24 -12
- data/lib/tapioca/commands/annotations.rb +2 -2
- data/lib/tapioca/commands/check_shims.rb +13 -21
- data/lib/tapioca/commands/command.rb +2 -2
- data/lib/tapioca/commands/command_without_tracker.rb +18 -0
- data/lib/tapioca/commands/configure.rb +3 -3
- data/lib/tapioca/commands/dsl.rb +16 -11
- data/lib/tapioca/commands/gem.rb +5 -5
- data/lib/tapioca/commands/require.rb +2 -2
- data/lib/tapioca/commands/todo.rb +2 -2
- data/lib/tapioca/commands.rb +1 -0
- data/lib/tapioca/dsl/compiler.rb +3 -3
- data/lib/tapioca/dsl/compilers/aasm.rb +4 -4
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -1
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_job.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +48 -13
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +22 -22
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +1 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +52 -48
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +3 -3
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_storage.rb +2 -2
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +1 -1
- data/lib/tapioca/dsl/compilers/config.rb +2 -2
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +1 -0
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +1 -0
- data/lib/tapioca/dsl/compilers/identity_cache.rb +12 -12
- data/lib/tapioca/dsl/compilers/protobuf.rb +21 -10
- data/lib/tapioca/dsl/compilers/rails_generators.rb +2 -2
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -1
- data/lib/tapioca/dsl/compilers/smart_properties.rb +2 -2
- data/lib/tapioca/dsl/compilers/state_machines.rb +24 -24
- data/lib/tapioca/dsl/compilers/url_helpers.rb +1 -1
- data/lib/tapioca/dsl/compilers.rb +1 -1
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +19 -0
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +1 -1
- data/lib/tapioca/dsl/pipeline.rb +5 -4
- data/lib/tapioca/executor.rb +2 -2
- data/lib/tapioca/gem/events.rb +1 -1
- data/lib/tapioca/gem/listeners/foreign_constants.rb +3 -2
- data/lib/tapioca/gem/listeners/methods.rb +3 -3
- data/lib/tapioca/gem/listeners/mixins.rb +3 -7
- data/lib/tapioca/gem/listeners/source_location.rb +1 -1
- data/lib/tapioca/gem/listeners/subconstants.rb +1 -1
- data/lib/tapioca/gem/listeners/yard_doc.rb +1 -1
- data/lib/tapioca/gem/pipeline.rb +11 -9
- data/lib/tapioca/gemfile.rb +4 -4
- data/lib/tapioca/helpers/config_helper.rb +4 -4
- data/lib/tapioca/helpers/env_helper.rb +1 -0
- data/lib/tapioca/helpers/gem_helper.rb +17 -5
- data/lib/tapioca/helpers/rbi_files_helper.rb +3 -3
- data/lib/tapioca/helpers/rbi_helper.rb +5 -13
- data/lib/tapioca/helpers/sorbet_helper.rb +3 -5
- data/lib/tapioca/helpers/source_uri.rb +1 -1
- data/lib/tapioca/helpers/test/dsl_compiler.rb +1 -1
- data/lib/tapioca/loaders/dsl.rb +9 -7
- data/lib/tapioca/loaders/gem.rb +2 -2
- data/lib/tapioca/loaders/loader.rb +6 -6
- data/lib/tapioca/rbi_ext/model.rb +8 -5
- data/lib/tapioca/rbi_formatter.rb +2 -2
- data/lib/tapioca/runtime/generic_type_registry.rb +22 -2
- data/lib/tapioca/runtime/reflection.rb +63 -2
- data/lib/tapioca/runtime/trackers/autoload.rb +3 -0
- data/lib/tapioca/runtime/trackers/constant_definition.rb +13 -5
- data/lib/tapioca/runtime/trackers/mixin.rb +37 -36
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +17 -4
- data/lib/tapioca/runtime/trackers/tracker.rb +45 -0
- data/lib/tapioca/runtime/trackers.rb +27 -1
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +17 -6
- data/lib/tapioca/static/symbol_loader.rb +3 -3
- data/lib/tapioca/static/symbol_table_parser.rb +6 -0
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +0 -10
- metadata +8 -20
@@ -64,7 +64,7 @@ module Tapioca
|
|
64
64
|
generate_scope_method(
|
65
65
|
relation_methods_module,
|
66
66
|
scope_method.to_s,
|
67
|
-
relations_enabled ? RelationClassName : "T.untyped"
|
67
|
+
relations_enabled ? RelationClassName : "T.untyped",
|
68
68
|
)
|
69
69
|
|
70
70
|
next unless relations_enabled
|
@@ -72,7 +72,7 @@ module Tapioca
|
|
72
72
|
generate_scope_method(
|
73
73
|
assoc_relation_methods_mod,
|
74
74
|
scope_method.to_s,
|
75
|
-
AssociationRelationClassName
|
75
|
+
AssociationRelationClassName,
|
76
76
|
)
|
77
77
|
end
|
78
78
|
|
@@ -112,7 +112,7 @@ module Tapioca
|
|
112
112
|
params(
|
113
113
|
mod: RBI::Scope,
|
114
114
|
scope_method: String,
|
115
|
-
return_type: String
|
115
|
+
return_type: String,
|
116
116
|
).void
|
117
117
|
end
|
118
118
|
def generate_scope_method(mod, scope_method, return_type)
|
@@ -147,7 +147,7 @@ module Tapioca
|
|
147
147
|
params(
|
148
148
|
klass: RBI::Scope,
|
149
149
|
name: String,
|
150
|
-
type: String
|
150
|
+
type: String,
|
151
151
|
)
|
152
152
|
.void
|
153
153
|
end
|
@@ -155,7 +155,7 @@ module Tapioca
|
|
155
155
|
klass.create_method(
|
156
156
|
"#{name}=",
|
157
157
|
parameters: [create_param(name, type: type)],
|
158
|
-
return_type: type
|
158
|
+
return_type: type,
|
159
159
|
)
|
160
160
|
klass.create_method(name, return_type: type)
|
161
161
|
klass.create_method("#{name}?", return_type: "T::Boolean")
|
@@ -63,12 +63,12 @@ module Tapioca
|
|
63
63
|
name = reflection.name.to_s
|
64
64
|
scope.create_method(
|
65
65
|
name,
|
66
|
-
return_type: type
|
66
|
+
return_type: type,
|
67
67
|
)
|
68
68
|
scope.create_method(
|
69
69
|
"#{name}=",
|
70
70
|
parameters: [create_param("attachable", type: "T.untyped")],
|
71
|
-
return_type: "T.untyped"
|
71
|
+
return_type: "T.untyped",
|
72
72
|
)
|
73
73
|
end
|
74
74
|
end
|
@@ -83,14 +83,14 @@ module Tapioca
|
|
83
83
|
# Create getter method
|
84
84
|
mod.create_method(
|
85
85
|
method_name.to_s,
|
86
|
-
return_type: "T.untyped"
|
86
|
+
return_type: "T.untyped",
|
87
87
|
)
|
88
88
|
|
89
89
|
# Create setter method
|
90
90
|
mod.create_method(
|
91
91
|
"#{method_name}=",
|
92
92
|
parameters: [create_param("value", type: "T.untyped")],
|
93
|
-
return_type: "T.untyped"
|
93
|
+
return_type: "T.untyped",
|
94
94
|
)
|
95
95
|
end
|
96
96
|
end
|
@@ -66,7 +66,7 @@ module Tapioca
|
|
66
66
|
|
67
67
|
COLLECTION_TYPE = T.let(
|
68
68
|
->(type) { "T::Array[::#{type}]" },
|
69
|
-
T.proc.params(type: T.any(Module, String)).returns(String)
|
69
|
+
T.proc.params(type: T.any(Module, String)).returns(String),
|
70
70
|
)
|
71
71
|
|
72
72
|
ConstantType = type_member { { fixed: T.class_of(::ActiveRecord::Base) } }
|
@@ -116,7 +116,7 @@ module Tapioca
|
|
116
116
|
sig do
|
117
117
|
params(
|
118
118
|
field: T.untyped,
|
119
|
-
returns_collection: T::Boolean
|
119
|
+
returns_collection: T::Boolean,
|
120
120
|
).returns(String)
|
121
121
|
end
|
122
122
|
def type_for_field(field, returns_collection:)
|
@@ -134,7 +134,7 @@ module Tapioca
|
|
134
134
|
params(
|
135
135
|
field: T.untyped,
|
136
136
|
klass: RBI::Scope,
|
137
|
-
returns_collection: T::Boolean
|
137
|
+
returns_collection: T::Boolean,
|
138
138
|
).void
|
139
139
|
end
|
140
140
|
def create_fetch_field_methods(field, klass, returns_collection:)
|
@@ -152,7 +152,7 @@ module Tapioca
|
|
152
152
|
sig do
|
153
153
|
params(
|
154
154
|
field: T.untyped,
|
155
|
-
klass: RBI::Scope
|
155
|
+
klass: RBI::Scope,
|
156
156
|
).void
|
157
157
|
end
|
158
158
|
def create_fetch_by_methods(field, klass)
|
@@ -168,7 +168,7 @@ module Tapioca
|
|
168
168
|
sig do
|
169
169
|
params(
|
170
170
|
field: T.untyped,
|
171
|
-
klass: RBI::Scope
|
171
|
+
klass: RBI::Scope,
|
172
172
|
).void
|
173
173
|
end
|
174
174
|
def create_index_fetch_by_methods(field, klass)
|
@@ -187,21 +187,21 @@ module Tapioca
|
|
187
187
|
"#{name}!",
|
188
188
|
class_method: true,
|
189
189
|
parameters: parameters,
|
190
|
-
return_type: type
|
190
|
+
return_type: type,
|
191
191
|
)
|
192
192
|
|
193
193
|
klass.create_method(
|
194
194
|
name,
|
195
195
|
class_method: true,
|
196
196
|
parameters: parameters,
|
197
|
-
return_type: as_nilable_type(type)
|
197
|
+
return_type: as_nilable_type(type),
|
198
198
|
)
|
199
199
|
else
|
200
200
|
klass.create_method(
|
201
201
|
name,
|
202
202
|
class_method: true,
|
203
203
|
parameters: parameters,
|
204
|
-
return_type: COLLECTION_TYPE.call(constant)
|
204
|
+
return_type: COLLECTION_TYPE.call(constant),
|
205
205
|
)
|
206
206
|
end
|
207
207
|
|
@@ -213,7 +213,7 @@ module Tapioca
|
|
213
213
|
create_param("index_values", type: "T::Enumerable[T.untyped]"),
|
214
214
|
create_kw_opt_param("includes", default: "nil", type: "T.untyped"),
|
215
215
|
],
|
216
|
-
return_type: COLLECTION_TYPE.call(constant)
|
216
|
+
return_type: COLLECTION_TYPE.call(constant),
|
217
217
|
)
|
218
218
|
end
|
219
219
|
end
|
@@ -221,7 +221,7 @@ module Tapioca
|
|
221
221
|
sig do
|
222
222
|
params(
|
223
223
|
field: T.untyped,
|
224
|
-
klass: RBI::Scope
|
224
|
+
klass: RBI::Scope,
|
225
225
|
).void
|
226
226
|
end
|
227
227
|
def create_aliased_fetch_by_methods(field, klass)
|
@@ -238,7 +238,7 @@ module Tapioca
|
|
238
238
|
"fetch_#{suffix}",
|
239
239
|
class_method: true,
|
240
240
|
parameters: parameters,
|
241
|
-
return_type: type
|
241
|
+
return_type: type,
|
242
242
|
)
|
243
243
|
|
244
244
|
if length == 1
|
@@ -246,7 +246,7 @@ module Tapioca
|
|
246
246
|
"fetch_multi_#{suffix}",
|
247
247
|
class_method: true,
|
248
248
|
parameters: [create_param("keys", type: "T::Enumerable[T.untyped]")],
|
249
|
-
return_type: COLLECTION_TYPE.call(multi_type)
|
249
|
+
return_type: COLLECTION_TYPE.call(multi_type),
|
250
250
|
)
|
251
251
|
end
|
252
252
|
end
|
@@ -37,7 +37,7 @@ module Tapioca
|
|
37
37
|
# sig { returns(Integer) }
|
38
38
|
# def customer_id; end
|
39
39
|
#
|
40
|
-
# sig { params(
|
40
|
+
# sig { params(value: Integer).returns(Integer) }
|
41
41
|
# def customer_id=(value); end
|
42
42
|
#
|
43
43
|
# sig { returns(Integer) }
|
@@ -95,7 +95,18 @@ module Tapioca
|
|
95
95
|
case descriptor
|
96
96
|
when Google::Protobuf::EnumDescriptor
|
97
97
|
descriptor.to_h.each do |sym, val|
|
98
|
-
|
98
|
+
# For each enum value, create a namespaced constant on the root rather than an un-namespaced
|
99
|
+
# constant within the class. This is because un-namespaced constants might conflict with reserved
|
100
|
+
# Ruby words, such as "BEGIN." By namespacing them, we avoid this problem.
|
101
|
+
#
|
102
|
+
# Invalid syntax:
|
103
|
+
# class Foo
|
104
|
+
# BEGIN = 3
|
105
|
+
# end
|
106
|
+
#
|
107
|
+
# Valid syntax:
|
108
|
+
# Foo::BEGIN = 3
|
109
|
+
root.create_constant("#{constant}::#{sym}", value: val.to_s)
|
99
110
|
end
|
100
111
|
|
101
112
|
klass.create_method(
|
@@ -169,7 +180,7 @@ module Tapioca
|
|
169
180
|
|
170
181
|
sig do
|
171
182
|
params(
|
172
|
-
descriptor: Google::Protobuf::FieldDescriptor
|
183
|
+
descriptor: Google::Protobuf::FieldDescriptor,
|
173
184
|
).returns(String)
|
174
185
|
end
|
175
186
|
def type_of(descriptor)
|
@@ -223,7 +234,7 @@ module Tapioca
|
|
223
234
|
name: descriptor.name,
|
224
235
|
type: type,
|
225
236
|
init_type: "T.nilable(T.any(#{type}, T::Hash[#{key_type}, #{value_type}]))",
|
226
|
-
default: "Google::Protobuf::Map.new(#{default_args.join(", ")})"
|
237
|
+
default: "Google::Protobuf::Map.new(#{default_args.join(", ")})",
|
227
238
|
)
|
228
239
|
else
|
229
240
|
elem_type = type_of(descriptor)
|
@@ -236,7 +247,7 @@ module Tapioca
|
|
236
247
|
name: descriptor.name,
|
237
248
|
type: type,
|
238
249
|
init_type: "T.nilable(T.any(#{type}, T::Array[#{elem_type}]))",
|
239
|
-
default: "Google::Protobuf::RepeatedField.new(#{default_args.join(", ")})"
|
250
|
+
default: "Google::Protobuf::RepeatedField.new(#{default_args.join(", ")})",
|
240
251
|
)
|
241
252
|
end
|
242
253
|
else
|
@@ -248,7 +259,7 @@ module Tapioca
|
|
248
259
|
name: descriptor.name,
|
249
260
|
type: type,
|
250
261
|
init_type: nilable_type,
|
251
|
-
default: "nil"
|
262
|
+
default: "nil",
|
252
263
|
)
|
253
264
|
end
|
254
265
|
end
|
@@ -264,13 +275,13 @@ module Tapioca
|
|
264
275
|
|
265
276
|
klass.create_method(
|
266
277
|
field.name,
|
267
|
-
return_type: field.type
|
278
|
+
return_type: field.type,
|
268
279
|
)
|
269
280
|
|
270
281
|
klass.create_method(
|
271
282
|
"#{field.name}=",
|
272
283
|
parameters: [create_param("value", type: field.type)],
|
273
|
-
return_type: "void"
|
284
|
+
return_type: "void",
|
274
285
|
)
|
275
286
|
|
276
287
|
field
|
@@ -279,13 +290,13 @@ module Tapioca
|
|
279
290
|
sig do
|
280
291
|
params(
|
281
292
|
klass: RBI::Scope,
|
282
|
-
desc: Google::Protobuf::OneofDescriptor
|
293
|
+
desc: Google::Protobuf::OneofDescriptor,
|
283
294
|
).void
|
284
295
|
end
|
285
296
|
def create_oneof_method(klass, desc)
|
286
297
|
klass.create_method(
|
287
298
|
desc.name,
|
288
|
-
return_type: "T.nilable(Symbol)"
|
299
|
+
return_type: "T.nilable(Symbol)",
|
289
300
|
)
|
290
301
|
end
|
291
302
|
end
|
@@ -43,7 +43,7 @@ module Tapioca
|
|
43
43
|
|
44
44
|
BUILT_IN_MATCHER = T.let(
|
45
45
|
/::(ActionMailbox|ActionText|ActiveRecord|Rails)::Generators/,
|
46
|
-
Regexp
|
46
|
+
Regexp,
|
47
47
|
)
|
48
48
|
|
49
49
|
ConstantType = type_member { { fixed: T.class_of(::Rails::Generators::Base) } }
|
@@ -86,7 +86,7 @@ module Tapioca
|
|
86
86
|
klass.create_method(
|
87
87
|
argument.name,
|
88
88
|
parameters: [],
|
89
|
-
return_type: type_for(argument)
|
89
|
+
return_type: type_for(argument),
|
90
90
|
)
|
91
91
|
end
|
92
92
|
|
@@ -69,7 +69,7 @@ module Tapioca
|
|
69
69
|
def decorate
|
70
70
|
properties = T.let(
|
71
71
|
T.unsafe(constant).properties,
|
72
|
-
::SmartProperties::PropertyCollection
|
72
|
+
::SmartProperties::PropertyCollection,
|
73
73
|
)
|
74
74
|
return if properties.keys.empty?
|
75
75
|
|
@@ -103,7 +103,7 @@ module Tapioca
|
|
103
103
|
sig do
|
104
104
|
params(
|
105
105
|
mod: RBI::Scope,
|
106
|
-
property: ::SmartProperties::Property
|
106
|
+
property: ::SmartProperties::Property,
|
107
107
|
).void
|
108
108
|
end
|
109
109
|
def generate_methods_for_property(mod, property)
|
@@ -186,7 +186,7 @@ module Tapioca
|
|
186
186
|
def define_activerecord_methods(instance_module)
|
187
187
|
instance_module.create_method(
|
188
188
|
"changed_for_autosave?",
|
189
|
-
return_type: "T::Boolean"
|
189
|
+
return_type: "T::Boolean",
|
190
190
|
)
|
191
191
|
end
|
192
192
|
|
@@ -195,7 +195,7 @@ module Tapioca
|
|
195
195
|
machine.states.each do |state|
|
196
196
|
instance_module.create_method(
|
197
197
|
"#{state.qualified_name}?",
|
198
|
-
return_type: "T::Boolean"
|
198
|
+
return_type: "T::Boolean",
|
199
199
|
)
|
200
200
|
end
|
201
201
|
end
|
@@ -205,22 +205,22 @@ module Tapioca
|
|
205
205
|
machine.events.each do |event|
|
206
206
|
instance_module.create_method(
|
207
207
|
"can_#{event.qualified_name}?",
|
208
|
-
return_type: "T::Boolean"
|
208
|
+
return_type: "T::Boolean",
|
209
209
|
)
|
210
210
|
instance_module.create_method(
|
211
211
|
"#{event.qualified_name}_transition",
|
212
212
|
parameters: [create_rest_param("args", type: "T.untyped")],
|
213
|
-
return_type: "T.nilable(::StateMachines::Transition)"
|
213
|
+
return_type: "T.nilable(::StateMachines::Transition)",
|
214
214
|
)
|
215
215
|
instance_module.create_method(
|
216
216
|
event.qualified_name.to_s,
|
217
217
|
parameters: [create_rest_param("args", type: "T.untyped")],
|
218
|
-
return_type: "T::Boolean"
|
218
|
+
return_type: "T::Boolean",
|
219
219
|
)
|
220
220
|
instance_module.create_method(
|
221
221
|
"#{event.qualified_name}!",
|
222
222
|
parameters: [create_rest_param("args", type: "T.untyped")],
|
223
|
-
return_type: "T::Boolean"
|
223
|
+
return_type: "T::Boolean",
|
224
224
|
)
|
225
225
|
end
|
226
226
|
end
|
@@ -229,19 +229,19 @@ module Tapioca
|
|
229
229
|
params(
|
230
230
|
instance_module: RBI::Module,
|
231
231
|
machine: ::StateMachines::Machine,
|
232
|
-
state_type: String
|
232
|
+
state_type: String,
|
233
233
|
).void
|
234
234
|
end
|
235
235
|
def define_state_accessor(instance_module, machine, state_type)
|
236
236
|
attribute = machine.attribute.to_s
|
237
237
|
instance_module.create_method(
|
238
238
|
attribute,
|
239
|
-
return_type: state_type
|
239
|
+
return_type: state_type,
|
240
240
|
)
|
241
241
|
instance_module.create_method(
|
242
242
|
"#{attribute}=",
|
243
243
|
parameters: [create_param("value", type: state_type)],
|
244
|
-
return_type: state_type
|
244
|
+
return_type: state_type,
|
245
245
|
)
|
246
246
|
end
|
247
247
|
|
@@ -250,7 +250,7 @@ module Tapioca
|
|
250
250
|
instance_module.create_method(
|
251
251
|
"#{machine.name}?",
|
252
252
|
parameters: [create_param("state", type: "T.any(String, Symbol)")],
|
253
|
-
return_type: "T::Boolean"
|
253
|
+
return_type: "T::Boolean",
|
254
254
|
)
|
255
255
|
end
|
256
256
|
|
@@ -264,12 +264,12 @@ module Tapioca
|
|
264
264
|
instance_module.create_method(
|
265
265
|
events_attribute,
|
266
266
|
parameters: [create_rest_param("args", type: "T.untyped")],
|
267
|
-
return_type: "T::Array[T.any(String, Symbol)]"
|
267
|
+
return_type: "T::Array[T.any(String, Symbol)]",
|
268
268
|
)
|
269
269
|
instance_module.create_method(
|
270
270
|
transitions_attribute,
|
271
271
|
parameters: [create_rest_param("args", type: "T.untyped")],
|
272
|
-
return_type: "T::Array[::StateMachines::Transition]"
|
272
|
+
return_type: "T::Array[::StateMachines::Transition]",
|
273
273
|
)
|
274
274
|
instance_module.create_method(
|
275
275
|
"fire_#{event_attribute}",
|
@@ -277,26 +277,26 @@ module Tapioca
|
|
277
277
|
create_param("event", type: "T.any(String, Symbol)"),
|
278
278
|
create_rest_param("args", type: "T.untyped"),
|
279
279
|
],
|
280
|
-
return_type: "T::Boolean"
|
280
|
+
return_type: "T::Boolean",
|
281
281
|
)
|
282
282
|
if machine.action
|
283
283
|
instance_module.create_method(
|
284
284
|
event_attribute,
|
285
|
-
return_type: "T.nilable(Symbol)"
|
285
|
+
return_type: "T.nilable(Symbol)",
|
286
286
|
)
|
287
287
|
instance_module.create_method(
|
288
288
|
"#{event_attribute}=",
|
289
289
|
parameters: [create_param("value", type: "T.any(String, Symbol)")],
|
290
|
-
return_type: "T.any(String, Symbol)"
|
290
|
+
return_type: "T.any(String, Symbol)",
|
291
291
|
)
|
292
292
|
instance_module.create_method(
|
293
293
|
event_transition_attribute,
|
294
|
-
return_type: "T.nilable(::StateMachines::Transition)"
|
294
|
+
return_type: "T.nilable(::StateMachines::Transition)",
|
295
295
|
)
|
296
296
|
instance_module.create_method(
|
297
297
|
"#{event_transition_attribute}=",
|
298
298
|
parameters: [create_param("value", type: "::StateMachines::Transition")],
|
299
|
-
return_type: "::StateMachines::Transition"
|
299
|
+
return_type: "::StateMachines::Transition",
|
300
300
|
)
|
301
301
|
end
|
302
302
|
end
|
@@ -308,7 +308,7 @@ module Tapioca
|
|
308
308
|
instance_module.create_method(
|
309
309
|
paths_attribute,
|
310
310
|
parameters: [create_rest_param("args", type: "T.untyped")],
|
311
|
-
return_type: "T::Array[::StateMachines::Transition]"
|
311
|
+
return_type: "T::Array[::StateMachines::Transition]",
|
312
312
|
)
|
313
313
|
end
|
314
314
|
|
@@ -316,7 +316,7 @@ module Tapioca
|
|
316
316
|
params(
|
317
317
|
instance_module: RBI::Module,
|
318
318
|
class_module: RBI::Module,
|
319
|
-
machine: ::StateMachines::Machine
|
319
|
+
machine: ::StateMachines::Machine,
|
320
320
|
).void
|
321
321
|
end
|
322
322
|
def define_name_helpers(instance_module, class_module, machine)
|
@@ -326,20 +326,20 @@ module Tapioca
|
|
326
326
|
class_module.create_method(
|
327
327
|
"human_#{name_attribute}",
|
328
328
|
parameters: [create_param("state", type: "T.any(String, Symbol)")],
|
329
|
-
return_type: "String"
|
329
|
+
return_type: "String",
|
330
330
|
)
|
331
331
|
class_module.create_method(
|
332
332
|
"human_#{event_name_attribute}",
|
333
333
|
parameters: [create_param("event", type: "T.any(String, Symbol)")],
|
334
|
-
return_type: "String"
|
334
|
+
return_type: "String",
|
335
335
|
)
|
336
336
|
instance_module.create_method(
|
337
337
|
name_attribute,
|
338
|
-
return_type: "T.any(String, Symbol)"
|
338
|
+
return_type: "T.any(String, Symbol)",
|
339
339
|
)
|
340
340
|
instance_module.create_method(
|
341
341
|
"human_#{name_attribute}",
|
342
|
-
return_type: "String"
|
342
|
+
return_type: "String",
|
343
343
|
)
|
344
344
|
end
|
345
345
|
|
@@ -354,7 +354,7 @@ module Tapioca
|
|
354
354
|
class_module.create_method(
|
355
355
|
method.to_s,
|
356
356
|
parameters: [create_rest_param("states", type: "T.any(String, Symbol)")],
|
357
|
-
return_type: "T.untyped"
|
357
|
+
return_type: "T.untyped",
|
358
358
|
)
|
359
359
|
end
|
360
360
|
end
|
@@ -41,6 +41,8 @@ module Tapioca
|
|
41
41
|
"::ActiveSupport::TimeWithZone"
|
42
42
|
when ActiveRecord::Enum::EnumType
|
43
43
|
"::String"
|
44
|
+
when ActiveRecord::Type::Serialized
|
45
|
+
serialized_column_type(column_type)
|
44
46
|
else
|
45
47
|
handle_unknown_type(column_type)
|
46
48
|
end
|
@@ -119,6 +121,23 @@ module Tapioca
|
|
119
121
|
"T.any(::String, ::Symbol)"
|
120
122
|
end
|
121
123
|
end
|
124
|
+
|
125
|
+
sig { params(column_type: ActiveRecord::Type::Serialized).returns(String) }
|
126
|
+
def serialized_column_type(column_type)
|
127
|
+
case column_type.coder
|
128
|
+
when ActiveRecord::Coders::YAMLColumn
|
129
|
+
case column_type.coder.object_class
|
130
|
+
when Array.singleton_class
|
131
|
+
"T::Array[T.untyped]"
|
132
|
+
when Hash.singleton_class
|
133
|
+
"T::Hash[T.untyped, T.untyped]"
|
134
|
+
else
|
135
|
+
"T.untyped"
|
136
|
+
end
|
137
|
+
else
|
138
|
+
"T.untyped"
|
139
|
+
end
|
140
|
+
end
|
122
141
|
end
|
123
142
|
end
|
124
143
|
end
|
@@ -25,7 +25,7 @@ module Tapioca
|
|
25
25
|
when GraphQL::Types::ISO8601Date.singleton_class
|
26
26
|
type_for_constant(Date)
|
27
27
|
when GraphQL::Types::ISO8601DateTime.singleton_class
|
28
|
-
type_for_constant(
|
28
|
+
type_for_constant(Time)
|
29
29
|
when GraphQL::Types::JSON.singleton_class
|
30
30
|
"T::Hash[::String, T.untyped]"
|
31
31
|
when GraphQL::Schema::Enum.singleton_class
|
data/lib/tapioca/dsl/pipeline.rb
CHANGED
@@ -36,7 +36,7 @@ module Tapioca
|
|
36
36
|
)
|
37
37
|
@active_compilers = T.let(
|
38
38
|
gather_active_compilers(requested_compilers, excluded_compilers),
|
39
|
-
T::Enumerable[T.class_of(Compiler)]
|
39
|
+
T::Enumerable[T.class_of(Compiler)],
|
40
40
|
)
|
41
41
|
@requested_constants = requested_constants
|
42
42
|
@error_handler = error_handler
|
@@ -46,7 +46,7 @@ module Tapioca
|
|
46
46
|
|
47
47
|
sig do
|
48
48
|
type_parameters(:T).params(
|
49
|
-
blk: T.proc.params(constant: Module, rbi: RBI::File).returns(T.type_parameter(:T))
|
49
|
+
blk: T.proc.params(constant: Module, rbi: RBI::File).returns(T.type_parameter(:T)),
|
50
50
|
).returns(T::Array[T.type_parameter(:T)])
|
51
51
|
end
|
52
52
|
def run(&blk)
|
@@ -63,7 +63,7 @@ module Tapioca
|
|
63
63
|
|
64
64
|
result = Executor.new(
|
65
65
|
constants_to_process,
|
66
|
-
number_of_workers: @number_of_workers
|
66
|
+
number_of_workers: @number_of_workers,
|
67
67
|
).run_in_parallel do |constant|
|
68
68
|
rbi = rbi_for_constant(constant)
|
69
69
|
next if rbi.nil?
|
@@ -105,7 +105,7 @@ module Tapioca
|
|
105
105
|
sig do
|
106
106
|
params(
|
107
107
|
requested_compilers: T::Array[T.class_of(Compiler)],
|
108
|
-
excluded_compilers: T::Array[T.class_of(Compiler)]
|
108
|
+
excluded_compilers: T::Array[T.class_of(Compiler)],
|
109
109
|
).returns(T::Enumerable[T.class_of(Compiler)])
|
110
110
|
end
|
111
111
|
def gather_active_compilers(requested_compilers, excluded_compilers)
|
@@ -146,6 +146,7 @@ module Tapioca
|
|
146
146
|
constants_by_name
|
147
147
|
.keys
|
148
148
|
.map { |name| T.cast(Runtime::Reflection.constantize(name), Module) }
|
149
|
+
.select { |mod| Runtime::Reflection.constant_defined?(mod) }
|
149
150
|
.to_set
|
150
151
|
end
|
151
152
|
|
data/lib/tapioca/executor.rb
CHANGED
@@ -16,13 +16,13 @@ module Tapioca
|
|
16
16
|
# one has at least 4 items to process
|
17
17
|
@number_of_workers = T.let(
|
18
18
|
number_of_workers || [Etc.nprocessors, (queue.length.to_f / MINIMUM_ITEMS_PER_WORKER).ceil].min,
|
19
|
-
Integer
|
19
|
+
Integer,
|
20
20
|
)
|
21
21
|
end
|
22
22
|
|
23
23
|
sig do
|
24
24
|
type_parameters(:T).params(
|
25
|
-
block: T.proc.params(item: T.untyped).returns(T.type_parameter(:T))
|
25
|
+
block: T.proc.params(item: T.untyped).returns(T.type_parameter(:T)),
|
26
26
|
).returns(T::Array[T.type_parameter(:T)])
|
27
27
|
end
|
28
28
|
def run_in_parallel(&block)
|
data/lib/tapioca/gem/events.rb
CHANGED
@@ -124,7 +124,7 @@ module Tapioca
|
|
124
124
|
method: UnboundMethod,
|
125
125
|
node: RBI::Method,
|
126
126
|
signature: T.untyped,
|
127
|
-
parameters: T::Array[[Symbol, String]]
|
127
|
+
parameters: T::Array[[Symbol, String]],
|
128
128
|
).void.checked(:never)
|
129
129
|
end
|
130
130
|
def initialize(symbol, constant, method, node, signature, parameters) # rubocop:disable Metrics/ParameterLists
|