tapioca 0.11.12 → 0.11.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +16 -3
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +35 -24
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +14 -5
- data/lib/tapioca/helpers/env_helper.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: 071fd87cab365673ec36e85a0cf657865d2c71d1650d02ae7c17ac3133f124f3
|
4
|
+
data.tar.gz: 34a3b5e83928cb38eefbf57568ca8dc5d16c20ee6653da2ee591d6e3265d8d2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d97568a53647ceb3fe4e7bfd33dc3503cb95d8c95791dc0c0bf8429f9974c4a39d5d5e5aca16251ae866a07761f00ddbd5a224925b11c4a8378f682fd4deef1c
|
7
|
+
data.tar.gz: f44cccf226efaa3b0ccda730daf3419acb3cdcaeec7c699c91ba9e2f8b4fe59a7e157331afff1723f69f09ff2fc3ff5a208222b2eb86c1738806170578a3ec2b
|
data/README.md
CHANGED
@@ -86,6 +86,7 @@ Options:
|
|
86
86
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
87
87
|
# Default: sorbet/tapioca/config.yml
|
88
88
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
89
|
+
# Default: false
|
89
90
|
|
90
91
|
```
|
91
92
|
<!-- END_HELP -->
|
@@ -119,6 +120,7 @@ Options:
|
|
119
120
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
120
121
|
# Default: sorbet/tapioca/config.yml
|
121
122
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
123
|
+
# Default: false
|
122
124
|
|
123
125
|
Get project ready for type checking
|
124
126
|
```
|
@@ -167,14 +169,17 @@ Options:
|
|
167
169
|
[--file-header], [--no-file-header] # Add a "This file is generated" header on top of each generated RBI file
|
168
170
|
# Default: true
|
169
171
|
[--all], [--no-all] # Regenerate RBI files for all gems
|
172
|
+
# Default: false
|
170
173
|
--pre, -b, [--prerequire=file] # A file to be required before Bundler.require is called
|
171
174
|
--post, -a, [--postrequire=file] # A file to be required after Bundler.require is called
|
172
175
|
# Default: sorbet/tapioca/require.rb
|
173
176
|
-x, [--exclude=gem [gem ...]] # Exclude the given gem(s) from RBI generation
|
174
177
|
[--include-dependencies], [--no-include-dependencies] # Generate RBI files for dependencies of the given gem(s)
|
178
|
+
# Default: false
|
175
179
|
--typed, -t, [--typed-overrides=gem:level [gem:level ...]] # Override for typed sigils for generated gem RBIs
|
176
180
|
# Default: {"activesupport"=>"false"}
|
177
181
|
[--verify], [--no-verify] # Verify RBIs are up-to-date
|
182
|
+
# Default: false
|
178
183
|
[--doc], [--no-doc] # Include YARD documentation from sources when generating RBIs. Warning: this might be slow
|
179
184
|
# Default: true
|
180
185
|
[--loc], [--no-loc] # Include comments with source location when generating RBIs
|
@@ -195,6 +200,7 @@ Options:
|
|
195
200
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
196
201
|
# Default: sorbet/tapioca/config.yml
|
197
202
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
203
|
+
# Default: false
|
198
204
|
|
199
205
|
Generate RBIs from gems
|
200
206
|
```
|
@@ -350,7 +356,7 @@ Usage:
|
|
350
356
|
|
351
357
|
Options:
|
352
358
|
[--sources=one two three] # URIs of the sources to pull gem RBI annotations from
|
353
|
-
# Default:
|
359
|
+
# Default: "https://raw.githubusercontent.com/Shopify/rbi-central/main"
|
354
360
|
[--netrc], [--no-netrc] # Use .netrc to authenticate to private sources
|
355
361
|
# Default: true
|
356
362
|
[--netrc-file=NETRC_FILE] # Path to .netrc file
|
@@ -359,6 +365,7 @@ Options:
|
|
359
365
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
360
366
|
# Default: sorbet/tapioca/config.yml
|
361
367
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
368
|
+
# Default: false
|
362
369
|
|
363
370
|
Pull gem RBI annotations from remote sources
|
364
371
|
```
|
@@ -467,7 +474,9 @@ Options:
|
|
467
474
|
[--only=compiler [compiler ...]] # Only run supplied DSL compiler(s)
|
468
475
|
[--exclude=compiler [compiler ...]] # Exclude supplied DSL compiler(s)
|
469
476
|
[--verify], [--no-verify] # Verifies RBIs are up-to-date
|
477
|
+
# Default: false
|
470
478
|
-q, [--quiet], [--no-quiet] # Suppresses file creation output
|
479
|
+
# Default: false
|
471
480
|
-w, [--workers=N] # Number of parallel workers to use when generating RBIs (default: 2)
|
472
481
|
# Default: 2
|
473
482
|
[--rbi-max-line-length=N] # Set the max line length of generated RBIs. Signatures longer than the max line length will be wrapped
|
@@ -475,6 +484,7 @@ Options:
|
|
475
484
|
-e, [--environment=ENVIRONMENT] # The Rack/Rails environment to use when generating RBIs
|
476
485
|
# Default: development
|
477
486
|
-l, [--list-compilers], [--no-list-compilers] # List all loaded compilers
|
487
|
+
# Default: false
|
478
488
|
[--app-root=APP_ROOT] # The path to the Rails application
|
479
489
|
# Default: .
|
480
490
|
[--halt-upon-load-error], [--no-halt-upon-load-error] # Halt upon a load error while loading the Rails application
|
@@ -482,6 +492,7 @@ Options:
|
|
482
492
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
483
493
|
# Default: sorbet/tapioca/config.yml
|
484
494
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
495
|
+
# Default: false
|
485
496
|
|
486
497
|
Generate RBIs for dynamic methods
|
487
498
|
```
|
@@ -845,6 +856,7 @@ Options:
|
|
845
856
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
846
857
|
# Default: sorbet/tapioca/config.yml
|
847
858
|
-V, [--verbose], [--no-verbose] # Verbose output for debugging purposes
|
859
|
+
# Default: false
|
848
860
|
|
849
861
|
Check duplicated definitions in shim RBIs
|
850
862
|
```
|
@@ -126,6 +126,9 @@ module Tapioca
|
|
126
126
|
# include GeneratedAssociationRelationMethods
|
127
127
|
#
|
128
128
|
# sig { returns(T::Array[::Post]) }
|
129
|
+
# def to_a; end
|
130
|
+
#
|
131
|
+
# sig { returns(T::Array[::Post]) }
|
129
132
|
# def to_ary; end
|
130
133
|
#
|
131
134
|
# Elem = type_member { { fixed: ::Post } }
|
@@ -149,6 +152,9 @@ module Tapioca
|
|
149
152
|
# include GeneratedRelationMethods
|
150
153
|
#
|
151
154
|
# sig { returns(T::Array[::Post]) }
|
155
|
+
# def to_a; end
|
156
|
+
#
|
157
|
+
# sig { returns(T::Array[::Post]) }
|
152
158
|
# def to_ary; end
|
153
159
|
#
|
154
160
|
# Elem = type_member { { fixed: ::Post } }
|
@@ -226,6 +232,7 @@ module Tapioca
|
|
226
232
|
T::Array[Symbol],
|
227
233
|
)
|
228
234
|
BUILDER_METHODS = T.let([:new, :build, :create, :create!], T::Array[Symbol])
|
235
|
+
TO_ARRAY_METHODS = T.let([:to_ary, :to_a], T::Array[Symbol])
|
229
236
|
|
230
237
|
private
|
231
238
|
|
@@ -296,7 +303,9 @@ module Tapioca
|
|
296
303
|
klass.create_include(RelationMethodsModuleName)
|
297
304
|
klass.create_type_variable("Elem", type: "type_member", fixed: constant_name)
|
298
305
|
|
299
|
-
|
306
|
+
TO_ARRAY_METHODS.each do |method_name|
|
307
|
+
klass.create_method(method_name.to_s, return_type: "T::Array[#{constant_name}]")
|
308
|
+
end
|
300
309
|
end
|
301
310
|
|
302
311
|
create_relation_where_chain_class
|
@@ -312,7 +321,9 @@ module Tapioca
|
|
312
321
|
klass.create_include(AssociationRelationMethodsModuleName)
|
313
322
|
klass.create_type_variable("Elem", type: "type_member", fixed: constant_name)
|
314
323
|
|
315
|
-
|
324
|
+
TO_ARRAY_METHODS.each do |method_name|
|
325
|
+
klass.create_method(method_name.to_s, return_type: "T::Array[#{constant_name}]")
|
326
|
+
end
|
316
327
|
end
|
317
328
|
|
318
329
|
create_association_relation_where_chain_class
|
@@ -372,7 +383,9 @@ module Tapioca
|
|
372
383
|
klass.create_include(AssociationRelationMethodsModuleName)
|
373
384
|
klass.create_type_variable("Elem", type: "type_member", fixed: constant_name)
|
374
385
|
|
375
|
-
|
386
|
+
TO_ARRAY_METHODS.each do |method_name|
|
387
|
+
klass.create_method(method_name.to_s, return_type: "T::Array[#{constant_name}]")
|
388
|
+
end
|
376
389
|
create_collection_proxy_methods(klass)
|
377
390
|
end
|
378
391
|
end
|
@@ -40,23 +40,29 @@ module Tapioca
|
|
40
40
|
# # typed: true
|
41
41
|
#
|
42
42
|
# class Current
|
43
|
-
#
|
44
|
-
# def self.account; end
|
43
|
+
# include GeneratedAttributeMethods
|
45
44
|
#
|
46
|
-
#
|
47
|
-
#
|
45
|
+
# class << self
|
46
|
+
# sig { returns(T.untyped) }
|
47
|
+
# def account; end
|
48
48
|
#
|
49
|
-
#
|
50
|
-
#
|
49
|
+
# sig { params(account: T.untyped).returns(T.untyped) }
|
50
|
+
# def account=(account); end
|
51
51
|
#
|
52
|
-
#
|
53
|
-
#
|
52
|
+
# sig { params(user_id: Integer).void }
|
53
|
+
# def authenticate(user_id); end
|
54
54
|
#
|
55
|
-
#
|
56
|
-
#
|
55
|
+
# sig { returns(T.untyped) }
|
56
|
+
# def helper; end
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
# module GeneratedAttributeMethods
|
60
|
+
# sig { returns(T.untyped) }
|
61
|
+
# def account; end
|
57
62
|
#
|
58
|
-
#
|
59
|
-
#
|
63
|
+
# sig { params(account: T.untyped).returns(T.untyped) }
|
64
|
+
# def account=(account); end
|
65
|
+
# end
|
60
66
|
# end
|
61
67
|
# ~~~
|
62
68
|
class ActiveSupportCurrentAttributes < Compiler
|
@@ -71,20 +77,25 @@ module Tapioca
|
|
71
77
|
return if dynamic_methods.empty? && instance_methods.empty?
|
72
78
|
|
73
79
|
root.create_path(constant) do |current_attributes|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
80
|
+
current_attributes_methods_name = "GeneratedAttributeMethods"
|
81
|
+
current_attributes.create_module(current_attributes_methods_name) do |generated_attribute_methods|
|
82
|
+
dynamic_methods.each do |method|
|
83
|
+
method = method.to_s
|
84
|
+
# We want to generate each method both on the class
|
85
|
+
generate_method(current_attributes, method, class_method: true)
|
86
|
+
# and on the instance
|
87
|
+
generate_method(generated_attribute_methods, method, class_method: false)
|
88
|
+
end
|
81
89
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
90
|
+
instance_methods.each do |method|
|
91
|
+
# instance methods are only elevated to class methods
|
92
|
+
# no need to add separate instance methods for them
|
93
|
+
method = constant.instance_method(method)
|
94
|
+
create_method_from_def(current_attributes, method, class_method: true)
|
95
|
+
end
|
87
96
|
end
|
97
|
+
|
98
|
+
current_attributes.create_include(current_attributes_methods_name)
|
88
99
|
end
|
89
100
|
end
|
90
101
|
|
@@ -19,6 +19,7 @@ module Tapioca
|
|
19
19
|
else
|
20
20
|
argument.type
|
21
21
|
end
|
22
|
+
|
22
23
|
unwrapped_type = type.unwrap
|
23
24
|
|
24
25
|
parsed_type = case unwrapped_type
|
@@ -50,11 +51,7 @@ module Tapioca
|
|
50
51
|
signature = Runtime::Reflection.signature_of(method)
|
51
52
|
return_type = signature&.return_type
|
52
53
|
|
53
|
-
|
54
|
-
return_type.to_s
|
55
|
-
else
|
56
|
-
"T.untyped"
|
57
|
-
end
|
54
|
+
valid_return_type?(return_type) ? return_type.to_s : "T.untyped"
|
58
55
|
when GraphQL::Schema::InputObject.singleton_class
|
59
56
|
type_for_constant(unwrapped_type)
|
60
57
|
when Module
|
@@ -78,6 +75,13 @@ module Tapioca
|
|
78
75
|
|
79
76
|
sig { params(constant: Module).returns(String) }
|
80
77
|
def type_for_constant(constant)
|
78
|
+
if constant.instance_methods.include?(:prepare)
|
79
|
+
prepare_method = constant.instance_method(:prepare)
|
80
|
+
prepare_signature = Runtime::Reflection.signature_of(prepare_method)
|
81
|
+
|
82
|
+
return prepare_signature.return_type&.to_s if valid_return_type?(prepare_signature&.return_type)
|
83
|
+
end
|
84
|
+
|
81
85
|
Runtime::Reflection.qualified_name_of(constant) || "T.untyped"
|
82
86
|
end
|
83
87
|
|
@@ -85,6 +89,11 @@ module Tapioca
|
|
85
89
|
def has_replaceable_default?(argument)
|
86
90
|
!!argument.replace_null_with_default? && !argument.default_value.nil?
|
87
91
|
end
|
92
|
+
|
93
|
+
sig { params(return_type: T.nilable(T::Types::Base)).returns(T::Boolean) }
|
94
|
+
def valid_return_type?(return_type)
|
95
|
+
!!return_type && !(T::Private::Types::Void === return_type || T::Private::Types::NotTyped === return_type)
|
96
|
+
end
|
88
97
|
end
|
89
98
|
end
|
90
99
|
end
|
@@ -11,7 +11,7 @@ module Tapioca
|
|
11
11
|
sig { params(options: T::Hash[Symbol, T.untyped]).void }
|
12
12
|
def set_environment(options) # rubocop:disable Naming/AccessorMethodName
|
13
13
|
ENV["RAILS_ENV"] = ENV["RACK_ENV"] = options[:environment]
|
14
|
-
ENV["
|
14
|
+
ENV["RUBY_DEBUG_LAZY"] = "1"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
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.11.
|
4
|
+
version: 0.11.13
|
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-
|
14
|
+
date: 2023-12-06 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -293,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
293
293
|
- !ruby/object:Gem::Version
|
294
294
|
version: '0'
|
295
295
|
requirements: []
|
296
|
-
rubygems_version: 3.4.
|
296
|
+
rubygems_version: 3.4.22
|
297
297
|
signing_key:
|
298
298
|
specification_version: 4
|
299
299
|
summary: A Ruby Interface file generator for gems, core types and the Ruby standard
|