rbs_activesupport 1.0.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 +7 -0
- data/.rubocop.yml +32 -0
- data/.vscode/extensions.json +7 -0
- data/.vscode/settings.json +6 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +8 -0
- data/Steepfile +11 -0
- data/lib/generators/rbs_activesupport/install_generator.rb +22 -0
- data/lib/rbs_activesupport/ast.rb +60 -0
- data/lib/rbs_activesupport/attribute_accessor.rb +40 -0
- data/lib/rbs_activesupport/class_attribute.rb +36 -0
- data/lib/rbs_activesupport/declaration_builder.rb +122 -0
- data/lib/rbs_activesupport/delegate.rb +36 -0
- data/lib/rbs_activesupport/generator.rb +82 -0
- data/lib/rbs_activesupport/include.rb +61 -0
- data/lib/rbs_activesupport/method_searcher.rb +38 -0
- data/lib/rbs_activesupport/parser.rb +56 -0
- data/lib/rbs_activesupport/rake_task.rb +68 -0
- data/lib/rbs_activesupport/version.rb +5 -0
- data/lib/rbs_activesupport.rb +17 -0
- data/rbs_collection.lock.yaml +272 -0
- data/rbs_collection.yaml +19 -0
- data/sig/rbs_activesupport/ast.rbs +7 -0
- data/sig/rbs_activesupport/attribute_accessor.rbs +15 -0
- data/sig/rbs_activesupport/class_attribute.rbs +14 -0
- data/sig/rbs_activesupport/declaration_builder.rbs +25 -0
- data/sig/rbs_activesupport/delegate.rbs +13 -0
- data/sig/rbs_activesupport/generator.rbs +20 -0
- data/sig/rbs_activesupport/include.rbs +16 -0
- data/sig/rbs_activesupport/method_searcher.rbs +12 -0
- data/sig/rbs_activesupport/parser.rbs +22 -0
- data/sig/rbs_activesupport/rake_task.rbs +17 -0
- data/sig/rbs_activesupport.rbs +4 -0
- metadata +122 -0
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/concern"
|
4
|
+
|
5
|
+
module RbsActivesupport
|
6
|
+
class Include
|
7
|
+
attr_reader :context, :module_path, :options
|
8
|
+
|
9
|
+
def initialize(context, module_path, options)
|
10
|
+
@context = context
|
11
|
+
@module_path = module_path
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def argument
|
16
|
+
if module_path.first.nil?
|
17
|
+
RBS::Namespace.new(path: module_path[1...], absolute: true) # steep:ignore ArgumentTypeMismatch
|
18
|
+
else
|
19
|
+
RBS::Namespace.new(path: module_path, absolute: false) # steep:ignore ArgumentTypeMismatch
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def module_name
|
24
|
+
namespace = @context
|
25
|
+
|
26
|
+
loop do
|
27
|
+
modname = namespace + argument
|
28
|
+
return modname if Object.const_defined?(modname.to_s.delete_suffix("::"))
|
29
|
+
|
30
|
+
break if namespace.empty?
|
31
|
+
|
32
|
+
namespace = namespace.parent
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def concern?
|
37
|
+
return false unless module_name
|
38
|
+
|
39
|
+
modname = module_name.to_s.delete_suffix("::")
|
40
|
+
return false unless Object.const_defined?(modname)
|
41
|
+
|
42
|
+
mod = Object.const_get(modname)
|
43
|
+
mod&.singleton_class&.include?(ActiveSupport::Concern)
|
44
|
+
end
|
45
|
+
|
46
|
+
def classmethods?
|
47
|
+
return false unless module_name
|
48
|
+
|
49
|
+
modname = module_name.append(:ClassMethods).to_s.delete_suffix("::")
|
50
|
+
Object.const_defined?(modname)
|
51
|
+
end
|
52
|
+
|
53
|
+
def public?
|
54
|
+
!private?
|
55
|
+
end
|
56
|
+
|
57
|
+
def private?
|
58
|
+
options.fetch(:private, false)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rbs"
|
4
|
+
|
5
|
+
module RbsActivesupport
|
6
|
+
class MethodSearcher
|
7
|
+
attr_reader :rbs_builder
|
8
|
+
|
9
|
+
def initialize(rbs_builder)
|
10
|
+
@rbs_builder = rbs_builder
|
11
|
+
end
|
12
|
+
|
13
|
+
def method_types_for(delegate)
|
14
|
+
delegate_to = lookup_method_types(delegate.namespace.to_type_name, delegate.to)
|
15
|
+
return ["() -> untyped"] if delegate_to.any? { |t| t.type.return_type.is_a?(RBS::Types::Bases::Any) }
|
16
|
+
|
17
|
+
return_types = delegate_to
|
18
|
+
.filter_map { |t| t.type.return_type.name } # steep:ignore NoMethod
|
19
|
+
.uniq
|
20
|
+
.flat_map { |t| lookup_method_types(t, delegate.method) }
|
21
|
+
.map(&:to_s)
|
22
|
+
return_types << "() -> untyped" if return_types.empty?
|
23
|
+
return_types
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def lookup_method_types(type_name, method)
|
29
|
+
instance = rbs_builder.build_instance(type_name)
|
30
|
+
method_def = instance.methods[method]
|
31
|
+
return [] unless method_def
|
32
|
+
|
33
|
+
method_def.defs.map(&:type)
|
34
|
+
rescue StandardError
|
35
|
+
[]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "rbs"
|
5
|
+
require "rbs/cli"
|
6
|
+
require "rbs/prototype/rb"
|
7
|
+
|
8
|
+
module RbsActivesupport
|
9
|
+
class Parser < ::RBS::Prototype::RB
|
10
|
+
class MethodCall
|
11
|
+
attr_reader :name, :args
|
12
|
+
|
13
|
+
def initialize(name, args, private)
|
14
|
+
@name = name
|
15
|
+
@args = args
|
16
|
+
@private = private
|
17
|
+
end
|
18
|
+
|
19
|
+
def private?
|
20
|
+
@private
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
METHODS = %i[
|
25
|
+
class_attribute delegate cattr_accessor mattr_accessor cattr_reader mattr_reader cattr_writer mattr_writer include
|
26
|
+
].freeze # steep:ignore IncompatibleAssignment
|
27
|
+
|
28
|
+
alias process_orig process
|
29
|
+
|
30
|
+
attr_reader :method_calls
|
31
|
+
|
32
|
+
def initialize
|
33
|
+
super
|
34
|
+
@method_calls = Hash.new { |hash, key| hash[key] = [] }
|
35
|
+
end
|
36
|
+
|
37
|
+
def process(node, decls:, comments:, context:)
|
38
|
+
case node.type
|
39
|
+
when :FCALL, :VCALL
|
40
|
+
args = node.children[1]&.children || []
|
41
|
+
case node.children[0]
|
42
|
+
when *METHODS
|
43
|
+
@method_calls[context.namespace] << MethodCall.new(node.children[0], args, private?(decls))
|
44
|
+
else
|
45
|
+
process_orig(node, decls: decls, comments: comments, context: context)
|
46
|
+
end
|
47
|
+
else
|
48
|
+
process_orig(node, decls: decls, comments: comments, context: context)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def private?(decls)
|
53
|
+
current_accessibility(decls) == private
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
require "rake/tasklib"
|
5
|
+
|
6
|
+
module RbsActivesupport
|
7
|
+
class RakeTask < Rake::TaskLib
|
8
|
+
attr_accessor :name, :signature_root_dir
|
9
|
+
|
10
|
+
def initialize(name = :'rbs:activesupport', &block)
|
11
|
+
super()
|
12
|
+
|
13
|
+
@name = name
|
14
|
+
@signature_root_dir = Pathname(Rails.root / "sig/activesupport")
|
15
|
+
|
16
|
+
block&.call(self)
|
17
|
+
|
18
|
+
define_clean_task
|
19
|
+
define_generate_task
|
20
|
+
define_setup_task
|
21
|
+
end
|
22
|
+
|
23
|
+
def define_setup_task
|
24
|
+
desc "Run all tasks of rbs_activesupport"
|
25
|
+
|
26
|
+
deps = [:"#{name}:clean", :"#{name}:generate"]
|
27
|
+
task("#{name}:setup" => deps)
|
28
|
+
end
|
29
|
+
|
30
|
+
def define_generate_task
|
31
|
+
desc "Generate RBS files for activesupport gem"
|
32
|
+
task("#{name}:generate": :environment) do
|
33
|
+
require "rbs_activesupport" # load RbsActivesupport lazily
|
34
|
+
|
35
|
+
Rails.application.eager_load!
|
36
|
+
|
37
|
+
signature_root_dir.mkpath
|
38
|
+
|
39
|
+
(Rails.root / "app").glob("**/*.rb").each do |file|
|
40
|
+
rbs = Generator.new(file, rbs_builder).generate
|
41
|
+
next unless rbs
|
42
|
+
|
43
|
+
rbs_path = signature_root_dir / file.sub_ext(".rbs").relative_path_from(Rails.root)
|
44
|
+
rbs_path.dirname.mkpath
|
45
|
+
rbs_path.write(rbs)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def define_clean_task
|
51
|
+
desc "Clean RBS files for config gem"
|
52
|
+
task "#{name}:clean" do
|
53
|
+
signature_root_dir.rmtree if signature_root_dir.exist?
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def rbs_builder
|
60
|
+
@rbs_builder ||= begin
|
61
|
+
loader = RBS::CLI::LibraryOptions.new.loader
|
62
|
+
loader.add(path: Pathname("sig"))
|
63
|
+
env = RBS::Environment.from_loader(loader).resolve_type_names
|
64
|
+
RBS::DefinitionBuilder.new(env: env)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "rbs_activesupport/ast"
|
4
|
+
require_relative "rbs_activesupport/attribute_accessor"
|
5
|
+
require_relative "rbs_activesupport/class_attribute"
|
6
|
+
require_relative "rbs_activesupport/declaration_builder"
|
7
|
+
require_relative "rbs_activesupport/delegate"
|
8
|
+
require_relative "rbs_activesupport/generator"
|
9
|
+
require_relative "rbs_activesupport/include"
|
10
|
+
require_relative "rbs_activesupport/method_searcher"
|
11
|
+
require_relative "rbs_activesupport/parser"
|
12
|
+
require_relative "rbs_activesupport/version"
|
13
|
+
|
14
|
+
module RbsActivesupport
|
15
|
+
class Error < StandardError; end
|
16
|
+
# Your code goes here...
|
17
|
+
end
|
@@ -0,0 +1,272 @@
|
|
1
|
+
---
|
2
|
+
path: ".gem_rbs_collection"
|
3
|
+
gems:
|
4
|
+
- name: actionpack
|
5
|
+
version: '6.0'
|
6
|
+
source:
|
7
|
+
type: git
|
8
|
+
name: ruby/gem_rbs_collection
|
9
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
10
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
11
|
+
repo_dir: gems
|
12
|
+
- name: actionview
|
13
|
+
version: '6.0'
|
14
|
+
source:
|
15
|
+
type: git
|
16
|
+
name: ruby/gem_rbs_collection
|
17
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
18
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
19
|
+
repo_dir: gems
|
20
|
+
- name: activesupport
|
21
|
+
version: '7.0'
|
22
|
+
source:
|
23
|
+
type: git
|
24
|
+
name: ruby/gem_rbs_collection
|
25
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
26
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
27
|
+
repo_dir: gems
|
28
|
+
- name: ast
|
29
|
+
version: '2.4'
|
30
|
+
source:
|
31
|
+
type: git
|
32
|
+
name: ruby/gem_rbs_collection
|
33
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
34
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
35
|
+
repo_dir: gems
|
36
|
+
- name: base64
|
37
|
+
version: '0'
|
38
|
+
source:
|
39
|
+
type: stdlib
|
40
|
+
- name: bigdecimal
|
41
|
+
version: '0'
|
42
|
+
source:
|
43
|
+
type: stdlib
|
44
|
+
- name: cgi
|
45
|
+
version: '0'
|
46
|
+
source:
|
47
|
+
type: stdlib
|
48
|
+
- name: concurrent-ruby
|
49
|
+
version: '1.1'
|
50
|
+
source:
|
51
|
+
type: git
|
52
|
+
name: ruby/gem_rbs_collection
|
53
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
54
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
55
|
+
repo_dir: gems
|
56
|
+
- name: connection_pool
|
57
|
+
version: '2.4'
|
58
|
+
source:
|
59
|
+
type: git
|
60
|
+
name: ruby/gem_rbs_collection
|
61
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
62
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
63
|
+
repo_dir: gems
|
64
|
+
- name: date
|
65
|
+
version: '0'
|
66
|
+
source:
|
67
|
+
type: stdlib
|
68
|
+
- name: dbm
|
69
|
+
version: '0'
|
70
|
+
source:
|
71
|
+
type: stdlib
|
72
|
+
- name: erb
|
73
|
+
version: '0'
|
74
|
+
source:
|
75
|
+
type: stdlib
|
76
|
+
- name: fileutils
|
77
|
+
version: '0'
|
78
|
+
source:
|
79
|
+
type: stdlib
|
80
|
+
- name: i18n
|
81
|
+
version: '1.10'
|
82
|
+
source:
|
83
|
+
type: git
|
84
|
+
name: ruby/gem_rbs_collection
|
85
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
86
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
87
|
+
repo_dir: gems
|
88
|
+
- name: io-console
|
89
|
+
version: '0'
|
90
|
+
source:
|
91
|
+
type: stdlib
|
92
|
+
- name: json
|
93
|
+
version: '0'
|
94
|
+
source:
|
95
|
+
type: stdlib
|
96
|
+
- name: logger
|
97
|
+
version: '0'
|
98
|
+
source:
|
99
|
+
type: stdlib
|
100
|
+
- name: minitest
|
101
|
+
version: '0'
|
102
|
+
source:
|
103
|
+
type: stdlib
|
104
|
+
- name: monitor
|
105
|
+
version: '0'
|
106
|
+
source:
|
107
|
+
type: stdlib
|
108
|
+
- name: mutex_m
|
109
|
+
version: '0'
|
110
|
+
source:
|
111
|
+
type: stdlib
|
112
|
+
- name: nokogiri
|
113
|
+
version: '1.11'
|
114
|
+
source:
|
115
|
+
type: git
|
116
|
+
name: ruby/gem_rbs_collection
|
117
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
118
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
119
|
+
repo_dir: gems
|
120
|
+
- name: optparse
|
121
|
+
version: '0'
|
122
|
+
source:
|
123
|
+
type: stdlib
|
124
|
+
- name: parallel
|
125
|
+
version: '1.20'
|
126
|
+
source:
|
127
|
+
type: git
|
128
|
+
name: ruby/gem_rbs_collection
|
129
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
130
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
131
|
+
repo_dir: gems
|
132
|
+
- name: parser
|
133
|
+
version: '3.2'
|
134
|
+
source:
|
135
|
+
type: git
|
136
|
+
name: ruby/gem_rbs_collection
|
137
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
138
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
139
|
+
repo_dir: gems
|
140
|
+
- name: pathname
|
141
|
+
version: '0'
|
142
|
+
source:
|
143
|
+
type: stdlib
|
144
|
+
- name: pstore
|
145
|
+
version: '0'
|
146
|
+
source:
|
147
|
+
type: stdlib
|
148
|
+
- name: psych
|
149
|
+
version: '0'
|
150
|
+
source:
|
151
|
+
type: stdlib
|
152
|
+
- name: rack
|
153
|
+
version: '2.2'
|
154
|
+
source:
|
155
|
+
type: git
|
156
|
+
name: ruby/gem_rbs_collection
|
157
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
158
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
159
|
+
repo_dir: gems
|
160
|
+
- name: rails-dom-testing
|
161
|
+
version: '2.0'
|
162
|
+
source:
|
163
|
+
type: git
|
164
|
+
name: ruby/gem_rbs_collection
|
165
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
166
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
167
|
+
repo_dir: gems
|
168
|
+
- name: railties
|
169
|
+
version: '6.0'
|
170
|
+
source:
|
171
|
+
type: git
|
172
|
+
name: ruby/gem_rbs_collection
|
173
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
174
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
175
|
+
repo_dir: gems
|
176
|
+
- name: rainbow
|
177
|
+
version: '3.0'
|
178
|
+
source:
|
179
|
+
type: git
|
180
|
+
name: ruby/gem_rbs_collection
|
181
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
182
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
183
|
+
repo_dir: gems
|
184
|
+
- name: rake
|
185
|
+
version: '13.0'
|
186
|
+
source:
|
187
|
+
type: git
|
188
|
+
name: ruby/gem_rbs_collection
|
189
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
190
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
191
|
+
repo_dir: gems
|
192
|
+
- name: rbs
|
193
|
+
version: 3.5.2
|
194
|
+
source:
|
195
|
+
type: rubygems
|
196
|
+
- name: rdoc
|
197
|
+
version: '0'
|
198
|
+
source:
|
199
|
+
type: stdlib
|
200
|
+
- name: regexp_parser
|
201
|
+
version: '2.8'
|
202
|
+
source:
|
203
|
+
type: git
|
204
|
+
name: ruby/gem_rbs_collection
|
205
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
206
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
207
|
+
repo_dir: gems
|
208
|
+
- name: rubocop
|
209
|
+
version: '1.57'
|
210
|
+
source:
|
211
|
+
type: git
|
212
|
+
name: ruby/gem_rbs_collection
|
213
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
214
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
215
|
+
repo_dir: gems
|
216
|
+
- name: rubocop-ast
|
217
|
+
version: '1.30'
|
218
|
+
source:
|
219
|
+
type: git
|
220
|
+
name: ruby/gem_rbs_collection
|
221
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
222
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
223
|
+
repo_dir: gems
|
224
|
+
- name: securerandom
|
225
|
+
version: '0'
|
226
|
+
source:
|
227
|
+
type: stdlib
|
228
|
+
- name: singleton
|
229
|
+
version: '0'
|
230
|
+
source:
|
231
|
+
type: stdlib
|
232
|
+
- name: strscan
|
233
|
+
version: '0'
|
234
|
+
source:
|
235
|
+
type: stdlib
|
236
|
+
- name: tempfile
|
237
|
+
version: '0'
|
238
|
+
source:
|
239
|
+
type: stdlib
|
240
|
+
- name: thor
|
241
|
+
version: '1.2'
|
242
|
+
source:
|
243
|
+
type: git
|
244
|
+
name: ruby/gem_rbs_collection
|
245
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
246
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
247
|
+
repo_dir: gems
|
248
|
+
- name: time
|
249
|
+
version: '0'
|
250
|
+
source:
|
251
|
+
type: stdlib
|
252
|
+
- name: timeout
|
253
|
+
version: '0'
|
254
|
+
source:
|
255
|
+
type: stdlib
|
256
|
+
- name: tsort
|
257
|
+
version: '0'
|
258
|
+
source:
|
259
|
+
type: stdlib
|
260
|
+
- name: tzinfo
|
261
|
+
version: '2.0'
|
262
|
+
source:
|
263
|
+
type: git
|
264
|
+
name: ruby/gem_rbs_collection
|
265
|
+
revision: a6ed3d2c66aa743a4f6f71b70e0c7e912b94d054
|
266
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
267
|
+
repo_dir: gems
|
268
|
+
- name: uri
|
269
|
+
version: '0'
|
270
|
+
source:
|
271
|
+
type: stdlib
|
272
|
+
gemfile_lock_path: Gemfile.lock
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Download sources
|
2
|
+
sources:
|
3
|
+
- type: git
|
4
|
+
name: ruby/gem_rbs_collection
|
5
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
6
|
+
revision: main
|
7
|
+
repo_dir: gems
|
8
|
+
|
9
|
+
# You can specify local directories as sources also.
|
10
|
+
# - type: local
|
11
|
+
# path: path/to/your/local/repository
|
12
|
+
|
13
|
+
# A directory to install the downloaded RBSs
|
14
|
+
path: .gem_rbs_collection
|
15
|
+
|
16
|
+
# gems:
|
17
|
+
# # If you want to avoid installing rbs files for gems, you can specify them here.
|
18
|
+
# - name: GEM_NAME
|
19
|
+
# ignore: true
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class AttributeAccessor
|
3
|
+
attr_reader name: Symbol
|
4
|
+
attr_reader options: Hash[untyped, untyped]
|
5
|
+
|
6
|
+
def initialize: (Symbol name, Hash[untyped, untyped] options) -> void
|
7
|
+
def singleton_reader?: () -> bool
|
8
|
+
def singleton_writer?: () -> bool
|
9
|
+
def instance_accessor?: () -> bool
|
10
|
+
def instance_reader?: () -> bool
|
11
|
+
def instance_writer?: () -> bool
|
12
|
+
def public?: () -> bool
|
13
|
+
def private?: () -> bool
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class ClassAttribute
|
3
|
+
attr_reader name: Symbol
|
4
|
+
attr_reader options: Hash[untyped, untyped]
|
5
|
+
|
6
|
+
def initialize: (Symbol name, Hash[untyped, untyped] options) -> void
|
7
|
+
def instance_accessor?: () -> bool
|
8
|
+
def instance_reader?: () -> bool
|
9
|
+
def instance_writer?: () -> bool
|
10
|
+
def instance_predicate?: () -> bool
|
11
|
+
def public?: () -> bool
|
12
|
+
def private?: () -> bool
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class DeclarationBuilder
|
3
|
+
type t = AttributeAccessor | ClassAttribute | Delegate | Include
|
4
|
+
|
5
|
+
include AST
|
6
|
+
|
7
|
+
attr_reader method_searcher: MethodSearcher
|
8
|
+
|
9
|
+
def initialize: (MethodSearcher method_searcher) -> void
|
10
|
+
def build: (RBS::Namespace namespace, Array[Parser::MethodCall] method_calls) -> [Array[String], Array[String]]
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def build_method_calls: (RBS::Namespace namespace, Array[Parser::MethodCall] method_calls) -> Array[t]
|
15
|
+
def build_attribute_accessor: (Parser::MethodCall method_call) -> Array[AttributeAccessor]
|
16
|
+
def build_class_attribute: (Parser::MethodCall method_calls) -> Array[ClassAttribute]
|
17
|
+
def build_delegate: (RBS::Namespace namespace, Parser::MethodCall method_calls) -> Array[Delegate]
|
18
|
+
def build_include: (RBS::Namespace namespace, Parser::MethodCall method_calls) -> Array[Include]
|
19
|
+
def render: (t decl) -> String?
|
20
|
+
def render_attribute_accessor: (AttributeAccessor decl) -> String
|
21
|
+
def render_class_attribute: (ClassAttribute decl) -> String
|
22
|
+
def render_delegate: (Delegate decl) -> String
|
23
|
+
def render_include: (Include decl) -> String?
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class Delegate
|
3
|
+
attr_reader namespace: RBS::Namespace
|
4
|
+
attr_reader method: Symbol
|
5
|
+
attr_reader options: Hash[Symbol, untyped]
|
6
|
+
|
7
|
+
def initialize: (RBS::Namespace namespace, Symbol method, Hash[Symbol, untyped] options) -> void
|
8
|
+
def to: () -> Symbol
|
9
|
+
def method_name: () -> Symbol
|
10
|
+
def public?: () -> bool
|
11
|
+
def private?: () -> bool
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class Generator
|
3
|
+
def self.generate: (Pathname pathname, RBS::DefinitionBuilder rbs_builder) -> String?
|
4
|
+
|
5
|
+
include AST
|
6
|
+
|
7
|
+
attr_reader pathname: Pathname
|
8
|
+
attr_reader declaration_builder: DeclarationBuilder
|
9
|
+
|
10
|
+
def initialize: (Pathname pathname, RBS::DefinitionBuilder rbs_builder) -> void
|
11
|
+
def generate: () -> String?
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def format: (String rbs) -> String
|
16
|
+
def parse_source_code: () -> Hash[RBS::Namespace, Array[Parser::MethodCall]]
|
17
|
+
def header: (RBS::Namespace namespace) -> String
|
18
|
+
def footer: (RBS::Namespace namespace) -> String
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class Include
|
3
|
+
attr_reader context: RBS::Namespace
|
4
|
+
attr_reader module_path: Array[Symbol?]
|
5
|
+
attr_reader options: Hash[Symbol, untyped]
|
6
|
+
|
7
|
+
def initialize: (RBS::Namespace context, Array[Symbol?] module_path, Hash[Symbol, untyped] options) -> void
|
8
|
+
def argument: () -> RBS::Namespace
|
9
|
+
%a{pure}
|
10
|
+
def module_name: () -> RBS::Namespace?
|
11
|
+
def concern?: () -> bool
|
12
|
+
def classmethods?: () -> bool
|
13
|
+
def public?: () -> bool
|
14
|
+
def private?: () -> bool
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class MethodSearcher
|
3
|
+
attr_reader rbs_builder: RBS::DefinitionBuilder
|
4
|
+
|
5
|
+
def initialize: (RBS::DefinitionBuilder rbs_builder) -> void
|
6
|
+
def method_types_for: (Delegate delegate) -> Array[String]
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def lookup_method_types: (RBS::TypeName namespace, Symbol method) -> Array[RBS::MethodType]
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module RbsActivesupport
|
2
|
+
class Parser < ::RBS::Prototype::RB
|
3
|
+
class MethodCall
|
4
|
+
attr_reader name: t
|
5
|
+
attr_reader args: Array[RubyVM::AbstractSyntaxTree::Node]
|
6
|
+
|
7
|
+
@private: bool
|
8
|
+
|
9
|
+
def initialize: (t name, Array[RubyVM::AbstractSyntaxTree::Node] args, bool private) -> void
|
10
|
+
def private?: () -> bool
|
11
|
+
end
|
12
|
+
|
13
|
+
type t = :class_attribute | :delegate | :cattr_accessor | :mattr_accessor | :cattr_reader | :mattr_reader | :cattr_writer | :mattr_writer | :include
|
14
|
+
METHODS: Array[t]
|
15
|
+
|
16
|
+
alias process_orig process
|
17
|
+
|
18
|
+
attr_reader method_calls: Hash[RBS::Namespace, Array[MethodCall]]
|
19
|
+
|
20
|
+
def private?: (Array[RBS::AST::Declarations::t | RBS::AST::Members::t] decls) -> bool
|
21
|
+
end
|
22
|
+
end
|