tapioca 0.11.17 → 0.13.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +122 -100
- data/lib/tapioca/commands/abstract_dsl.rb +3 -2
- data/lib/tapioca/commands/abstract_gem.rb +3 -1
- data/lib/tapioca/dsl/compilers/aasm.rb +1 -6
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +1 -5
- data/lib/tapioca/dsl/compilers/action_mailer.rb +1 -5
- data/lib/tapioca/dsl/compilers/action_text.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_job.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +4 -11
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +10 -6
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +1 -7
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +2 -9
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +253 -66
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_store.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +1 -7
- data/lib/tapioca/dsl/compilers/active_resource.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_storage.rb +1 -6
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +1 -5
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +6 -16
- data/lib/tapioca/dsl/compilers/config.rb +1 -5
- data/lib/tapioca/dsl/compilers/frozen_record.rb +1 -5
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +2 -6
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +2 -6
- data/lib/tapioca/dsl/compilers/identity_cache.rb +1 -7
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +1 -7
- data/lib/tapioca/dsl/compilers/kredis.rb +1 -5
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +1 -5
- data/lib/tapioca/dsl/compilers/protobuf.rb +8 -5
- data/lib/tapioca/dsl/compilers/rails_generators.rb +1 -6
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +1 -5
- data/lib/tapioca/dsl/compilers/smart_properties.rb +1 -7
- data/lib/tapioca/dsl/compilers/state_machines.rb +1 -7
- data/lib/tapioca/dsl/compilers/url_helpers.rb +17 -16
- data/lib/tapioca/dsl/extensions/active_record.rb +4 -2
- data/lib/tapioca/dsl/extensions/frozen_record.rb +6 -2
- data/lib/tapioca/dsl/extensions/kredis.rb +6 -2
- data/lib/tapioca/dsl/helpers/active_model_type_helper.rb +70 -0
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +3 -35
- data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +2 -0
- data/lib/tapioca/dsl/pipeline.rb +1 -1
- data/lib/tapioca/gem/listeners/sorbet_props.rb +2 -1
- data/lib/tapioca/gemfile.rb +12 -1
- data/lib/tapioca/rbi_ext/model.rb +38 -6
- data/lib/tapioca/version.rb +1 -1
- metadata +6 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f655f69697a5c375a3e04eef733d55213d2ea83b7392f35e3f81ed61ef4f93e4
|
4
|
+
data.tar.gz: 1ba60b67539a5034080dd9247f2f005593f25bcb2f01d72b72bccfb9a1f77f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99e5157e6d3b82922fb321d9eed18813bd8964cd02a9e253653c73ae6fff56529638e129532bf165dae9ec43e191e9186b4e6a7e4481ea0e4f11d5e2675b2f37
|
7
|
+
data.tar.gz: 22e178bf5afe57e2fa348606bf3cdbc8085cb4e8f735cdf1ad06665e27e6b5e08085d1eef74bba823eab87b3e1f76f12c02df5455a4fd182f11455744a5ce27c
|
data/README.md
CHANGED
@@ -40,6 +40,7 @@ Tapioca makes it easy to work with [Sorbet](https://sorbet.org) in your codebase
|
|
40
40
|
* [Excluding a gem from RBI generation](#excluding-a-gem-from-rbi-generation)
|
41
41
|
* [Changing the strictness level of the RBI for a gem](#changing-the-strictness-level-of-the-rbi-for-a-gem)
|
42
42
|
* [Keeping RBI files for gems up-to-date](#keeping-rbi-files-for-gems-up-to-date)
|
43
|
+
* [Importing hand written signatures from gem's `rbi/` folder](#importing-hand-written-signatures-from-gems-rbi-folder)
|
43
44
|
* [Pulling RBI annotations from remote sources](#pulling-rbi-annotations-from-remote-sources)
|
44
45
|
* [Basic authentication](#basic-authentication)
|
45
46
|
* [Using a .netrc file](#using-a-netrc-file)
|
@@ -83,10 +84,10 @@ Commands:
|
|
83
84
|
tapioca todo # Generate the list of unresolved constants
|
84
85
|
|
85
86
|
Options:
|
86
|
-
-c, [--config=<config file path>]
|
87
|
-
|
88
|
-
-V, [--verbose], [--no-verbose]
|
89
|
-
|
87
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
88
|
+
# Default: sorbet/tapioca/config.yml
|
89
|
+
-V, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output for debugging purposes
|
90
|
+
# Default: false
|
90
91
|
|
91
92
|
```
|
92
93
|
<!-- END_HELP -->
|
@@ -117,10 +118,10 @@ Usage:
|
|
117
118
|
tapioca init
|
118
119
|
|
119
120
|
Options:
|
120
|
-
-c, [--config=<config file path>]
|
121
|
-
|
122
|
-
-V, [--verbose], [--no-verbose]
|
123
|
-
|
121
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
122
|
+
# Default: sorbet/tapioca/config.yml
|
123
|
+
-V, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output for debugging purposes
|
124
|
+
# Default: false
|
124
125
|
|
125
126
|
Get project ready for type checking
|
126
127
|
```
|
@@ -164,43 +165,43 @@ Usage:
|
|
164
165
|
tapioca gem [gem...]
|
165
166
|
|
166
167
|
Options:
|
167
|
-
--out, -o, [--outdir=directory]
|
168
|
-
|
169
|
-
[--file-header], [--no-file-header]
|
170
|
-
|
171
|
-
[--all], [--no-all]
|
172
|
-
|
173
|
-
--pre, -b, [--prerequire=file]
|
174
|
-
--post, -a, [--postrequire=file]
|
175
|
-
|
176
|
-
-x, [--exclude=gem [gem ...]]
|
177
|
-
[--include-dependencies], [--no-include-dependencies] # Generate RBI files for dependencies of the given gem(s)
|
178
|
-
|
179
|
-
--typed, -t, [--typed-overrides=gem:level [gem:level ...]]
|
180
|
-
|
181
|
-
[--verify], [--no-verify]
|
182
|
-
|
183
|
-
[--doc], [--no-doc]
|
184
|
-
|
185
|
-
[--loc], [--no-loc]
|
186
|
-
|
187
|
-
[--exported-gem-rbis], [--no-exported-gem-rbis]
|
188
|
-
|
189
|
-
-w, [--workers=N]
|
190
|
-
[--auto-strictness], [--no-auto-strictness]
|
191
|
-
|
192
|
-
--dsl-dir, [--dsl-dir=directory]
|
193
|
-
|
194
|
-
[--rbi-max-line-length=N]
|
195
|
-
|
196
|
-
-e, [--environment=ENVIRONMENT]
|
197
|
-
|
198
|
-
[--halt-upon-load-error], [--no-halt-upon-load-error] # Halt upon a load error while loading the Rails application
|
199
|
-
|
200
|
-
-c, [--config=<config file path>]
|
201
|
-
|
202
|
-
-V, [--verbose], [--no-verbose]
|
203
|
-
|
168
|
+
--out, -o, [--outdir=directory] # The output directory for generated gem RBI files
|
169
|
+
# Default: sorbet/rbi/gems
|
170
|
+
[--file-header], [--no-file-header], [--skip-file-header] # Add a "This file is generated" header on top of each generated RBI file
|
171
|
+
# Default: true
|
172
|
+
[--all], [--no-all], [--skip-all] # Regenerate RBI files for all gems
|
173
|
+
# Default: false
|
174
|
+
--pre, -b, [--prerequire=file] # A file to be required before Bundler.require is called
|
175
|
+
--post, -a, [--postrequire=file] # A file to be required after Bundler.require is called
|
176
|
+
# Default: sorbet/tapioca/require.rb
|
177
|
+
-x, [--exclude=gem [gem ...]] # Exclude the given gem(s) from RBI generation
|
178
|
+
[--include-dependencies], [--no-include-dependencies], [--skip-include-dependencies] # Generate RBI files for dependencies of the given gem(s)
|
179
|
+
# Default: false
|
180
|
+
--typed, -t, [--typed-overrides=gem:level [gem:level ...]] # Override for typed sigils for generated gem RBIs
|
181
|
+
# Default: {"activesupport"=>"false"}
|
182
|
+
[--verify], [--no-verify], [--skip-verify] # Verify RBIs are up-to-date
|
183
|
+
# Default: false
|
184
|
+
[--doc], [--no-doc], [--skip-doc] # Include YARD documentation from sources when generating RBIs. Warning: this might be slow
|
185
|
+
# Default: true
|
186
|
+
[--loc], [--no-loc], [--skip-loc] # Include comments with source location when generating RBIs
|
187
|
+
# Default: true
|
188
|
+
[--exported-gem-rbis], [--no-exported-gem-rbis], [--skip-exported-gem-rbis] # Include RBIs found in the `rbi/` directory of the gem
|
189
|
+
# Default: true
|
190
|
+
-w, [--workers=N] # Number of parallel workers to use when generating RBIs (default: auto)
|
191
|
+
[--auto-strictness], [--no-auto-strictness], [--skip-auto-strictness] # Autocorrect strictness in gem RBIs in case of conflict with the DSL RBIs
|
192
|
+
# Default: true
|
193
|
+
--dsl-dir, [--dsl-dir=directory] # The DSL directory used to correct gems strictnesses
|
194
|
+
# Default: sorbet/rbi/dsl
|
195
|
+
[--rbi-max-line-length=N] # Set the max line length of generated RBIs. Signatures longer than the max line length will be wrapped
|
196
|
+
# Default: 120
|
197
|
+
-e, [--environment=ENVIRONMENT] # The Rack/Rails environment to use when generating RBIs
|
198
|
+
# Default: development
|
199
|
+
[--halt-upon-load-error], [--no-halt-upon-load-error], [--skip-halt-upon-load-error] # Halt upon a load error while loading the Rails application
|
200
|
+
# Default: true
|
201
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
202
|
+
# Default: sorbet/tapioca/config.yml
|
203
|
+
-V, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output for debugging purposes
|
204
|
+
# Default: false
|
204
205
|
|
205
206
|
Generate RBIs from gems
|
206
207
|
```
|
@@ -223,18 +224,18 @@ For gems that have a normal default `require` and that load all of their constan
|
|
223
224
|
For example, suppose you are using the class `BetterHtml::Parser` exported from the `better_html` gem. Just doing a `require "better_html"` (which is the default require) does not load that type:
|
224
225
|
|
225
226
|
```shell
|
226
|
-
$ bundle exec
|
227
|
+
$ bundle exec irb
|
227
228
|
|
228
|
-
|
229
|
+
irb(main):001> require 'better_html'
|
229
230
|
=> true
|
230
|
-
|
231
|
+
irb(main):002> BetterHtml
|
231
232
|
=> BetterHtml
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
233
|
+
irb(main):003> BetterHtml::Parser
|
234
|
+
(irb):3:in '<main>': uninitialized constant BetterHtml::Parser (NameError)
|
235
|
+
Did you mean? BetterHtml::ParserError
|
236
|
+
irb(main):004> require 'better_html/parser'
|
236
237
|
=> true
|
237
|
-
|
238
|
+
irb(main):005> BetterHtml::Parser
|
238
239
|
=> BetterHtml::Parser
|
239
240
|
```
|
240
241
|
|
@@ -315,7 +316,7 @@ gem:
|
|
315
316
|
|
316
317
|
#### Keeping RBI files for gems up-to-date
|
317
318
|
|
318
|
-
To ensure all RBI files for gems are
|
319
|
+
To ensure all RBI files for gems are present and have the correct version based on your `Gemfile.lock`, Tapioca provides a `--verify` option:
|
319
320
|
|
320
321
|
```shell
|
321
322
|
$ bin/tapioca gems --verify
|
@@ -325,7 +326,16 @@ Checking for out-of-date RBIs...
|
|
325
326
|
Nothing to do, all RBIs are up-to-date.
|
326
327
|
```
|
327
328
|
|
328
|
-
This option can be used
|
329
|
+
This option can be used in CI to make sure the RBI files are *up-to-date* and ensure accurate type checking.
|
330
|
+
|
331
|
+
**Warning**: doing so will break your normal automated dependency update workflow as every pull request opened to bump a gem version will fail CI since the RBI will be out-of-date. You will need to either set up additional automation (eg [Dependabot](https://github.com/dependabot/dependabot-core/issues/5962#issuecomment-1303781931)), or manually run `bin/tapioca gems` and commit the results.
|
332
|
+
|
333
|
+
**Warning**: Verification ONLY ensures the RBI files are present, used and have the correct version based on the gem version in your `Gemfile.lock`. It's possible for your RBIs to be out-of-date if RBIs were not regenerated following an update to tapioca itself or if a another gem that injects functionality (e.g. `turbo-rails`) was installed/updated/removed. To ensure RBIs are completely up-to-date, you must run `bin/tapioca gems --all` but it's not recommended to do this in CI as it's an expensive operation.
|
334
|
+
|
335
|
+
|
336
|
+
#### Importing hand written signatures from gem's `rbi/` folder
|
337
|
+
|
338
|
+
Tapioca will import any signatures found in the `rbi/` folder of a given gem and combine them with the RBIs it generates. This is useful when a gem doesn't want to depend on `sorbet-runtime` but still wants to provide type safety to users during static checks. Note that the `rbi/` folder needs to be included in the gem release using the `.gemspec` file. Applications can choose not to import these signatures using the `--no-exported-gem-rbis` flag.
|
329
339
|
|
330
340
|
### Pulling RBI annotations from remote sources
|
331
341
|
|
@@ -357,14 +367,14 @@ Usage:
|
|
357
367
|
Options:
|
358
368
|
[--sources=one two three] # URIs of the sources to pull gem RBI annotations from
|
359
369
|
# Default: "https://raw.githubusercontent.com/Shopify/rbi-central/main"
|
360
|
-
[--netrc], [--no-netrc]
|
370
|
+
[--netrc], [--no-netrc], [--skip-netrc] # Use .netrc to authenticate to private sources
|
361
371
|
# Default: true
|
362
372
|
[--netrc-file=NETRC_FILE] # Path to .netrc file
|
363
373
|
[--auth=AUTH] # HTTP authorization header for private sources
|
364
374
|
--typed, -t, [--typed-overrides=gem:level [gem:level ...]] # Override for typed sigils for pulled annotations
|
365
375
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
366
376
|
# Default: sorbet/tapioca/config.yml
|
367
|
-
-V, [--verbose], [--no-verbose]
|
377
|
+
-V, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output for debugging purposes
|
368
378
|
# Default: false
|
369
379
|
|
370
380
|
Pull gem RBI annotations from remote sources
|
@@ -467,32 +477,32 @@ Usage:
|
|
467
477
|
tapioca dsl [constant...]
|
468
478
|
|
469
479
|
Options:
|
470
|
-
--out, -o, [--outdir=directory]
|
471
|
-
|
472
|
-
[--file-header], [--no-file-header]
|
473
|
-
|
474
|
-
[--only=compiler [compiler ...]]
|
475
|
-
[--exclude=compiler [compiler ...]]
|
476
|
-
[--verify], [--no-verify]
|
477
|
-
|
478
|
-
-q, [--quiet], [--no-quiet]
|
479
|
-
|
480
|
-
-w, [--workers=N]
|
481
|
-
|
482
|
-
[--rbi-max-line-length=N]
|
483
|
-
|
484
|
-
-e, [--environment=ENVIRONMENT]
|
485
|
-
|
486
|
-
-l, [--list-compilers], [--no-list-compilers]
|
487
|
-
|
488
|
-
[--app-root=APP_ROOT]
|
489
|
-
|
490
|
-
[--halt-upon-load-error], [--no-halt-upon-load-error] # Halt upon a load error while loading the Rails application
|
491
|
-
|
492
|
-
-c, [--config=<config file path>]
|
493
|
-
|
494
|
-
-V, [--verbose], [--no-verbose]
|
495
|
-
|
480
|
+
--out, -o, [--outdir=directory] # The output directory for generated DSL RBI files
|
481
|
+
# Default: sorbet/rbi/dsl
|
482
|
+
[--file-header], [--no-file-header], [--skip-file-header] # Add a "This file is generated" header on top of each generated RBI file
|
483
|
+
# Default: true
|
484
|
+
[--only=compiler [compiler ...]] # Only run supplied DSL compiler(s)
|
485
|
+
[--exclude=compiler [compiler ...]] # Exclude supplied DSL compiler(s)
|
486
|
+
[--verify], [--no-verify], [--skip-verify] # Verifies RBIs are up-to-date
|
487
|
+
# Default: false
|
488
|
+
-q, [--quiet], [--no-quiet], [--skip-quiet] # Suppresses file creation output
|
489
|
+
# Default: false
|
490
|
+
-w, [--workers=N] # Number of parallel workers to use when generating RBIs (default: 2)
|
491
|
+
# Default: 2
|
492
|
+
[--rbi-max-line-length=N] # Set the max line length of generated RBIs. Signatures longer than the max line length will be wrapped
|
493
|
+
# Default: 120
|
494
|
+
-e, [--environment=ENVIRONMENT] # The Rack/Rails environment to use when generating RBIs
|
495
|
+
# Default: development
|
496
|
+
-l, [--list-compilers], [--no-list-compilers], [--skip-list-compilers] # List all loaded compilers
|
497
|
+
# Default: false
|
498
|
+
[--app-root=APP_ROOT] # The path to the Rails application
|
499
|
+
# Default: .
|
500
|
+
[--halt-upon-load-error], [--no-halt-upon-load-error], [--skip-halt-upon-load-error] # Halt upon a load error while loading the Rails application
|
501
|
+
# Default: true
|
502
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
503
|
+
# Default: sorbet/tapioca/config.yml
|
504
|
+
-V, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output for debugging purposes
|
505
|
+
# Default: false
|
496
506
|
|
497
507
|
Generate RBIs for dynamic methods
|
498
508
|
```
|
@@ -521,6 +531,18 @@ Reason:
|
|
521
531
|
|
522
532
|
This option can be used on CI to make sure the RBI files are always up-to-date and ensure accurate type checking.
|
523
533
|
|
534
|
+
If you are using Rails, you can configure `tapioca dsl` to run after each migration:
|
535
|
+
|
536
|
+
```ruby
|
537
|
+
# Rakefile
|
538
|
+
if Rails.env.development?
|
539
|
+
namespace :db do
|
540
|
+
task :migrate do # Appends to the existing `db:migrate` task
|
541
|
+
system("bundle exec tapioca dsl", exception: true)
|
542
|
+
end
|
543
|
+
end
|
544
|
+
```
|
545
|
+
|
524
546
|
#### Writing custom DSL compilers
|
525
547
|
|
526
548
|
It is possible to create your own compilers for DSLs not supported by Tapioca out of the box.
|
@@ -840,23 +862,23 @@ Usage:
|
|
840
862
|
tapioca check-shims
|
841
863
|
|
842
864
|
Options:
|
843
|
-
[--gem-rbi-dir=GEM_RBI_DIR]
|
844
|
-
|
845
|
-
[--dsl-rbi-dir=DSL_RBI_DIR]
|
846
|
-
|
847
|
-
[--shim-rbi-dir=SHIM_RBI_DIR]
|
848
|
-
|
849
|
-
[--annotations-rbi-dir=ANNOTATIONS_RBI_DIR]
|
850
|
-
|
851
|
-
[--todo-rbi-file=TODO_RBI_FILE]
|
852
|
-
|
853
|
-
[--payload], [--no-payload]
|
854
|
-
|
855
|
-
-w, [--workers=N]
|
856
|
-
-c, [--config=<config file path>]
|
857
|
-
|
858
|
-
-V, [--verbose], [--no-verbose]
|
859
|
-
|
865
|
+
[--gem-rbi-dir=GEM_RBI_DIR] # Path to gem RBIs
|
866
|
+
# Default: sorbet/rbi/gems
|
867
|
+
[--dsl-rbi-dir=DSL_RBI_DIR] # Path to DSL RBIs
|
868
|
+
# Default: sorbet/rbi/dsl
|
869
|
+
[--shim-rbi-dir=SHIM_RBI_DIR] # Path to shim RBIs
|
870
|
+
# Default: sorbet/rbi/shims
|
871
|
+
[--annotations-rbi-dir=ANNOTATIONS_RBI_DIR] # Path to annotations RBIs
|
872
|
+
# Default: sorbet/rbi/annotations
|
873
|
+
[--todo-rbi-file=TODO_RBI_FILE] # Path to the generated todo RBI file
|
874
|
+
# Default: sorbet/rbi/todo.rbi
|
875
|
+
[--payload], [--no-payload], [--skip-payload] # Check shims against Sorbet's payload
|
876
|
+
# Default: true
|
877
|
+
-w, [--workers=N] # Number of parallel workers (default: auto)
|
878
|
+
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
879
|
+
# Default: sorbet/tapioca/config.yml
|
880
|
+
-V, [--verbose], [--no-verbose], [--skip-verbose] # Verbose output for debugging purposes
|
881
|
+
# Default: false
|
860
882
|
|
861
883
|
Check duplicated definitions in shim RBIs
|
862
884
|
```
|
@@ -175,10 +175,11 @@ module Tapioca
|
|
175
175
|
|
176
176
|
unless unprocessable_compilers.empty?
|
177
177
|
message = unprocessable_compilers.map do |name, _|
|
178
|
-
set_color("
|
178
|
+
set_color("Warning: Cannot find compiler '#{name}'", :yellow)
|
179
179
|
end.join("\n")
|
180
180
|
|
181
|
-
|
181
|
+
say(message)
|
182
|
+
say("")
|
182
183
|
end
|
183
184
|
|
184
185
|
T.cast(compiler_map.values, T::Array[T.class_of(Tapioca::Dsl::Compiler)])
|
@@ -118,7 +118,9 @@ module Tapioca
|
|
118
118
|
reason: "types exported from the `#{gem.name}` gem",
|
119
119
|
) if @file_header
|
120
120
|
|
121
|
-
rbi.root =
|
121
|
+
rbi.root = Runtime::Trackers::Autoload.with_disabled_exits do
|
122
|
+
Tapioca::Gem::Pipeline.new(gem, include_doc: @include_doc, include_loc: @include_loc).compile
|
123
|
+
end
|
122
124
|
|
123
125
|
merge_with_exported_rbi(gem, rbi) if @include_exported_rbis
|
124
126
|
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
return
|
8
|
-
end
|
4
|
+
return unless defined?(ActiveModel::Attributes)
|
5
|
+
|
6
|
+
require "tapioca/dsl/helpers/active_model_type_helper"
|
9
7
|
|
10
8
|
module Tapioca
|
11
9
|
module Dsl
|
@@ -103,11 +101,6 @@ module Tapioca
|
|
103
101
|
|
104
102
|
sig { params(attribute_type_value: T.untyped).returns(::String) }
|
105
103
|
def type_for(attribute_type_value)
|
106
|
-
# This guarantees that the type will remain as T.untyped for attributes in the following form:
|
107
|
-
# attribute :name
|
108
|
-
# This is because for a generic attribute with no specified type, ActiveModel::Type::Value.new is returned
|
109
|
-
return "T.untyped" if attribute_type_value.instance_of?(ActiveModel::Type::Value)
|
110
|
-
|
111
104
|
type = case attribute_type_value
|
112
105
|
when ActiveModel::Type::Boolean
|
113
106
|
"T::Boolean"
|
@@ -124,7 +117,7 @@ module Tapioca
|
|
124
117
|
when ActiveModel::Type::String
|
125
118
|
"::String"
|
126
119
|
else
|
127
|
-
attribute_type_value
|
120
|
+
Helpers::ActiveModelTypeHelper.type_for(attribute_type_value)
|
128
121
|
end
|
129
122
|
|
130
123
|
as_nilable_type(type)
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require "active_model"
|
6
|
-
rescue LoadError
|
7
|
-
return
|
8
|
-
end
|
4
|
+
return unless defined?(ActiveModel::SecurePassword)
|
9
5
|
|
10
6
|
module Tapioca
|
11
7
|
module Dsl
|
@@ -82,7 +78,15 @@ module Tapioca
|
|
82
78
|
|
83
79
|
root.create_path(constant) do |klass|
|
84
80
|
methods.each do |method|
|
85
|
-
|
81
|
+
if method == :authenticate || method.start_with?("authenticate_")
|
82
|
+
klass.create_method(
|
83
|
+
method.to_s,
|
84
|
+
parameters: [create_param("unencrypted_password", type: "T.untyped")],
|
85
|
+
return_type: "T.any(#{constant}, FalseClass)",
|
86
|
+
)
|
87
|
+
else
|
88
|
+
create_method_from_def(klass, constant.instance_method(method))
|
89
|
+
end
|
86
90
|
end
|
87
91
|
end
|
88
92
|
end
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require "active_record"
|
6
|
-
rescue LoadError
|
7
|
-
return
|
8
|
-
end
|
4
|
+
return unless defined?(ActiveRecord::Base)
|
9
5
|
|
10
6
|
require "tapioca/dsl/helpers/active_record_column_type_helper"
|
11
7
|
require "tapioca/dsl/helpers/active_record_constants_helper"
|
@@ -1,11 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require "active_record"
|
6
|
-
rescue LoadError
|
7
|
-
return
|
8
|
-
end
|
4
|
+
return unless defined?(ActiveRecord::Base)
|
9
5
|
|
10
6
|
require "tapioca/dsl/helpers/active_record_column_type_helper"
|
11
7
|
require "tapioca/dsl/helpers/active_record_constants_helper"
|
@@ -1,13 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require "active_record"
|
6
|
-
rescue LoadError
|
7
|
-
# means ActiveRecord is not installed,
|
8
|
-
# so let's not even define the compiler.
|
9
|
-
return
|
10
|
-
end
|
4
|
+
return unless defined?(ActiveRecord::Base)
|
11
5
|
|
12
6
|
module Tapioca
|
13
7
|
module Dsl
|
@@ -1,14 +1,7 @@
|
|
1
1
|
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
|
5
|
-
require "rails"
|
6
|
-
require "active_record"
|
7
|
-
require "active_record/fixtures"
|
8
|
-
require "active_support/test_case"
|
9
|
-
rescue LoadError
|
10
|
-
return
|
11
|
-
end
|
4
|
+
return unless defined?(Rails) && defined?(ActiveSupport::TestCase) && defined?(ActiveRecord::TestFixtures)
|
12
5
|
|
13
6
|
module Tapioca
|
14
7
|
module Dsl
|
@@ -62,7 +55,7 @@ module Tapioca
|
|
62
55
|
|
63
56
|
sig { override.returns(T::Enumerable[Module]) }
|
64
57
|
def gather_constants
|
65
|
-
return [] unless Rails.application
|
58
|
+
return [] unless defined?(Rails.application) && Rails.application
|
66
59
|
|
67
60
|
[ActiveSupport::TestCase]
|
68
61
|
end
|