tapioca 0.16.0 → 0.16.1
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/lib/tapioca/commands/abstract_gem.rb +8 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +15 -0
- data/lib/tapioca/gem/listeners/methods.rb +13 -1
- data/lib/tapioca/gem/pipeline.rb +18 -2
- data/lib/tapioca/loaders/loader.rb +1 -1
- data/lib/tapioca/runtime/generic_type_registry.rb +1 -1
- data/lib/tapioca/runtime/reflection.rb +6 -1
- data/lib/tapioca/static/symbol_loader.rb +1 -1
- data/lib/tapioca/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02620ac27a54a716743952e003b0c4b3d8cfd8a1fe9ee580068007e570c0814a
|
4
|
+
data.tar.gz: 6901ae216ea51a7a92facf5c64e4de42262f7f86e79ebfa816c7a8b1ca9a5af1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 443333835093464931be7bcbf54e9dfad0e2241f099cc06fbca54c54dca284ab84c246343110dca2e5a64eaeee5d0d006bf22b3d955be9f64160d63ae807aeeb
|
7
|
+
data.tar.gz: 375a7ee0697b44f807161819bbbe6907eb8ee6f5ae76e791c73da4f748bd26bf3a86bfa3b28a6589503020890621c73f27506928c26e6c2078981dfb556cc7a5
|
@@ -119,7 +119,14 @@ module Tapioca
|
|
119
119
|
) if @file_header
|
120
120
|
|
121
121
|
rbi.root = Runtime::Trackers::Autoload.with_disabled_exits do
|
122
|
-
Tapioca::Gem::Pipeline.new(
|
122
|
+
Tapioca::Gem::Pipeline.new(
|
123
|
+
gem,
|
124
|
+
include_doc: @include_doc,
|
125
|
+
include_loc: @include_loc,
|
126
|
+
error_handler: ->(error) {
|
127
|
+
say_error(error, :bold, :red)
|
128
|
+
},
|
129
|
+
).compile
|
123
130
|
end
|
124
131
|
|
125
132
|
merge_with_exported_rbi(gem, rbi) if @include_exported_rbis
|
@@ -1024,6 +1024,21 @@ module Tapioca
|
|
1024
1024
|
end
|
1025
1025
|
end
|
1026
1026
|
end
|
1027
|
+
|
1028
|
+
# We are creating `#new` on the class itself since when called as `Model.new`
|
1029
|
+
# it doesn't allow for an array to be passed. If we kept it as a blanket it
|
1030
|
+
# would mean the passing any `T.untyped` value to the method would assume
|
1031
|
+
# the result is `T::Array` which is not the case majority of the time.
|
1032
|
+
model.create_method("new", class_method: true) do |method|
|
1033
|
+
method.add_opt_param("attributes", "nil")
|
1034
|
+
method.add_block_param("block")
|
1035
|
+
|
1036
|
+
method.add_sig do |sig|
|
1037
|
+
sig.add_param("attributes", "T.untyped")
|
1038
|
+
sig.add_param("block", "T.nilable(T.proc.params(object: #{constant_name}).void)")
|
1039
|
+
sig.return_type = constant_name
|
1040
|
+
end
|
1041
|
+
end
|
1027
1042
|
end
|
1028
1043
|
|
1029
1044
|
sig do
|
@@ -73,7 +73,7 @@ module Tapioca
|
|
73
73
|
return unless method_owned_by_constant?(method, constant)
|
74
74
|
return if @pipeline.symbol_in_payload?(symbol_name) && !@pipeline.method_in_gem?(method)
|
75
75
|
|
76
|
-
signature =
|
76
|
+
signature = lookup_signature_of(method)
|
77
77
|
method = T.let(signature.method, UnboundMethod) if signature
|
78
78
|
|
79
79
|
method_name = method.name.to_s
|
@@ -211,6 +211,18 @@ module Tapioca
|
|
211
211
|
def ignore?(event)
|
212
212
|
event.is_a?(Tapioca::Gem::ForeignScopeNodeAdded)
|
213
213
|
end
|
214
|
+
|
215
|
+
sig { params(method: UnboundMethod).returns(T.untyped) }
|
216
|
+
def lookup_signature_of(method)
|
217
|
+
signature_of!(method)
|
218
|
+
rescue LoadError, StandardError => error
|
219
|
+
@pipeline.error_handler.call(<<~MSG)
|
220
|
+
Unable to compile signature for method: #{method.owner}##{method.name}
|
221
|
+
Exception raised when loading signature: #{error.inspect}
|
222
|
+
MSG
|
223
|
+
|
224
|
+
nil
|
225
|
+
end
|
214
226
|
end
|
215
227
|
end
|
216
228
|
end
|
data/lib/tapioca/gem/pipeline.rb
CHANGED
@@ -13,12 +13,28 @@ module Tapioca
|
|
13
13
|
sig { returns(Gemfile::GemSpec) }
|
14
14
|
attr_reader :gem
|
15
15
|
|
16
|
-
sig { params(
|
17
|
-
|
16
|
+
sig { returns(T.proc.params(error: String).void) }
|
17
|
+
attr_reader :error_handler
|
18
|
+
|
19
|
+
sig do
|
20
|
+
params(
|
21
|
+
gem: Gemfile::GemSpec,
|
22
|
+
error_handler: T.proc.params(error: String).void,
|
23
|
+
include_doc: T::Boolean,
|
24
|
+
include_loc: T::Boolean,
|
25
|
+
).void
|
26
|
+
end
|
27
|
+
def initialize(
|
28
|
+
gem,
|
29
|
+
error_handler:,
|
30
|
+
include_doc: false,
|
31
|
+
include_loc: false
|
32
|
+
)
|
18
33
|
@root = T.let(RBI::Tree.new, RBI::Tree)
|
19
34
|
@gem = gem
|
20
35
|
@seen = T.let(Set.new, T::Set[String])
|
21
36
|
@alias_namespace = T.let(Set.new, T::Set[String])
|
37
|
+
@error_handler = error_handler
|
22
38
|
|
23
39
|
@events = T.let([], T::Array[Gem::Event])
|
24
40
|
|
@@ -230,7 +230,7 @@ module Tapioca
|
|
230
230
|
# The `eager_load_paths` method still exists, but doesn't return all paths anymore and causes Tapioca to miss some
|
231
231
|
# engine paths. The following commit is the change:
|
232
232
|
# https://github.com/rails/rails/commit/ebfca905db14020589c22e6937382e6f8f687664
|
233
|
-
sig { params(engine: T.class_of(Rails::Engine)).returns(T::Array[String]) }
|
233
|
+
T::Sig::WithoutRuntime.sig { params(engine: T.class_of(Rails::Engine)).returns(T::Array[String]) }
|
234
234
|
def eager_load_paths(engine)
|
235
235
|
config = engine.config
|
236
236
|
|
@@ -130,8 +130,13 @@ module Tapioca
|
|
130
130
|
end
|
131
131
|
|
132
132
|
sig { params(method: T.any(UnboundMethod, Method)).returns(T.untyped) }
|
133
|
-
def signature_of(method)
|
133
|
+
def signature_of!(method)
|
134
134
|
T::Utils.signature_for_method(method)
|
135
|
+
end
|
136
|
+
|
137
|
+
sig { params(method: T.any(UnboundMethod, Method)).returns(T.untyped) }
|
138
|
+
def signature_of(method)
|
139
|
+
signature_of!(method)
|
135
140
|
rescue LoadError, StandardError
|
136
141
|
nil
|
137
142
|
end
|
data/lib/tapioca/version.rb
CHANGED
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.16.
|
4
|
+
version: 0.16.1
|
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: 2024-08-
|
14
|
+
date: 2024-08-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -290,7 +290,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
290
290
|
- !ruby/object:Gem::Version
|
291
291
|
version: '0'
|
292
292
|
requirements: []
|
293
|
-
rubygems_version: 3.5.
|
293
|
+
rubygems_version: 3.5.17
|
294
294
|
signing_key:
|
295
295
|
specification_version: 4
|
296
296
|
summary: A Ruby Interface file generator for gems, core types and the Ruby standard
|