orthoses-rails 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/rails/Rakefile +244 -0
- data/examples/rails/known_sig/action_cable/connection/test_cookie_jar.rbs +2 -0
- data/examples/rails/known_sig/action_controller/metal.rbs +4 -0
- data/examples/rails/known_sig/action_dispatch/cookies/cookie_jar.rbs +3 -0
- data/examples/rails/known_sig/action_dispatch/response.rbs +4 -0
- data/examples/rails/patch/drb/drb_undumped.rbs +2 -0
- data/examples/rails/patch/drb.rbs +2 -0
- data/examples/rails/patch/erubi/engine.rbs +4 -0
- data/examples/rails/patch/erubi.rbs +2 -0
- data/examples/rails/patch/minitest/kernel.rbs +44 -0
- data/examples/rails/patch/minitest/minitest/abstract_reporter.rbs +49 -0
- data/examples/rails/patch/minitest/minitest/assertion.rbs +16 -0
- data/examples/rails/patch/minitest/minitest/assertions.rbs +545 -0
- data/examples/rails/patch/minitest/minitest/backtrace_filter.rbs +16 -0
- data/examples/rails/patch/minitest/minitest/bench_spec.rbs +101 -0
- data/examples/rails/patch/minitest/minitest/benchmark.rbs +258 -0
- data/examples/rails/patch/minitest/minitest/composite_reporter.rbs +25 -0
- data/examples/rails/patch/minitest/minitest/expectations.rbs +21 -0
- data/examples/rails/patch/minitest/minitest/guard.rbs +64 -0
- data/examples/rails/patch/minitest/minitest/mock.rbs +60 -0
- data/examples/rails/patch/minitest/minitest/parallel/executor.rbs +42 -0
- data/examples/rails/patch/minitest/minitest/parallel/test/class_methods.rbs +6 -0
- data/examples/rails/patch/minitest/minitest/parallel/test.rbs +3 -0
- data/examples/rails/patch/minitest/minitest/parallel.rbs +2 -0
- data/examples/rails/patch/minitest/minitest/pride_io.rbs +54 -0
- data/examples/rails/patch/minitest/minitest/pride_lol.rbs +17 -0
- data/examples/rails/patch/minitest/minitest/progress_reporter.rbs +11 -0
- data/examples/rails/patch/minitest/minitest/reportable.rbs +51 -0
- data/examples/rails/patch/minitest/minitest/reporter.rbs +5 -0
- data/examples/rails/patch/minitest/minitest/result.rbs +28 -0
- data/examples/rails/patch/minitest/minitest/runnable.rbs +131 -0
- data/examples/rails/patch/minitest/minitest/skip.rbs +6 -0
- data/examples/rails/patch/minitest/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/examples/rails/patch/minitest/minitest/spec/dsl.rbs +125 -0
- data/examples/rails/patch/minitest/minitest/spec.rbs +10 -0
- data/examples/rails/patch/minitest/minitest/statistics_reporter.rbs +76 -0
- data/examples/rails/patch/minitest/minitest/summary_reporter.rbs +26 -0
- data/examples/rails/patch/minitest/minitest/test/lifecycle_hooks.rbs +92 -0
- data/examples/rails/patch/minitest/minitest/test.rbs +76 -0
- data/examples/rails/patch/minitest/minitest/unexpected_error.rbs +10 -0
- data/examples/rails/patch/minitest/minitest/unit/test_case.rbs +3 -0
- data/examples/rails/patch/minitest/minitest/unit.rbs +5 -0
- data/examples/rails/patch/minitest/minitest.rbs +966 -0
- data/examples/rails/patch/pg/simple_decoder.rbs +4 -0
- data/examples/rails/patch/pg.rbs +2 -0
- data/examples/rails/patch/qc/queue.rbs +2 -0
- data/examples/rails/patch/qc.rbs +2 -0
- data/examples/rails/patch/que/job.rbs +2 -0
- data/examples/rails/patch/que.rbs +2 -0
- data/examples/rails/patch/rack/cache/entity_store.rbs +2 -0
- data/examples/rails/patch/rack/cache/meta_store.rbs +2 -0
- data/examples/rails/patch/rack/cache.rbs +2 -0
- data/examples/rails/patch/rack/session/dalli.rbs +2 -0
- data/examples/rails/patch/rack/session.rbs +2 -0
- data/examples/rails/patch/rboc.rbs +2 -0
- data/examples/rails/patch/rdoc/generator/sdoc.rbs +3 -0
- data/examples/rails/patch/rdoc/generator.rbs +2 -0
- data/examples/rails/patch/rdoc/task.rbs +2 -0
- data/examples/rails/patch/ripper.rbs +2 -0
- data/examples/rails/patch/sidekiq/worker.rbs +2 -0
- data/examples/rails/patch/sidekiq.rbs +2 -0
- data/examples/rails/patch/sneakers/worker.rbs +2 -0
- data/examples/rails/patch/sneakers.rbs +2 -0
- data/examples/rails/patch/sucker_punch/job.rbs +2 -0
- data/examples/rails/patch/sucker_punch.rbs +2 -0
- data/examples/rails/patch/thor/actions/create_file.rbs +2 -0
- data/examples/rails/patch/thor/actions.rbs +2 -0
- data/examples/rails/patch/thor/error.rbs +2 -0
- data/examples/rails/patch/thor/group.rbs +2 -0
- data/examples/rails/patch/thor.rbs +2 -0
- data/lib/orthoses/active_model/has_secure_password.rb +8 -1
- data/lib/orthoses/active_model/known_sig/7.0/serialization.rbs +4 -0
- data/lib/orthoses/active_model/known_sig/7.0/validations.rbs +4 -0
- data/lib/orthoses/active_model/known_sig.rb +21 -0
- data/lib/orthoses/active_model.rb +4 -0
- data/lib/orthoses/active_record/known_sig/6.0/result.rbs +5 -0
- data/lib/orthoses/active_record/known_sig/6.1/result.rbs +5 -0
- data/lib/orthoses/active_record/known_sig/7.0/encryption/context.rbs +9 -0
- data/lib/orthoses/active_record/known_sig/7.0/result.rbs +5 -0
- data/lib/orthoses/active_record/known_sig.rb +21 -0
- data/lib/orthoses/active_record/query_methods.rb +32 -0
- data/lib/orthoses/active_record.rb +8 -0
- data/lib/orthoses/active_support/class_attribute.rb +14 -3
- data/lib/orthoses/active_support/concern.rb +9 -1
- data/lib/orthoses/active_support/delegation.rb +158 -0
- data/lib/orthoses/active_support/known_sig/7.0/active_support/callbacks/callback_chain.rbs +9 -0
- data/lib/orthoses/active_support/known_sig/7.0/active_support/hash_with_indifferent_access.rbs +6 -0
- data/lib/orthoses/active_support/known_sig/7.0/hash_with_indifferent_access.rbs +2 -0
- data/lib/orthoses/active_support/known_sig/{time.rbs → 7.0/time.rbs} +4 -0
- data/lib/orthoses/active_support/known_sig.rb +21 -0
- data/lib/orthoses/active_support/mattr_accessor.rb +10 -2
- data/lib/orthoses/active_support/time_with_zone.rb +13 -10
- data/lib/orthoses/active_support.rb +25 -0
- data/lib/orthoses/rails/known_sig_helper.rb +22 -0
- data/lib/orthoses/rails/version.rb +1 -1
- data/lib/orthoses/rails.rb +4 -11
- metadata +91 -4
- data/lib/orthoses/active_support/known_sig/active_support/time_with_zone.rbs +0 -4
@@ -13,7 +13,14 @@ module Orthoses
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def call
|
16
|
-
target_method =
|
16
|
+
target_method = begin
|
17
|
+
::ActiveModel::SecurePassword::ClassMethods.instance_method(:has_secure_password)
|
18
|
+
rescue NameError => err
|
19
|
+
Orthoses.logger.warn("Run `require 'active_support/concern'; require 'active_model/secure_password'` and retry because #{err}")
|
20
|
+
require 'active_support/concern'
|
21
|
+
require 'active_model/secure_password'
|
22
|
+
retry
|
23
|
+
end
|
17
24
|
call_tracer = Orthoses::CallTracer.new
|
18
25
|
|
19
26
|
store = call_tracer.trace(target_method) do
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
module ActiveModel
|
5
|
+
class KnownSig
|
6
|
+
include Orthoses::Rails::KnownSigHelper
|
7
|
+
|
8
|
+
def initialize(loader)
|
9
|
+
@loader = loader
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
@loader.call.tap do |store|
|
14
|
+
paths = best_version_paths(::ActiveModel::VERSION::STRING, __dir__)
|
15
|
+
env = Content::Environment.load_from_paths(paths)
|
16
|
+
env.write_to(store: store)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# attr_accessor in #each
|
2
|
+
class ActiveRecord::Encryption::Context
|
3
|
+
attr_accessor key_provider: untyped
|
4
|
+
attr_accessor key_generator: untyped
|
5
|
+
attr_accessor cipher: untyped
|
6
|
+
attr_accessor message_serializer: untyped
|
7
|
+
attr_accessor encryptor: untyped
|
8
|
+
attr_accessor frozen_encryption: untyped
|
9
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
module ActiveRecord
|
5
|
+
class KnownSig
|
6
|
+
include Orthoses::Rails::KnownSigHelper
|
7
|
+
|
8
|
+
def initialize(loader)
|
9
|
+
@loader = loader
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
@loader.call.tap do |store|
|
14
|
+
paths = best_version_paths(::ActiveRecord::VERSION::STRING, __dir__)
|
15
|
+
env = Content::Environment.load_from_paths(paths)
|
16
|
+
env.write_to(store: store)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
module ActiveRecord
|
5
|
+
class QueryMethods
|
6
|
+
def initialize(loader)
|
7
|
+
@loader = loader
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
@loader.call.tap do |store|
|
12
|
+
content = store["ActiveRecord::QueryMethods"]
|
13
|
+
|
14
|
+
::ActiveRecord::Relation::VALUE_METHODS.each do |name|
|
15
|
+
method_name, type =
|
16
|
+
case name
|
17
|
+
when *::ActiveRecord::Relation::MULTI_VALUE_METHODS
|
18
|
+
["#{name}_values", "::Array[untyped]"]
|
19
|
+
when *::ActiveRecord::Relation::SINGLE_VALUE_METHODS
|
20
|
+
["#{name}_value", name == :create_with ? "::Hash[untyped, untyped]?" : "untyped"]
|
21
|
+
when *::ActiveRecord::Relation::CLAUSE_METHODS
|
22
|
+
["#{name}_clause", name == :from ? "::ActiveRecord::Relation::FromClause" : "::ActiveRecord::Relation::WhereClause"]
|
23
|
+
end
|
24
|
+
|
25
|
+
content << "def #{method_name}: () -> #{type}"
|
26
|
+
content << "def #{method_name}=: (#{type} value) -> #{type}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'active_record/belongs_to'
|
4
|
+
require_relative 'active_record/generated_attribute_methods'
|
5
|
+
require_relative 'active_record/has_many'
|
6
|
+
require_relative 'active_record/has_one'
|
7
|
+
require_relative 'active_record/known_sig'
|
8
|
+
require_relative 'active_record/query_methods'
|
@@ -15,7 +15,13 @@ module Orthoses
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def call
|
18
|
-
target_method =
|
18
|
+
target_method = begin
|
19
|
+
::Class.instance_method(:class_attribute)
|
20
|
+
rescue NameError => err
|
21
|
+
Orthoses.logger.warn("Run `require 'active_support/core_ext/class/attribute'` and retry because #{err}")
|
22
|
+
require 'active_support/core_ext/class/attribute'
|
23
|
+
retry
|
24
|
+
end
|
19
25
|
call_tracer = Orthoses::CallTracer.new
|
20
26
|
|
21
27
|
store = call_tracer.trace(target_method) do
|
@@ -34,6 +40,9 @@ module Orthoses
|
|
34
40
|
argument[:instance_predicate] = options.fetch(:instance_predicate, true)
|
35
41
|
argument[:default_value] = options.fetch(:default, nil)
|
36
42
|
end
|
43
|
+
|
44
|
+
content = store[receiver_name]
|
45
|
+
|
37
46
|
argument[:attrs].each do |name|
|
38
47
|
next unless @if.nil? || @if.call(method, name)
|
39
48
|
|
@@ -47,11 +56,13 @@ module Orthoses
|
|
47
56
|
methods << "def self.#{name}=: (untyped value) -> untyped"
|
48
57
|
methods << "def #{name}: () -> untyped" if argument[:instance_reader]
|
49
58
|
methods << "def #{name}?: () -> bool" if argument[:instance_predicate] && argument[:instance_reader]
|
50
|
-
methods << "
|
59
|
+
methods << "def #{name}=: (untyped value) -> untyped" if argument[:instance_writer]
|
60
|
+
# In RBS, `foo=` and attr_writer :foo cannot live together.
|
61
|
+
content.body.delete_if { |line| line.start_with?("attr_writer #{name}:") }
|
51
62
|
end
|
52
63
|
next if methods.empty?
|
53
64
|
|
54
|
-
|
65
|
+
content.concat(methods)
|
55
66
|
end
|
56
67
|
|
57
68
|
store
|
@@ -8,8 +8,16 @@ module Orthoses
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def call
|
11
|
+
target_method = begin
|
12
|
+
::ActiveSupport::Concern.method(:extended)
|
13
|
+
rescue NameError => err
|
14
|
+
Orthoses.logger.warn("Run `require 'active_support/concern'` and retry because #{err}")
|
15
|
+
require 'active_support/concern'
|
16
|
+
retry
|
17
|
+
end
|
18
|
+
|
11
19
|
extended = CallTracer.new
|
12
|
-
store = extended.trace(
|
20
|
+
store = extended.trace(target_method) do
|
13
21
|
@loader.call
|
14
22
|
end
|
15
23
|
extended.result.each do |method, argument|
|
@@ -0,0 +1,158 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
module ActiveSupport
|
5
|
+
class Delegation
|
6
|
+
def initialize(loader)
|
7
|
+
@loader = loader
|
8
|
+
end
|
9
|
+
|
10
|
+
# def delegate(*methods, to: nil, prefix: nil, allow_nil: nil, private: nil)
|
11
|
+
# def delegate_missing_to(target, allow_nil: nil)
|
12
|
+
def call
|
13
|
+
target_method = begin
|
14
|
+
::Module.method(:delegate)
|
15
|
+
rescue NameError => err
|
16
|
+
Orthoses.logger.warn("Run `require 'active_support/core_ext/module/delegation'` and retry because #{err}")
|
17
|
+
require 'active_support/core_ext/module/delegation'
|
18
|
+
retry
|
19
|
+
end
|
20
|
+
delegate = CallTracer.new
|
21
|
+
store = delegate.trace(target_method) do
|
22
|
+
@loader.call
|
23
|
+
end
|
24
|
+
|
25
|
+
resource = Resource.new(store)
|
26
|
+
|
27
|
+
delegate.result.each do |method, argument|
|
28
|
+
receiver_name = Utils.module_name(method.receiver) or next
|
29
|
+
receiver_content = store[receiver_name]
|
30
|
+
case argument[:to]
|
31
|
+
when Module
|
32
|
+
to_module_name = Utils.module_name(argument[:to]) or next
|
33
|
+
argument[:methods].each do |arg|
|
34
|
+
if sig = resource.build_signature(to_module_name, arg, :singleton, false)
|
35
|
+
receiver_content << "# defined by `delegate` to: #{to_module_name}"
|
36
|
+
receiver_content << sig
|
37
|
+
else
|
38
|
+
Orthoses.logger.warn("[ActiveSupport::Delegation] Ignore #{arg.inspect}")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
else
|
42
|
+
to_name = argument[:to].to_s.to_sym
|
43
|
+
tag, to_return_type = resource.find(receiver_name, to_name, :instance, false)
|
44
|
+
raise "bug" if tag == :multi
|
45
|
+
if to_return_type.nil?
|
46
|
+
Orthoses.logger.warn("[ActiveSupport::Delegation] Ignore #{argument.inspect}")
|
47
|
+
next
|
48
|
+
end
|
49
|
+
if to_return_type.instance_of?(RBS::Types::Bases::Any)
|
50
|
+
argument[:methods].each do |method|
|
51
|
+
receiver_content << "# defined by `delegate` to: :#{to_name}(#{to_return_type})"
|
52
|
+
receiver_content << "def #{method}: (*untyped, **untyped) -> untyped"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
to_typename = to_return_type.name.relative!.to_s
|
56
|
+
argument[:methods].each do |method|
|
57
|
+
if sig = resource.build_signature(to_typename, method, :instance, true)
|
58
|
+
receiver_content << "# defined by `delegate` to: :#{to_name}(#{to_return_type})"
|
59
|
+
receiver_content << sig
|
60
|
+
else
|
61
|
+
Orthoses.logger.warn("[ActiveSupport::Delegation] Ignore #{method.inspect}")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
store
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
|
73
|
+
class Resource
|
74
|
+
def initialize(store)
|
75
|
+
@store = store
|
76
|
+
env = Orthoses::Utils.rbs_environment(collection: true)
|
77
|
+
@definition_builder = RBS::DefinitionBuilder.new(env: env)
|
78
|
+
end
|
79
|
+
|
80
|
+
def find(mod_name, name, kind, argument)
|
81
|
+
typename = TypeName(mod_name).absolute!
|
82
|
+
|
83
|
+
if definition_method = build_definition(typename, kind)&.methods&.[](name)
|
84
|
+
return [:multi, definition_method.defs.map(&:type)]
|
85
|
+
end
|
86
|
+
resolve_type_by_name(@store[mod_name].to_decl.members, name, kind, argument)
|
87
|
+
end
|
88
|
+
|
89
|
+
def build_definition(typename, kind)
|
90
|
+
case kind
|
91
|
+
when :instance
|
92
|
+
@definition_builder.build_instance(typename)
|
93
|
+
when :singleton
|
94
|
+
@definition_builder.build_singleton(typename)
|
95
|
+
else
|
96
|
+
raise "big"
|
97
|
+
end
|
98
|
+
rescue RuntimeError => e
|
99
|
+
if e.message.match?(/\AUnknown name for/)
|
100
|
+
nil
|
101
|
+
else
|
102
|
+
raise
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def build_signature(mod_name, name, kind, argument)
|
107
|
+
tag, type = find(mod_name, name, kind, argument)
|
108
|
+
case tag
|
109
|
+
when :single
|
110
|
+
"def #{name}: () -> #{type}"
|
111
|
+
when :multi
|
112
|
+
"def #{name}: #{type.join(' | ')}"
|
113
|
+
else
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def resolve_type_by_name(members, name, kind, argument)
|
121
|
+
members.each do |member|
|
122
|
+
case member
|
123
|
+
when RBS::AST::Members::MethodDefinition
|
124
|
+
next unless member.name == name && member.kind == kind
|
125
|
+
if argument
|
126
|
+
return [:multi, member.types]
|
127
|
+
else
|
128
|
+
type = member.types.find do |method_type|
|
129
|
+
method_type.type.required_positionals.empty? && method_type.type.required_keywords.empty?
|
130
|
+
end
|
131
|
+
next unless type
|
132
|
+
return [:single, type.type.return_type]
|
133
|
+
end
|
134
|
+
when RBS::AST::Members::Var
|
135
|
+
next unless member.name == name
|
136
|
+
return [:single, member.type]
|
137
|
+
when RBS::AST::Declarations::Constant
|
138
|
+
next unless member.name.to_s.to_sym == name
|
139
|
+
return [:single, member.type]
|
140
|
+
when RBS::AST::Members::Attribute
|
141
|
+
next unless member.name == name && member.kind == kind
|
142
|
+
return [:single, member.type]
|
143
|
+
when RBS::AST::Members::Alias
|
144
|
+
next unless member.new_name == name && member.kind == kind
|
145
|
+
return resolve_type_by_name(members, member.old_name, kind, argument)
|
146
|
+
when RBS::AST::Members::Mixin, RBS::AST::Members::LocationOnly
|
147
|
+
next
|
148
|
+
else
|
149
|
+
binding.irb
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module ActiveSupport
|
2
|
+
module Callbacks
|
3
|
+
class CallbackChain
|
4
|
+
include Enumerable[::ActiveSupport::Callbacks::Callback]
|
5
|
+
def each: () -> Enumerator[::ActiveSupport::Callbacks::Callback, Array[::ActiveSupport::Callbacks::Callback]]
|
6
|
+
| () { (::ActiveSupport::Callbacks::Callback) -> void } -> Array[::ActiveSupport::Callbacks::Callback]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
module ActiveSupport
|
5
|
+
class KnownSig
|
6
|
+
include Orthoses::Rails::KnownSigHelper
|
7
|
+
|
8
|
+
def initialize(loader)
|
9
|
+
@loader = loader
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
@loader.call.tap do |store|
|
14
|
+
paths = best_version_paths(::ActiveSupport::VERSION::STRING, __dir__)
|
15
|
+
env = Content::Environment.load_from_paths(paths)
|
16
|
+
env.write_to(store: store)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -16,8 +16,8 @@ module Orthoses
|
|
16
16
|
mattr_reader = Orthoses::CallTracer.new
|
17
17
|
mattr_writer = Orthoses::CallTracer.new
|
18
18
|
|
19
|
-
store = mattr_reader.trace(
|
20
|
-
mattr_writer.trace(
|
19
|
+
store = mattr_reader.trace(target_method(:mattr_reader)) do
|
20
|
+
mattr_writer.trace(target_method(:mattr_writer)) do
|
21
21
|
@loader.call
|
22
22
|
end
|
23
23
|
end
|
@@ -56,6 +56,14 @@ module Orthoses
|
|
56
56
|
|
57
57
|
store
|
58
58
|
end
|
59
|
+
|
60
|
+
def target_method(name)
|
61
|
+
::Module.instance_method(name)
|
62
|
+
rescue NameError => err
|
63
|
+
Orthoses.logger.warn("Run `require 'active_support/core_ext/module/attribute_accessors'` and retry because #{err}")
|
64
|
+
require 'active_support/core_ext/module/attribute_accessors'
|
65
|
+
retry
|
66
|
+
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
@@ -15,10 +15,10 @@ module Orthoses
|
|
15
15
|
# Time <= (known Time)
|
16
16
|
# TimeWithZone <= (known TimeWithZone, known Time, core Time)
|
17
17
|
def call
|
18
|
-
store =
|
18
|
+
store = @loader.call
|
19
19
|
|
20
20
|
time_with_zone_store = store["ActiveSupport::TimeWithZone"]
|
21
|
-
each_line_from_core_time_definition do |line|
|
21
|
+
each_line_from_core_time_definition(store) do |line|
|
22
22
|
time_with_zone_store << line
|
23
23
|
end
|
24
24
|
|
@@ -35,15 +35,18 @@ module Orthoses
|
|
35
35
|
localtime
|
36
36
|
]
|
37
37
|
|
38
|
-
def each_line_from_core_time_definition
|
38
|
+
def each_line_from_core_time_definition(store)
|
39
39
|
type_name_time = TypeName("::Time")
|
40
|
-
|
41
|
-
env
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
env = Utils.rbs_environment(collection: true).dup
|
41
|
+
env << store["Time"].to_decl
|
42
|
+
env << store["DateAndTime"].to_decl
|
43
|
+
env << store["DateAndTime::Zones"].to_decl
|
44
|
+
env << store["DateAndTime::Calculations"].to_decl
|
45
|
+
env << store["DateAndTime::Compatibility"].to_decl
|
46
|
+
env << store["ActiveSupport"].to_decl
|
47
|
+
env << store["ActiveSupport::TimeZone"].to_decl
|
48
|
+
env << store["ActiveSupport::Duration"].to_decl
|
49
|
+
env << store["ActiveSupport::TimeWithZone"].to_decl
|
47
50
|
|
48
51
|
builder = RBS::DefinitionBuilder.new(env: env.resolve_type_names)
|
49
52
|
one_ancestors = builder.ancestor_builder.one_instance_ancestors(type_name_time)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'active_support/class_attribute'
|
4
|
+
require_relative 'active_support/concern'
|
5
|
+
require_relative 'active_support/delegation'
|
6
|
+
require_relative 'active_support/mattr_accessor'
|
7
|
+
require_relative 'active_support/time_with_zone'
|
8
|
+
require_relative 'active_support/known_sig'
|
9
|
+
|
10
|
+
module Orthoses
|
11
|
+
module ActiveSupport
|
12
|
+
# Interface for adding middleware in bulk.
|
13
|
+
# Orthoses::ActiveSupport.each do |middleware, **args|
|
14
|
+
# use middleware, **args
|
15
|
+
# end
|
16
|
+
def self.each
|
17
|
+
yield ClassAttribute
|
18
|
+
yield Concern
|
19
|
+
yield Delegation
|
20
|
+
yield MattrAccessor
|
21
|
+
yield TimeWithZone
|
22
|
+
yield KnownSig
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|