rbs_activerecord 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +22 -0
- data/.vscode/extensions.json +6 -0
- data/.vscode/settings.json +12 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +14 -0
- data/Steepfile +9 -0
- data/lib/generators/rbs_activerecord/install_generator.rb +21 -0
- data/lib/rbs_activerecord/generator/active_storage/instance_methods.rb +57 -0
- data/lib/rbs_activerecord/generator/active_storage/scopes.rb +39 -0
- data/lib/rbs_activerecord/generator/associations.rb +118 -0
- data/lib/rbs_activerecord/generator/attributes.rb +95 -0
- data/lib/rbs_activerecord/generator/delegated_type/instance_methods.rb +66 -0
- data/lib/rbs_activerecord/generator/delegated_type/scopes.rb +44 -0
- data/lib/rbs_activerecord/generator/enum/base.rb +63 -0
- data/lib/rbs_activerecord/generator/enum/instance_methods.rb +51 -0
- data/lib/rbs_activerecord/generator/enum/scopes.rb +51 -0
- data/lib/rbs_activerecord/generator/pluck_overloads.rb +41 -0
- data/lib/rbs_activerecord/generator/scopes.rb +99 -0
- data/lib/rbs_activerecord/generator/secure_password.rb +54 -0
- data/lib/rbs_activerecord/generator.rb +143 -0
- data/lib/rbs_activerecord/model.rb +33 -0
- data/lib/rbs_activerecord/parser/evaluator.rb +48 -0
- data/lib/rbs_activerecord/parser/visitor.rb +67 -0
- data/lib/rbs_activerecord/parser.rb +30 -0
- data/lib/rbs_activerecord/rake_task.rb +61 -0
- data/lib/rbs_activerecord/utils.rb +58 -0
- data/lib/rbs_activerecord/version.rb +5 -0
- data/lib/rbs_activerecord.rb +27 -0
- data/rbs_collection.lock.yaml +352 -0
- data/rbs_collection.yaml +18 -0
- data/sig/generators/rbs_activerecord/install_generator.rbs +7 -0
- data/sig/rbs_activerecord/generator/active_storage/instance_methods.rbs +23 -0
- data/sig/rbs_activerecord/generator/active_storage/scopes.rbs +23 -0
- data/sig/rbs_activerecord/generator/associations.rbs +29 -0
- data/sig/rbs_activerecord/generator/attributes.rbs +28 -0
- data/sig/rbs_activerecord/generator/delegated_type/instance_methods.rbs +31 -0
- data/sig/rbs_activerecord/generator/delegated_type/scopes.rbs +26 -0
- data/sig/rbs_activerecord/generator/enum/base.rbs +19 -0
- data/sig/rbs_activerecord/generator/enum/instance_methods.rbs +26 -0
- data/sig/rbs_activerecord/generator/enum/scopes.rbs +26 -0
- data/sig/rbs_activerecord/generator/pluck_overloads.rbs +23 -0
- data/sig/rbs_activerecord/generator/scopes.rbs +27 -0
- data/sig/rbs_activerecord/generator/secure_password.rbs +22 -0
- data/sig/rbs_activerecord/generator.rbs +34 -0
- data/sig/rbs_activerecord/model.rbs +26 -0
- data/sig/rbs_activerecord/parser/evaluator.rbs +12 -0
- data/sig/rbs_activerecord/parser/visitor.rbs +27 -0
- data/sig/rbs_activerecord/parser.rbs +15 -0
- data/sig/rbs_activerecord/rake_task.rbs +19 -0
- data/sig/rbs_activerecord/utils.rbs +14 -0
- data/sig/rbs_activerecord/version.rbs +5 -0
- data/sig/rbs_activerecord.rbs +6 -0
- metadata +142 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "prism"
|
4
|
+
|
5
|
+
module RbsActiverecord
|
6
|
+
module Parser
|
7
|
+
# NOTE: rbs-inline-0.9.0 does not support module_function yet.
|
8
|
+
# refs: https://github.com/soutaro/rbs-inline/pull/118
|
9
|
+
#
|
10
|
+
# @rbs!
|
11
|
+
# def self.parse: (String filename) -> Hash[String, Array[Prism::CallNode]]
|
12
|
+
# def self.eval_node: (Prism::Node node) -> untyped
|
13
|
+
|
14
|
+
# @rbs filename: String
|
15
|
+
def parse(filename) #: Hash[String, Array[Prism::CallNode]]
|
16
|
+
result = Prism.parse_file(filename)
|
17
|
+
|
18
|
+
visitor = Visitor.new
|
19
|
+
visitor.visit(result.value)
|
20
|
+
visitor.decls
|
21
|
+
end
|
22
|
+
module_function :parse
|
23
|
+
|
24
|
+
# @rbs node: Prism::Node
|
25
|
+
def eval_node(node) #: untyped
|
26
|
+
Evaluator.eval_node(node)
|
27
|
+
end
|
28
|
+
module_function :eval_node
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rake/tasklib"
|
4
|
+
|
5
|
+
module RbsActiverecord
|
6
|
+
class RakeTask < Rake::TaskLib
|
7
|
+
attr_accessor :name, :signature_root_dir
|
8
|
+
|
9
|
+
# @rbs name: Symbol
|
10
|
+
# @rbs &block: (RakeTask) -> void
|
11
|
+
def initialize(name = :'rbs:activerecord', &block) #: void
|
12
|
+
super()
|
13
|
+
|
14
|
+
@name = name
|
15
|
+
@signature_root_dir = Rails.root / "sig/activerecord"
|
16
|
+
|
17
|
+
block&.call(self)
|
18
|
+
|
19
|
+
define_setup_task
|
20
|
+
define_clean_task
|
21
|
+
define_generate_task
|
22
|
+
end
|
23
|
+
|
24
|
+
def define_setup_task #: void
|
25
|
+
desc "Run all tasks of rbs_activerecord"
|
26
|
+
|
27
|
+
deps = [:"#{name}:clean", :"#{name}:generate"]
|
28
|
+
task("#{name}:setup" => deps)
|
29
|
+
end
|
30
|
+
|
31
|
+
def define_clean_task #: void
|
32
|
+
desc "Clean RBS files for ActiveRecord models"
|
33
|
+
task "#{name}:clean" do
|
34
|
+
signature_root_dir.rmtree if signature_root_dir.exist?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def define_generate_task #: void # rubocop:disable Metrics/AbcSize
|
39
|
+
desc "Generate RBS files for ActiveRecord models"
|
40
|
+
task("#{name}:generate": :environment) do
|
41
|
+
require "rbs_activerecord" # load RbsActiverecord lazily
|
42
|
+
|
43
|
+
Rails.application.eager_load!
|
44
|
+
|
45
|
+
signature_root_dir.mkpath
|
46
|
+
|
47
|
+
ActiveRecord::Base.descendants.each do |klass|
|
48
|
+
next if klass.abstract_class?
|
49
|
+
next unless klass.connection.table_exists?(klass.table_name)
|
50
|
+
|
51
|
+
rbs = Generator.new(klass).generate
|
52
|
+
next unless rbs
|
53
|
+
|
54
|
+
path = signature_root_dir / "app/models/#{klass.name.underscore}.rbs"
|
55
|
+
path.dirname.mkpath
|
56
|
+
path.write(rbs)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rbs"
|
4
|
+
|
5
|
+
module RbsActiverecord
|
6
|
+
module Utils
|
7
|
+
# @rbs str: String
|
8
|
+
def format(str) #: String
|
9
|
+
parsed = RBS::Parser.parse_signature(str)
|
10
|
+
StringIO.new.tap do |out|
|
11
|
+
RBS::Writer.new(out: out).write(parsed[1] + parsed[2])
|
12
|
+
end.string
|
13
|
+
end
|
14
|
+
|
15
|
+
# @rbs klass: singleton(ActiveRecord::Base)
|
16
|
+
def primary_key_type_for(klass) #: String # rubocop:disable Metrics/AbcSize
|
17
|
+
case klass.primary_key
|
18
|
+
when Array
|
19
|
+
primary_keys = klass.primary_key.map(&:to_s)
|
20
|
+
types = klass.columns
|
21
|
+
.select { |column| primary_keys.include?(column.name) }
|
22
|
+
.map { |pk| sql_type_to_class(pk.type) }
|
23
|
+
"[#{types.join(" | ")}]"
|
24
|
+
else
|
25
|
+
primary_key = klass.columns.find { |column| column.name == klass.primary_key }
|
26
|
+
sql_type_to_class(primary_key.type)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# @rbs type: Symbol
|
31
|
+
def sql_type_to_class(type) #: String # rubocop:disable Metris/CyclomaticComplexity
|
32
|
+
case type
|
33
|
+
when :integer
|
34
|
+
"::Integer"
|
35
|
+
when :float
|
36
|
+
"::Float"
|
37
|
+
when :decimal
|
38
|
+
"::BigDecimal"
|
39
|
+
when :string, :text, :citext, :uuid, :binary
|
40
|
+
"::String"
|
41
|
+
when :datetime
|
42
|
+
"::ActiveSupport::TimeWithZone"
|
43
|
+
when :date
|
44
|
+
"::Date"
|
45
|
+
when :time
|
46
|
+
"::Time"
|
47
|
+
when :boolean
|
48
|
+
"bool"
|
49
|
+
when :jsonb, :json
|
50
|
+
"untyped"
|
51
|
+
when :inet
|
52
|
+
"::IPAddr"
|
53
|
+
else
|
54
|
+
"untyped"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "rbs_activerecord/utils"
|
4
|
+
|
5
|
+
require_relative "rbs_activerecord/generator"
|
6
|
+
require_relative "rbs_activerecord/generator/active_storage/instance_methods"
|
7
|
+
require_relative "rbs_activerecord/generator/active_storage/scopes"
|
8
|
+
require_relative "rbs_activerecord/generator/associations"
|
9
|
+
require_relative "rbs_activerecord/generator/attributes"
|
10
|
+
require_relative "rbs_activerecord/generator/delegated_type/instance_methods"
|
11
|
+
require_relative "rbs_activerecord/generator/delegated_type/scopes"
|
12
|
+
require_relative "rbs_activerecord/generator/enum/base"
|
13
|
+
require_relative "rbs_activerecord/generator/enum/instance_methods"
|
14
|
+
require_relative "rbs_activerecord/generator/enum/scopes"
|
15
|
+
require_relative "rbs_activerecord/generator/pluck_overloads"
|
16
|
+
require_relative "rbs_activerecord/generator/scopes"
|
17
|
+
require_relative "rbs_activerecord/generator/secure_password"
|
18
|
+
require_relative "rbs_activerecord/model"
|
19
|
+
require_relative "rbs_activerecord/parser"
|
20
|
+
require_relative "rbs_activerecord/parser/evaluator"
|
21
|
+
require_relative "rbs_activerecord/parser/visitor"
|
22
|
+
require_relative "rbs_activerecord/version"
|
23
|
+
|
24
|
+
module RbsActiverecord
|
25
|
+
class Error < StandardError; end
|
26
|
+
# Your code goes here...
|
27
|
+
end
|
@@ -0,0 +1,352 @@
|
|
1
|
+
---
|
2
|
+
path: ".gem_rbs_collection"
|
3
|
+
gems:
|
4
|
+
- name: actionpack
|
5
|
+
version: '7.2'
|
6
|
+
source:
|
7
|
+
type: git
|
8
|
+
name: ruby/gem_rbs_collection
|
9
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
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: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
18
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
19
|
+
repo_dir: gems
|
20
|
+
- name: activejob
|
21
|
+
version: '6.0'
|
22
|
+
source:
|
23
|
+
type: git
|
24
|
+
name: ruby/gem_rbs_collection
|
25
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
26
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
27
|
+
repo_dir: gems
|
28
|
+
- name: activemodel
|
29
|
+
version: '7.0'
|
30
|
+
source:
|
31
|
+
type: git
|
32
|
+
name: ruby/gem_rbs_collection
|
33
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
34
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
35
|
+
repo_dir: gems
|
36
|
+
- name: activerecord
|
37
|
+
version: '7.2'
|
38
|
+
source:
|
39
|
+
type: git
|
40
|
+
name: ruby/gem_rbs_collection
|
41
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
42
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
43
|
+
repo_dir: gems
|
44
|
+
- name: activestorage
|
45
|
+
version: '7.0'
|
46
|
+
source:
|
47
|
+
type: git
|
48
|
+
name: ruby/gem_rbs_collection
|
49
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
50
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
51
|
+
repo_dir: gems
|
52
|
+
- name: activesupport
|
53
|
+
version: '7.0'
|
54
|
+
source:
|
55
|
+
type: git
|
56
|
+
name: ruby/gem_rbs_collection
|
57
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
58
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
59
|
+
repo_dir: gems
|
60
|
+
- name: ast
|
61
|
+
version: '2.4'
|
62
|
+
source:
|
63
|
+
type: git
|
64
|
+
name: ruby/gem_rbs_collection
|
65
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
66
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
67
|
+
repo_dir: gems
|
68
|
+
- name: base64
|
69
|
+
version: '0'
|
70
|
+
source:
|
71
|
+
type: stdlib
|
72
|
+
- name: bcrypt
|
73
|
+
version: '3.1'
|
74
|
+
source:
|
75
|
+
type: git
|
76
|
+
name: ruby/gem_rbs_collection
|
77
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
78
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
79
|
+
repo_dir: gems
|
80
|
+
- name: benchmark
|
81
|
+
version: '0'
|
82
|
+
source:
|
83
|
+
type: stdlib
|
84
|
+
- name: bigdecimal
|
85
|
+
version: '0'
|
86
|
+
source:
|
87
|
+
type: stdlib
|
88
|
+
- name: cgi
|
89
|
+
version: '0'
|
90
|
+
source:
|
91
|
+
type: stdlib
|
92
|
+
- name: concurrent-ruby
|
93
|
+
version: '1.1'
|
94
|
+
source:
|
95
|
+
type: git
|
96
|
+
name: ruby/gem_rbs_collection
|
97
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
98
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
99
|
+
repo_dir: gems
|
100
|
+
- name: connection_pool
|
101
|
+
version: '2.4'
|
102
|
+
source:
|
103
|
+
type: git
|
104
|
+
name: ruby/gem_rbs_collection
|
105
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
106
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
107
|
+
repo_dir: gems
|
108
|
+
- name: date
|
109
|
+
version: '0'
|
110
|
+
source:
|
111
|
+
type: stdlib
|
112
|
+
- name: delegate
|
113
|
+
version: '0'
|
114
|
+
source:
|
115
|
+
type: stdlib
|
116
|
+
- name: erb
|
117
|
+
version: '0'
|
118
|
+
source:
|
119
|
+
type: stdlib
|
120
|
+
- name: fileutils
|
121
|
+
version: '0'
|
122
|
+
source:
|
123
|
+
type: stdlib
|
124
|
+
- name: forwardable
|
125
|
+
version: '0'
|
126
|
+
source:
|
127
|
+
type: stdlib
|
128
|
+
- name: globalid
|
129
|
+
version: '1.1'
|
130
|
+
source:
|
131
|
+
type: git
|
132
|
+
name: ruby/gem_rbs_collection
|
133
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
134
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
135
|
+
repo_dir: gems
|
136
|
+
- name: i18n
|
137
|
+
version: '1.10'
|
138
|
+
source:
|
139
|
+
type: git
|
140
|
+
name: ruby/gem_rbs_collection
|
141
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
142
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
143
|
+
repo_dir: gems
|
144
|
+
- name: io-console
|
145
|
+
version: '0'
|
146
|
+
source:
|
147
|
+
type: stdlib
|
148
|
+
- name: json
|
149
|
+
version: '0'
|
150
|
+
source:
|
151
|
+
type: stdlib
|
152
|
+
- name: logger
|
153
|
+
version: '0'
|
154
|
+
source:
|
155
|
+
type: stdlib
|
156
|
+
- name: marcel
|
157
|
+
version: '1.0'
|
158
|
+
source:
|
159
|
+
type: git
|
160
|
+
name: ruby/gem_rbs_collection
|
161
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
162
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
163
|
+
repo_dir: gems
|
164
|
+
- name: minitest
|
165
|
+
version: '0'
|
166
|
+
source:
|
167
|
+
type: stdlib
|
168
|
+
- name: monitor
|
169
|
+
version: '0'
|
170
|
+
source:
|
171
|
+
type: stdlib
|
172
|
+
- name: mutex_m
|
173
|
+
version: '0'
|
174
|
+
source:
|
175
|
+
type: stdlib
|
176
|
+
- name: nokogiri
|
177
|
+
version: '1.11'
|
178
|
+
source:
|
179
|
+
type: git
|
180
|
+
name: ruby/gem_rbs_collection
|
181
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
182
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
183
|
+
repo_dir: gems
|
184
|
+
- name: openssl
|
185
|
+
version: '0'
|
186
|
+
source:
|
187
|
+
type: stdlib
|
188
|
+
- name: optparse
|
189
|
+
version: '0'
|
190
|
+
source:
|
191
|
+
type: stdlib
|
192
|
+
- name: parallel
|
193
|
+
version: '1.20'
|
194
|
+
source:
|
195
|
+
type: git
|
196
|
+
name: ruby/gem_rbs_collection
|
197
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
198
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
199
|
+
repo_dir: gems
|
200
|
+
- name: parser
|
201
|
+
version: '3.2'
|
202
|
+
source:
|
203
|
+
type: git
|
204
|
+
name: ruby/gem_rbs_collection
|
205
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
206
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
207
|
+
repo_dir: gems
|
208
|
+
- name: pathname
|
209
|
+
version: '0'
|
210
|
+
source:
|
211
|
+
type: stdlib
|
212
|
+
- name: prism
|
213
|
+
version: 1.0.0
|
214
|
+
source:
|
215
|
+
type: rubygems
|
216
|
+
- name: rack
|
217
|
+
version: '2.2'
|
218
|
+
source:
|
219
|
+
type: git
|
220
|
+
name: ruby/gem_rbs_collection
|
221
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
222
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
223
|
+
repo_dir: gems
|
224
|
+
- name: rails-dom-testing
|
225
|
+
version: '2.0'
|
226
|
+
source:
|
227
|
+
type: git
|
228
|
+
name: ruby/gem_rbs_collection
|
229
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
230
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
231
|
+
repo_dir: gems
|
232
|
+
- name: rails-html-sanitizer
|
233
|
+
version: '1.6'
|
234
|
+
source:
|
235
|
+
type: git
|
236
|
+
name: ruby/gem_rbs_collection
|
237
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
238
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
239
|
+
repo_dir: gems
|
240
|
+
- name: railties
|
241
|
+
version: '6.0'
|
242
|
+
source:
|
243
|
+
type: git
|
244
|
+
name: ruby/gem_rbs_collection
|
245
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
246
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
247
|
+
repo_dir: gems
|
248
|
+
- name: rainbow
|
249
|
+
version: '3.0'
|
250
|
+
source:
|
251
|
+
type: git
|
252
|
+
name: ruby/gem_rbs_collection
|
253
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
254
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
255
|
+
repo_dir: gems
|
256
|
+
- name: rake
|
257
|
+
version: '13.0'
|
258
|
+
source:
|
259
|
+
type: git
|
260
|
+
name: ruby/gem_rbs_collection
|
261
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
262
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
263
|
+
repo_dir: gems
|
264
|
+
- name: rbs
|
265
|
+
version: 3.6.1
|
266
|
+
source:
|
267
|
+
type: rubygems
|
268
|
+
- name: rdoc
|
269
|
+
version: '0'
|
270
|
+
source:
|
271
|
+
type: stdlib
|
272
|
+
- name: regexp_parser
|
273
|
+
version: '2.8'
|
274
|
+
source:
|
275
|
+
type: git
|
276
|
+
name: ruby/gem_rbs_collection
|
277
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
278
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
279
|
+
repo_dir: gems
|
280
|
+
- name: rubocop
|
281
|
+
version: '1.57'
|
282
|
+
source:
|
283
|
+
type: git
|
284
|
+
name: ruby/gem_rbs_collection
|
285
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
286
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
287
|
+
repo_dir: gems
|
288
|
+
- name: rubocop-ast
|
289
|
+
version: '1.30'
|
290
|
+
source:
|
291
|
+
type: git
|
292
|
+
name: ruby/gem_rbs_collection
|
293
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
294
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
295
|
+
repo_dir: gems
|
296
|
+
- name: securerandom
|
297
|
+
version: '0'
|
298
|
+
source:
|
299
|
+
type: stdlib
|
300
|
+
- name: singleton
|
301
|
+
version: '0'
|
302
|
+
source:
|
303
|
+
type: stdlib
|
304
|
+
- name: socket
|
305
|
+
version: '0'
|
306
|
+
source:
|
307
|
+
type: stdlib
|
308
|
+
- name: sqlite3
|
309
|
+
version: '2.0'
|
310
|
+
source:
|
311
|
+
type: git
|
312
|
+
name: ruby/gem_rbs_collection
|
313
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
314
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
315
|
+
repo_dir: gems
|
316
|
+
- name: tempfile
|
317
|
+
version: '0'
|
318
|
+
source:
|
319
|
+
type: stdlib
|
320
|
+
- name: thor
|
321
|
+
version: '1.2'
|
322
|
+
source:
|
323
|
+
type: git
|
324
|
+
name: ruby/gem_rbs_collection
|
325
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
326
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
327
|
+
repo_dir: gems
|
328
|
+
- name: time
|
329
|
+
version: '0'
|
330
|
+
source:
|
331
|
+
type: stdlib
|
332
|
+
- name: timeout
|
333
|
+
version: '0'
|
334
|
+
source:
|
335
|
+
type: stdlib
|
336
|
+
- name: tsort
|
337
|
+
version: '0'
|
338
|
+
source:
|
339
|
+
type: stdlib
|
340
|
+
- name: tzinfo
|
341
|
+
version: '2.0'
|
342
|
+
source:
|
343
|
+
type: git
|
344
|
+
name: ruby/gem_rbs_collection
|
345
|
+
revision: 9b07b7bde4c9f656f3f6d785bd676320032cecb4
|
346
|
+
remote: https://github.com/ruby/gem_rbs_collection.git
|
347
|
+
repo_dir: gems
|
348
|
+
- name: uri
|
349
|
+
version: '0'
|
350
|
+
source:
|
351
|
+
type: stdlib
|
352
|
+
gemfile_lock_path: Gemfile.lock
|
data/rbs_collection.yaml
ADDED
@@ -0,0 +1,18 @@
|
|
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
|
+
- name: forwardable
|
18
|
+
- name: rbs
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/generator/active_storage/instance_methods.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
module ActiveStorage
|
6
|
+
class InstanceMethods
|
7
|
+
attr_reader model: RbsActiverecord::Model
|
8
|
+
|
9
|
+
# @rbs model: RbsActiverecord::Model
|
10
|
+
def initialize: (RbsActiverecord::Model model) -> void
|
11
|
+
|
12
|
+
def generate: () -> String
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def attachments: () -> Hash[String, untyped]
|
17
|
+
|
18
|
+
# @rbs name: String
|
19
|
+
def attachment: (String name, untyped reflection) -> String
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/generator/active_storage/scopes.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
module ActiveStorage
|
6
|
+
class Scopes
|
7
|
+
attr_reader model: RbsActiverecord::Model
|
8
|
+
|
9
|
+
# @rbs model: RbsActiverecord::Model
|
10
|
+
def initialize: (RbsActiverecord::Model model) -> void
|
11
|
+
|
12
|
+
def generate: () -> String
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def attachments: () -> Hash[String, untyped]
|
17
|
+
|
18
|
+
# @rbs name: String
|
19
|
+
def attachment: (String name) -> String
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/generator/associations.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
class Associations
|
6
|
+
include Utils
|
7
|
+
|
8
|
+
attr_reader model: RbsActiverecord::Model
|
9
|
+
|
10
|
+
# @rbs model: RbsActiverecord::Model
|
11
|
+
def initialize: (RbsActiverecord::Model model) -> void
|
12
|
+
|
13
|
+
def generate: () -> String
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def has_many: () -> String
|
18
|
+
|
19
|
+
def has_one: () -> String
|
20
|
+
|
21
|
+
def belongs_to: () -> String
|
22
|
+
|
23
|
+
# @rbs assoc: untyped
|
24
|
+
def polymorphic_owner_types: (untyped assoc) -> String
|
25
|
+
|
26
|
+
def has_and_belongs_to_many: () -> String
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/generator/attributes.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
class Attributes
|
6
|
+
include Utils
|
7
|
+
|
8
|
+
attr_reader model: RbsActiverecord::Model
|
9
|
+
|
10
|
+
# @rbs model: RbsActiverecord::Model
|
11
|
+
def initialize: (RbsActiverecord::Model model) -> void
|
12
|
+
|
13
|
+
def generate: () -> String
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def column: (untyped col) -> String
|
18
|
+
|
19
|
+
def attributes: () -> Hash[String, untyped]
|
20
|
+
|
21
|
+
# @rbs name: String
|
22
|
+
# @rbs type: untyped
|
23
|
+
def attribute: (String name, untyped type) -> String
|
24
|
+
|
25
|
+
def alias_method: (untyped from, untyped to) -> String
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Generated from lib/rbs_activerecord/generator/delegated_type/instance_methods.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RbsActiverecord
|
4
|
+
class Generator
|
5
|
+
module DelegatedType
|
6
|
+
class InstanceMethods
|
7
|
+
include Utils
|
8
|
+
|
9
|
+
attr_reader model: RbsActiverecord::Model
|
10
|
+
|
11
|
+
attr_reader declarations: Array[Prism::CallNode]
|
12
|
+
|
13
|
+
# @rbs model: RbsActiverecord::Model
|
14
|
+
# @rbs declarations: Hash[String, Array[Prism::CallNode]]
|
15
|
+
def initialize: (RbsActiverecord::Model model, Hash[String, Array[Prism::CallNode]] declarations) -> void
|
16
|
+
|
17
|
+
def generate: () -> String
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def delegated_types: () -> Array[Prism::CallNode]
|
22
|
+
|
23
|
+
# @rbs node: Prism::CallNode
|
24
|
+
def delegated_type: (Prism::CallNode node) -> String
|
25
|
+
|
26
|
+
# @rbs klass_name: String
|
27
|
+
def primary_key_type_for: (String klass_name) -> String
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|