tapioca 0.17.10 → 0.18.0
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 +1 -0
- data/lib/tapioca/bundler_ext/auto_require_hook.rb +0 -3
- data/lib/tapioca/cli.rb +0 -2
- data/lib/tapioca/commands/annotations.rb +0 -2
- data/lib/tapioca/commands/check_shims.rb +0 -1
- data/lib/tapioca/commands/command.rb +0 -1
- data/lib/tapioca/dsl/compiler.rb +0 -4
- data/lib/tapioca/dsl/compilers/aasm.rb +0 -4
- data/lib/tapioca/dsl/compilers/action_controller_helpers.rb +0 -4
- data/lib/tapioca/dsl/compilers/action_mailer.rb +0 -4
- data/lib/tapioca/dsl/compilers/action_text.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_job.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_model_attributes.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_model_secure_password.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_model_validations_confirmation.rb +0 -2
- data/lib/tapioca/dsl/compilers/active_record_associations.rb +0 -5
- data/lib/tapioca/dsl/compilers/active_record_columns.rb +0 -3
- data/lib/tapioca/dsl/compilers/active_record_delegated_types.rb +0 -3
- data/lib/tapioca/dsl/compilers/active_record_enum.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_record_fixtures.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_record_relations.rb +33 -6
- data/lib/tapioca/dsl/compilers/active_record_scope.rb +0 -1
- data/lib/tapioca/dsl/compilers/active_record_secure_token.rb +0 -3
- data/lib/tapioca/dsl/compilers/active_record_store.rb +0 -3
- data/lib/tapioca/dsl/compilers/active_record_typed_store.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_resource.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_storage.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_support_concern.rb +0 -4
- data/lib/tapioca/dsl/compilers/active_support_current_attributes.rb +3 -18
- data/lib/tapioca/dsl/compilers/active_support_environment_inquirer.rb +60 -0
- data/lib/tapioca/dsl/compilers/active_support_time_ext.rb +0 -4
- data/lib/tapioca/dsl/compilers/config.rb +0 -4
- data/lib/tapioca/dsl/compilers/frozen_record.rb +0 -4
- data/lib/tapioca/dsl/compilers/graphql_input_object.rb +0 -4
- data/lib/tapioca/dsl/compilers/graphql_mutation.rb +0 -4
- data/lib/tapioca/dsl/compilers/identity_cache.rb +0 -4
- data/lib/tapioca/dsl/compilers/json_api_client_resource.rb +3 -17
- data/lib/tapioca/dsl/compilers/kredis.rb +0 -4
- data/lib/tapioca/dsl/compilers/mixed_in_class_attributes.rb +0 -4
- data/lib/tapioca/dsl/compilers/protobuf.rb +0 -4
- data/lib/tapioca/dsl/compilers/rails_generators.rb +0 -4
- data/lib/tapioca/dsl/compilers/sidekiq_worker.rb +0 -4
- data/lib/tapioca/dsl/compilers/smart_properties.rb +0 -4
- data/lib/tapioca/dsl/compilers/state_machines.rb +0 -4
- data/lib/tapioca/dsl/compilers/url_helpers.rb +0 -3
- data/lib/tapioca/dsl/helpers/active_model_type_helper.rb +0 -2
- data/lib/tapioca/dsl/helpers/active_record_column_type_helper.rb +0 -5
- data/lib/tapioca/dsl/helpers/active_record_constants_helper.rb +0 -2
- data/lib/tapioca/dsl/helpers/graphql_type_helper.rb +0 -2
- data/lib/tapioca/dsl/pipeline.rb +0 -2
- data/lib/tapioca/executor.rb +0 -2
- data/lib/tapioca/gem/events.rb +0 -15
- data/lib/tapioca/gem/listeners/base.rb +0 -1
- data/lib/tapioca/gem/listeners/dynamic_mixins.rb +0 -2
- data/lib/tapioca/gem/listeners/foreign_constants.rb +0 -2
- data/lib/tapioca/gem/listeners/methods.rb +0 -2
- data/lib/tapioca/gem/listeners/mixins.rb +0 -2
- data/lib/tapioca/gem/listeners/remove_empty_payload_scopes.rb +0 -2
- data/lib/tapioca/gem/listeners/sorbet_enums.rb +0 -2
- data/lib/tapioca/gem/listeners/sorbet_helpers.rb +0 -2
- data/lib/tapioca/gem/listeners/sorbet_props.rb +0 -1
- data/lib/tapioca/gem/listeners/sorbet_required_ancestors.rb +0 -2
- data/lib/tapioca/gem/listeners/sorbet_signatures.rb +0 -2
- data/lib/tapioca/gem/listeners/sorbet_type_variables.rb +0 -2
- data/lib/tapioca/gem/listeners/source_location.rb +6 -7
- data/lib/tapioca/gem/listeners/subconstants.rb +0 -2
- data/lib/tapioca/gem/listeners/yard_doc.rb +0 -2
- data/lib/tapioca/gem/pipeline.rb +0 -3
- data/lib/tapioca/gemfile.rb +0 -2
- data/lib/tapioca/helpers/cli_helper.rb +0 -1
- data/lib/tapioca/helpers/config_helper.rb +0 -1
- data/lib/tapioca/helpers/env_helper.rb +0 -1
- data/lib/tapioca/helpers/gem_helper.rb +0 -2
- data/lib/tapioca/helpers/git_attributes.rb +0 -2
- data/lib/tapioca/helpers/package_url.rb +416 -0
- data/lib/tapioca/helpers/rbi_files_helper.rb +0 -1
- data/lib/tapioca/helpers/rbi_helper.rb +0 -3
- data/lib/tapioca/helpers/sorbet_helper.rb +0 -2
- data/lib/tapioca/helpers/test/content.rb +0 -1
- data/lib/tapioca/helpers/test/dsl_compiler.rb +0 -3
- data/lib/tapioca/helpers/test/isolation.rb +0 -6
- data/lib/tapioca/helpers/test/template.rb +1 -9
- data/lib/tapioca/internal.rb +1 -1
- data/lib/tapioca/loaders/dsl.rb +0 -4
- data/lib/tapioca/loaders/gem.rb +0 -4
- data/lib/tapioca/loaders/loader.rb +0 -1
- data/lib/tapioca/rbi_ext/model.rb +0 -2
- data/lib/tapioca/rbi_formatter.rb +0 -2
- data/lib/tapioca/repo_index.rb +0 -3
- data/lib/tapioca/runtime/dynamic_mixin_compiler.rb +0 -3
- data/lib/tapioca/runtime/generic_type_registry.rb +0 -4
- data/lib/tapioca/runtime/reflection.rb +6 -12
- data/lib/tapioca/runtime/trackers/autoload.rb +0 -3
- data/lib/tapioca/runtime/trackers/constant_definition.rb +27 -5
- data/lib/tapioca/runtime/trackers/method_definition.rb +0 -1
- data/lib/tapioca/runtime/trackers/mixin.rb +0 -3
- data/lib/tapioca/runtime/trackers/required_ancestor.rb +0 -2
- data/lib/tapioca/runtime/trackers/tracker.rb +0 -3
- data/lib/tapioca/runtime/trackers.rb +0 -4
- data/lib/tapioca/sorbet_ext/generic_name_patch.rb +0 -2
- data/lib/tapioca/static/requires_compiler.rb +0 -2
- data/lib/tapioca/static/symbol_loader.rb +0 -1
- data/lib/tapioca/static/symbol_table_parser.rb +0 -4
- data/lib/tapioca/version.rb +1 -1
- data/lib/tapioca.rb +0 -2
- metadata +18 -5
- data/lib/tapioca/helpers/source_uri.rb +0 -84
- data/lib/tapioca/runtime/attached_class_of_32.rb +0 -20
- data/lib/tapioca/runtime/attached_class_of_legacy.rb +0 -24
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 659ca0696f2d5827518829428768bcd7b679532b7f554b893d16915c6d2389df
|
|
4
|
+
data.tar.gz: 2500137b33f2a4c4491200c579f6fc762c8a183257f741bfbd86148c7561db4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 54af5a5d84ce82b7ed58ff41d0656f1979f180edbc90bd08750e6767e1cfb400a92522bb8f9ba23739c1f00739db0049a019f1635516e1fbe4789dfb4a10bf4d
|
|
7
|
+
data.tar.gz: 5e3e2784bdd12d0bc9f79d7aefc21ad07b71d4b50962c4f4e391ec9be9958f6accf1e82a1e076c88f243209487066ee23d13377a864bf7bc7d6cd8b10db8e79a
|
data/README.md
CHANGED
|
@@ -87,6 +87,7 @@ Commands:
|
|
|
87
87
|
tapioca init # Get project ready for type checking
|
|
88
88
|
tapioca require # Generate the list of files to be required by tapioca
|
|
89
89
|
tapioca todo # Generate the list of unresolved constants
|
|
90
|
+
tapioca tree # Print a tree of all available commands
|
|
90
91
|
|
|
91
92
|
Options:
|
|
92
93
|
-c, [--config=<config file path>] # Path to the Tapioca configuration file
|
|
@@ -8,13 +8,10 @@ module Tapioca
|
|
|
8
8
|
# `Bundler.require`.
|
|
9
9
|
# @requires_ancestor: ::Bundler::Dependency
|
|
10
10
|
module AutoRequireHook
|
|
11
|
-
extend T::Sig
|
|
12
11
|
@exclude = [] #: Array[String]
|
|
13
12
|
@enabled = false #: bool
|
|
14
13
|
|
|
15
14
|
class << self
|
|
16
|
-
extend T::Sig
|
|
17
|
-
|
|
18
15
|
#: (untyped name) -> bool
|
|
19
16
|
def excluded?(name)
|
|
20
17
|
@exclude.include?(name)
|
data/lib/tapioca/cli.rb
CHANGED
data/lib/tapioca/dsl/compiler.rb
CHANGED
|
@@ -6,8 +6,6 @@ module Tapioca
|
|
|
6
6
|
# @abstract
|
|
7
7
|
#: [ConstantType < T::Module[top]]
|
|
8
8
|
class Compiler
|
|
9
|
-
extend T::Sig
|
|
10
|
-
|
|
11
9
|
include RBIHelper
|
|
12
10
|
include Runtime::Reflection
|
|
13
11
|
extend Runtime::Reflection
|
|
@@ -24,8 +22,6 @@ module Tapioca
|
|
|
24
22
|
@@requested_constants = [] #: Array[T::Module[top]] # rubocop:disable Style/ClassVars
|
|
25
23
|
|
|
26
24
|
class << self
|
|
27
|
-
extend T::Sig
|
|
28
|
-
|
|
29
25
|
#: (T::Module[top] constant) -> bool
|
|
30
26
|
def handles?(constant)
|
|
31
27
|
processable_constants.include?(constant)
|
|
@@ -34,8 +34,6 @@ module Tapioca
|
|
|
34
34
|
#
|
|
35
35
|
#: [ConstantType = (Class[::AASM] & ::AASM::ClassMethods)]
|
|
36
36
|
class AASM < Compiler
|
|
37
|
-
extend T::Sig
|
|
38
|
-
|
|
39
37
|
# Taken directly from the AASM::Core::Event class, here:
|
|
40
38
|
# https://github.com/aasm/aasm/blob/0e03746/lib/aasm/core/event.rb#L21-L29
|
|
41
39
|
EVENT_CALLBACKS = [
|
|
@@ -200,8 +198,6 @@ module Tapioca
|
|
|
200
198
|
end
|
|
201
199
|
|
|
202
200
|
class << self
|
|
203
|
-
extend T::Sig
|
|
204
|
-
|
|
205
201
|
# @override
|
|
206
202
|
#: -> Enumerable[T::Module[top]]
|
|
207
203
|
def gather_constants
|
|
@@ -63,8 +63,6 @@ module Tapioca
|
|
|
63
63
|
# ~~~
|
|
64
64
|
#: [ConstantType = singleton(::ActionController::Base)]
|
|
65
65
|
class ActionControllerHelpers < Compiler
|
|
66
|
-
extend T::Sig
|
|
67
|
-
|
|
68
66
|
# @override
|
|
69
67
|
#: -> void
|
|
70
68
|
def decorate
|
|
@@ -118,8 +116,6 @@ module Tapioca
|
|
|
118
116
|
end
|
|
119
117
|
|
|
120
118
|
class << self
|
|
121
|
-
extend T::Sig
|
|
122
|
-
|
|
123
119
|
# @override
|
|
124
120
|
#: -> Enumerable[T::Module[top]]
|
|
125
121
|
def gather_constants
|
|
@@ -31,8 +31,6 @@ module Tapioca
|
|
|
31
31
|
# ~~~
|
|
32
32
|
#: [ConstantType = singleton(::ActionMailer::Base)]
|
|
33
33
|
class ActionMailer < Compiler
|
|
34
|
-
extend T::Sig
|
|
35
|
-
|
|
36
34
|
# @override
|
|
37
35
|
#: -> void
|
|
38
36
|
def decorate
|
|
@@ -51,8 +49,6 @@ module Tapioca
|
|
|
51
49
|
end
|
|
52
50
|
|
|
53
51
|
class << self
|
|
54
|
-
extend T::Sig
|
|
55
|
-
|
|
56
52
|
# @override
|
|
57
53
|
#: -> Enumerable[T::Module[top]]
|
|
58
54
|
def gather_constants
|
|
@@ -45,8 +45,6 @@ module Tapioca
|
|
|
45
45
|
# ~~~
|
|
46
46
|
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
|
47
47
|
class ActionText < Compiler
|
|
48
|
-
extend T::Sig
|
|
49
|
-
|
|
50
48
|
# @override
|
|
51
49
|
#: -> void
|
|
52
50
|
def decorate
|
|
@@ -73,8 +71,6 @@ module Tapioca
|
|
|
73
71
|
end
|
|
74
72
|
|
|
75
73
|
class << self
|
|
76
|
-
extend T::Sig
|
|
77
|
-
|
|
78
74
|
#: (singleton(::ActiveRecord::Base) constant) -> Array[String]
|
|
79
75
|
def action_text_associations(constant)
|
|
80
76
|
# Implementation copied from https://github.com/rails/rails/blob/31052d0e518b9da103eea2f79d250242ed1e3705/actiontext/lib/action_text/attribute.rb#L66
|
|
@@ -40,8 +40,6 @@ module Tapioca
|
|
|
40
40
|
# ~~~
|
|
41
41
|
#: [ConstantType = singleton(::ActiveJob::Base)]
|
|
42
42
|
class ActiveJob < Compiler
|
|
43
|
-
extend T::Sig
|
|
44
|
-
|
|
45
43
|
# @override
|
|
46
44
|
#: -> void
|
|
47
45
|
def decorate
|
|
@@ -85,8 +83,6 @@ module Tapioca
|
|
|
85
83
|
end
|
|
86
84
|
|
|
87
85
|
class << self
|
|
88
|
-
extend T::Sig
|
|
89
|
-
|
|
90
86
|
# @override
|
|
91
87
|
#: -> Enumerable[T::Module[top]]
|
|
92
88
|
def gather_constants
|
|
@@ -40,8 +40,6 @@ module Tapioca
|
|
|
40
40
|
# ~~~
|
|
41
41
|
#: [ConstantType = (Class[::ActiveModel::Attributes] & ::ActiveModel::Attributes::ClassMethods)]
|
|
42
42
|
class ActiveModelAttributes < Compiler
|
|
43
|
-
extend T::Sig
|
|
44
|
-
|
|
45
43
|
# @override
|
|
46
44
|
#: -> void
|
|
47
45
|
def decorate
|
|
@@ -60,8 +58,6 @@ module Tapioca
|
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
class << self
|
|
63
|
-
extend T::Sig
|
|
64
|
-
|
|
65
61
|
# @override
|
|
66
62
|
#: -> Enumerable[T::Module[top]]
|
|
67
63
|
def gather_constants
|
|
@@ -55,8 +55,6 @@ module Tapioca
|
|
|
55
55
|
# ~~~
|
|
56
56
|
#: [ConstantType = (Class[::ActiveModel::SecurePassword] & ::ActiveModel::SecurePassword::ClassMethods)]
|
|
57
57
|
class ActiveModelSecurePassword < Compiler
|
|
58
|
-
extend T::Sig
|
|
59
|
-
|
|
60
58
|
# @override
|
|
61
59
|
#: -> void
|
|
62
60
|
def decorate
|
|
@@ -90,8 +88,6 @@ module Tapioca
|
|
|
90
88
|
end
|
|
91
89
|
|
|
92
90
|
class << self
|
|
93
|
-
extend T::Sig
|
|
94
|
-
|
|
95
91
|
# @override
|
|
96
92
|
#: -> Enumerable[T::Module[top]]
|
|
97
93
|
def gather_constants
|
|
@@ -42,8 +42,6 @@ module Tapioca
|
|
|
42
42
|
# ~~~
|
|
43
43
|
#: [ConstantType = (Class[ActiveModel::Validations] & ActiveModel::Validations::HelperMethods & ActiveModel::Validations::ClassMethods)]
|
|
44
44
|
class ActiveModelValidationsConfirmation < Compiler
|
|
45
|
-
extend T::Sig
|
|
46
|
-
|
|
47
45
|
class << self
|
|
48
46
|
# @override
|
|
49
47
|
#: -> Enumerable[T::Module[top]]
|
|
@@ -103,15 +103,12 @@ module Tapioca
|
|
|
103
103
|
# ~~~
|
|
104
104
|
#: [ConstantType = singleton(ActiveRecord::Base)]
|
|
105
105
|
class ActiveRecordAssociations < Compiler
|
|
106
|
-
extend T::Sig
|
|
107
106
|
include Helpers::ActiveRecordConstantsHelper
|
|
108
107
|
|
|
109
108
|
class SourceReflectionError < StandardError
|
|
110
109
|
end
|
|
111
110
|
|
|
112
111
|
class MissingConstantError < StandardError
|
|
113
|
-
extend T::Sig
|
|
114
|
-
|
|
115
112
|
#: String
|
|
116
113
|
attr_reader :class_name
|
|
117
114
|
|
|
@@ -138,8 +135,6 @@ module Tapioca
|
|
|
138
135
|
end
|
|
139
136
|
|
|
140
137
|
class << self
|
|
141
|
-
extend T::Sig
|
|
142
|
-
|
|
143
138
|
# @override
|
|
144
139
|
#: -> Enumerable[T::Module[top]]
|
|
145
140
|
def gather_constants
|
|
@@ -122,7 +122,6 @@ module Tapioca
|
|
|
122
122
|
# ~~~
|
|
123
123
|
#: [ConstantType = singleton(ActiveRecord::Base)]
|
|
124
124
|
class ActiveRecordColumns < Compiler
|
|
125
|
-
extend T::Sig
|
|
126
125
|
include Helpers::ActiveRecordConstantsHelper
|
|
127
126
|
|
|
128
127
|
# @override
|
|
@@ -163,8 +162,6 @@ module Tapioca
|
|
|
163
162
|
end
|
|
164
163
|
|
|
165
164
|
class << self
|
|
166
|
-
extend T::Sig
|
|
167
|
-
|
|
168
165
|
# @override
|
|
169
166
|
#: -> Enumerable[T::Module[top]]
|
|
170
167
|
def gather_constants
|
|
@@ -65,7 +65,6 @@ module Tapioca
|
|
|
65
65
|
# ~~~
|
|
66
66
|
#: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
|
|
67
67
|
class ActiveRecordDelegatedTypes < Compiler
|
|
68
|
-
extend T::Sig
|
|
69
68
|
include Helpers::ActiveRecordConstantsHelper
|
|
70
69
|
|
|
71
70
|
# @override
|
|
@@ -88,8 +87,6 @@ module Tapioca
|
|
|
88
87
|
end
|
|
89
88
|
|
|
90
89
|
class << self
|
|
91
|
-
extend T::Sig
|
|
92
|
-
|
|
93
90
|
# @override
|
|
94
91
|
#: -> Enumerable[T::Module[top]]
|
|
95
92
|
def gather_constants
|
|
@@ -51,8 +51,6 @@ module Tapioca
|
|
|
51
51
|
# ~~~
|
|
52
52
|
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
|
53
53
|
class ActiveRecordEnum < Compiler
|
|
54
|
-
extend T::Sig
|
|
55
|
-
|
|
56
54
|
# @override
|
|
57
55
|
#: -> void
|
|
58
56
|
def decorate
|
|
@@ -75,8 +73,6 @@ module Tapioca
|
|
|
75
73
|
end
|
|
76
74
|
|
|
77
75
|
class << self
|
|
78
|
-
extend T::Sig
|
|
79
|
-
|
|
80
76
|
# @override
|
|
81
77
|
#: -> Enumerable[T::Module[top]]
|
|
82
78
|
def gather_constants
|
|
@@ -35,8 +35,6 @@ module Tapioca
|
|
|
35
35
|
# ~~~
|
|
36
36
|
#: [ConstantType = singleton(ActiveSupport::TestCase)]
|
|
37
37
|
class ActiveRecordFixtures < Compiler
|
|
38
|
-
extend T::Sig
|
|
39
|
-
|
|
40
38
|
MISSING = Object.new
|
|
41
39
|
|
|
42
40
|
# @override
|
|
@@ -59,8 +57,6 @@ module Tapioca
|
|
|
59
57
|
end
|
|
60
58
|
|
|
61
59
|
class << self
|
|
62
|
-
extend T::Sig
|
|
63
|
-
|
|
64
60
|
# @override
|
|
65
61
|
#: -> Enumerable[T::Module[top]]
|
|
66
62
|
def gather_constants
|
|
@@ -151,7 +151,6 @@ module Tapioca
|
|
|
151
151
|
# ~~~
|
|
152
152
|
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
|
153
153
|
class ActiveRecordRelations < Compiler
|
|
154
|
-
extend T::Sig
|
|
155
154
|
include Helpers::ActiveRecordConstantsHelper
|
|
156
155
|
include SorbetHelper
|
|
157
156
|
|
|
@@ -181,8 +180,6 @@ module Tapioca
|
|
|
181
180
|
end
|
|
182
181
|
|
|
183
182
|
class << self
|
|
184
|
-
extend T::Sig
|
|
185
|
-
|
|
186
183
|
# @override
|
|
187
184
|
#: -> Enumerable[T::Module[top]]
|
|
188
185
|
def gather_constants
|
|
@@ -224,7 +221,7 @@ module Tapioca
|
|
|
224
221
|
batch_size: ["Integer", "1000"],
|
|
225
222
|
of: ["Integer", "1000"],
|
|
226
223
|
error_on_ignore: ["T.untyped", "nil"],
|
|
227
|
-
order: ["Symbol", ":asc"],
|
|
224
|
+
order: ["T.any(Symbol, T::Array[Symbol])", ":asc"],
|
|
228
225
|
cursor: ["T.untyped", "primary_key"],
|
|
229
226
|
use_ranges: ["T.untyped", "nil"],
|
|
230
227
|
} #: Hash[Symbol, [String, String]]
|
|
@@ -541,6 +538,7 @@ module Tapioca
|
|
|
541
538
|
#: -> void
|
|
542
539
|
def create_relation_methods
|
|
543
540
|
create_relation_method("all")
|
|
541
|
+
create_unscoped_relation_method
|
|
544
542
|
|
|
545
543
|
QUERY_METHODS.each do |method_name|
|
|
546
544
|
case method_name
|
|
@@ -947,7 +945,7 @@ module Tapioca
|
|
|
947
945
|
common_relation_methods_module.create_method(
|
|
948
946
|
method_name.to_s,
|
|
949
947
|
parameters: [
|
|
950
|
-
|
|
948
|
+
create_rest_param("args", type: "T.untyped"),
|
|
951
949
|
],
|
|
952
950
|
return_type: method_name == :delete_by ? "Integer" : "T::Array[#{constant_name}]",
|
|
953
951
|
)
|
|
@@ -976,7 +974,7 @@ module Tapioca
|
|
|
976
974
|
when :find_each
|
|
977
975
|
[constant_name, "T::Enumerator[#{constant_name}]"]
|
|
978
976
|
when :find_in_batches
|
|
979
|
-
["T::Array[#{constant_name}]", "T::Enumerator[T::
|
|
977
|
+
["T::Array[#{constant_name}]", "T::Enumerator[T::Array[#{constant_name}]]"]
|
|
980
978
|
when :in_batches
|
|
981
979
|
[RelationClassName, "::ActiveRecord::Batches::BatchEnumerator"]
|
|
982
980
|
else
|
|
@@ -1056,6 +1054,35 @@ module Tapioca
|
|
|
1056
1054
|
return_type: association_return_type,
|
|
1057
1055
|
)
|
|
1058
1056
|
end
|
|
1057
|
+
|
|
1058
|
+
#: -> void
|
|
1059
|
+
def create_unscoped_relation_method
|
|
1060
|
+
relation_methods_module.create_method("unscoped") do |method|
|
|
1061
|
+
method.add_block_param("block")
|
|
1062
|
+
|
|
1063
|
+
method.add_sig do |sig|
|
|
1064
|
+
sig.return_type = RelationClassName
|
|
1065
|
+
end
|
|
1066
|
+
|
|
1067
|
+
method.add_sig(type_params: ["U"]) do |sig|
|
|
1068
|
+
sig.add_param("block", "T.proc.returns(T.type_parameter(:U))")
|
|
1069
|
+
sig.return_type = "T.type_parameter(:U)"
|
|
1070
|
+
end
|
|
1071
|
+
end
|
|
1072
|
+
|
|
1073
|
+
association_relation_methods_module.create_method("unscoped") do |method|
|
|
1074
|
+
method.add_block_param("block")
|
|
1075
|
+
|
|
1076
|
+
method.add_sig do |sig|
|
|
1077
|
+
sig.return_type = AssociationRelationClassName
|
|
1078
|
+
end
|
|
1079
|
+
|
|
1080
|
+
method.add_sig(type_params: ["U"]) do |sig|
|
|
1081
|
+
sig.add_param("block", "T.proc.returns(T.type_parameter(:U))")
|
|
1082
|
+
sig.return_type = "T.type_parameter(:U)"
|
|
1083
|
+
end
|
|
1084
|
+
end
|
|
1085
|
+
end
|
|
1059
1086
|
end
|
|
1060
1087
|
end
|
|
1061
1088
|
end
|
|
@@ -34,7 +34,6 @@ module Tapioca
|
|
|
34
34
|
# ~~~
|
|
35
35
|
#: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
|
|
36
36
|
class ActiveRecordSecureToken < Compiler
|
|
37
|
-
extend T::Sig
|
|
38
37
|
include Helpers::ActiveRecordConstantsHelper
|
|
39
38
|
|
|
40
39
|
# @override
|
|
@@ -57,8 +56,6 @@ module Tapioca
|
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
class << self
|
|
60
|
-
extend T::Sig
|
|
61
|
-
|
|
62
59
|
# @override
|
|
63
60
|
#: -> Enumerable[T::Module[top]]
|
|
64
61
|
def gather_constants
|
|
@@ -80,7 +80,6 @@ module Tapioca
|
|
|
80
80
|
# ~~~
|
|
81
81
|
#: [ConstantType = (singleton(ActiveRecord::Base) & Extensions::ActiveRecord)]
|
|
82
82
|
class ActiveRecordStore < Compiler
|
|
83
|
-
extend T::Sig
|
|
84
83
|
include Helpers::ActiveRecordConstantsHelper
|
|
85
84
|
|
|
86
85
|
# @override
|
|
@@ -132,8 +131,6 @@ module Tapioca
|
|
|
132
131
|
end
|
|
133
132
|
|
|
134
133
|
class << self
|
|
135
|
-
extend T::Sig
|
|
136
|
-
|
|
137
134
|
# @override
|
|
138
135
|
#: -> Enumerable[T::Module[top]]
|
|
139
136
|
def gather_constants
|
|
@@ -83,8 +83,6 @@ module Tapioca
|
|
|
83
83
|
# ~~~
|
|
84
84
|
#: [ConstantType = singleton(::ActiveRecord::Base)]
|
|
85
85
|
class ActiveRecordTypedStore < Compiler
|
|
86
|
-
extend T::Sig
|
|
87
|
-
|
|
88
86
|
# @override
|
|
89
87
|
#: -> void
|
|
90
88
|
def decorate
|
|
@@ -108,8 +106,6 @@ module Tapioca
|
|
|
108
106
|
end
|
|
109
107
|
|
|
110
108
|
class << self
|
|
111
|
-
extend T::Sig
|
|
112
|
-
|
|
113
109
|
# @override
|
|
114
110
|
#: -> Enumerable[T::Module[top]]
|
|
115
111
|
def gather_constants
|
|
@@ -56,8 +56,6 @@ module Tapioca
|
|
|
56
56
|
# ~~~
|
|
57
57
|
#: [ConstantType = singleton(::ActiveResource::Base)]
|
|
58
58
|
class ActiveResource < Compiler
|
|
59
|
-
extend T::Sig
|
|
60
|
-
|
|
61
59
|
# @override
|
|
62
60
|
#: -> void
|
|
63
61
|
def decorate
|
|
@@ -71,8 +69,6 @@ module Tapioca
|
|
|
71
69
|
end
|
|
72
70
|
|
|
73
71
|
class << self
|
|
74
|
-
extend T::Sig
|
|
75
|
-
|
|
76
72
|
# @override
|
|
77
73
|
#: -> Enumerable[T::Module[top]]
|
|
78
74
|
def gather_constants
|
|
@@ -40,8 +40,6 @@ module Tapioca
|
|
|
40
40
|
# ~~~
|
|
41
41
|
#: [ConstantType = (T::Module[top] & ::ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods)]
|
|
42
42
|
class ActiveStorage < Compiler
|
|
43
|
-
extend T::Sig
|
|
44
|
-
|
|
45
43
|
# @override
|
|
46
44
|
#: -> void
|
|
47
45
|
def decorate
|
|
@@ -65,8 +63,6 @@ module Tapioca
|
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
class << self
|
|
68
|
-
extend T::Sig
|
|
69
|
-
|
|
70
66
|
# @override
|
|
71
67
|
#: -> Enumerable[T::Module[top]]
|
|
72
68
|
def gather_constants
|
|
@@ -39,8 +39,6 @@ module Tapioca
|
|
|
39
39
|
# ~~~
|
|
40
40
|
#: [ConstantType = T::Module[top]]
|
|
41
41
|
class ActiveSupportConcern < Compiler
|
|
42
|
-
extend T::Sig
|
|
43
|
-
|
|
44
42
|
# @override
|
|
45
43
|
#: -> void
|
|
46
44
|
def decorate
|
|
@@ -62,8 +60,6 @@ module Tapioca
|
|
|
62
60
|
end
|
|
63
61
|
|
|
64
62
|
class << self
|
|
65
|
-
extend T::Sig
|
|
66
|
-
|
|
67
63
|
# @override
|
|
68
64
|
#: -> Enumerable[T::Module[top]]
|
|
69
65
|
def gather_constants
|
|
@@ -61,8 +61,6 @@ module Tapioca
|
|
|
61
61
|
# ~~~
|
|
62
62
|
#: [ConstantType = singleton(::ActiveSupport::CurrentAttributes)]
|
|
63
63
|
class ActiveSupportCurrentAttributes < Compiler
|
|
64
|
-
extend T::Sig
|
|
65
|
-
|
|
66
64
|
# @override
|
|
67
65
|
#: -> void
|
|
68
66
|
def decorate
|
|
@@ -74,11 +72,11 @@ module Tapioca
|
|
|
74
72
|
current_attributes_methods_name = "GeneratedAttributeMethods"
|
|
75
73
|
current_attributes.create_module(current_attributes_methods_name) do |generated_attribute_methods|
|
|
76
74
|
dynamic_methods.each do |method|
|
|
77
|
-
method = method
|
|
75
|
+
method = constant.instance_method(method)
|
|
78
76
|
# We want to generate each method both on the class
|
|
79
|
-
|
|
77
|
+
create_method_from_def(current_attributes, method, class_method: true)
|
|
80
78
|
# and on the instance
|
|
81
|
-
|
|
79
|
+
create_method_from_def(generated_attribute_methods, method, class_method: false)
|
|
82
80
|
end
|
|
83
81
|
|
|
84
82
|
instance_methods.each do |method|
|
|
@@ -94,8 +92,6 @@ module Tapioca
|
|
|
94
92
|
end
|
|
95
93
|
|
|
96
94
|
class << self
|
|
97
|
-
extend T::Sig
|
|
98
|
-
|
|
99
95
|
# @override
|
|
100
96
|
#: -> Enumerable[T::Module[top]]
|
|
101
97
|
def gather_constants
|
|
@@ -114,17 +110,6 @@ module Tapioca
|
|
|
114
110
|
def instance_methods_of_constant
|
|
115
111
|
constant.instance_methods(false)
|
|
116
112
|
end
|
|
117
|
-
|
|
118
|
-
#: (RBI::Scope klass, String method, class_method: bool) -> void
|
|
119
|
-
def generate_method(klass, method, class_method:)
|
|
120
|
-
method_def = if class_method
|
|
121
|
-
constant.method(method)
|
|
122
|
-
else
|
|
123
|
-
constant.instance_method(method)
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
create_method_from_def(klass, method_def, class_method: class_method)
|
|
127
|
-
end
|
|
128
113
|
end
|
|
129
114
|
end
|
|
130
115
|
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# typed: strict
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
return unless defined?(ActiveSupport::EnvironmentInquirer)
|
|
5
|
+
|
|
6
|
+
module Tapioca
|
|
7
|
+
module Dsl
|
|
8
|
+
module Compilers
|
|
9
|
+
# `Tapioca::Dsl::Compilers::ActiveSupportEnvironmentInquirer` decorates an RBI file for non-default environment
|
|
10
|
+
# files in the `config/environments` directory.
|
|
11
|
+
#
|
|
12
|
+
# For example, in a Rails application with the following files:
|
|
13
|
+
#
|
|
14
|
+
# - config/environments/development.rb
|
|
15
|
+
# - config/environments/demo.rb
|
|
16
|
+
# - config/environments/production.rb
|
|
17
|
+
# - config/environments/staging.rb
|
|
18
|
+
# - config/environments/test.rb
|
|
19
|
+
#
|
|
20
|
+
# this compiler will produce an RBI file with the following content:
|
|
21
|
+
# ~~~rbi
|
|
22
|
+
# # typed: true
|
|
23
|
+
#
|
|
24
|
+
# class ActiveSupport::EnvironmentInquirer
|
|
25
|
+
# sig { returns(T::Boolean) }
|
|
26
|
+
# def demo?; end
|
|
27
|
+
#
|
|
28
|
+
# sig { returns(T::Boolean) }
|
|
29
|
+
# def staging?; end
|
|
30
|
+
# end
|
|
31
|
+
# ~~~
|
|
32
|
+
#: [ConstantType = singleton(::ActiveSupport::EnvironmentInquirer)]
|
|
33
|
+
class ActiveSupportEnvironmentInquirer < Compiler
|
|
34
|
+
# @override
|
|
35
|
+
#: -> void
|
|
36
|
+
def decorate
|
|
37
|
+
envs = Rails.root.glob("config/environments/*.rb").map { |f| f.basename(".rb").to_s }.sort
|
|
38
|
+
envs -= ::ActiveSupport::EnvironmentInquirer::DEFAULT_ENVIRONMENTS
|
|
39
|
+
return if envs.none?
|
|
40
|
+
|
|
41
|
+
root.create_path(::ActiveSupport::EnvironmentInquirer) do |mod|
|
|
42
|
+
envs.each do |env|
|
|
43
|
+
mod.create_method("#{env}?", return_type: "T::Boolean")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class << self
|
|
49
|
+
# @override
|
|
50
|
+
#: -> T::Enumerable[T::Module[top]]
|
|
51
|
+
def gather_constants
|
|
52
|
+
return [] unless defined?(Rails.application) && Rails.application
|
|
53
|
+
|
|
54
|
+
[::ActiveSupport::EnvironmentInquirer]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -36,8 +36,6 @@ module Tapioca
|
|
|
36
36
|
# ```
|
|
37
37
|
#: [ConstantType = singleton(::Time)]
|
|
38
38
|
class ActiveSupportTimeExt < Compiler
|
|
39
|
-
extend T::Sig
|
|
40
|
-
|
|
41
39
|
# @override
|
|
42
40
|
#: -> void
|
|
43
41
|
def decorate
|
|
@@ -55,8 +53,6 @@ module Tapioca
|
|
|
55
53
|
end
|
|
56
54
|
|
|
57
55
|
class << self
|
|
58
|
-
extend T::Sig
|
|
59
|
-
|
|
60
56
|
# @override
|
|
61
57
|
#: -> Enumerable[T::Module[top]]
|
|
62
58
|
def gather_constants
|