rbs_active_hash 1.1.1 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +5 -2
- data/Gemfile.lock +25 -23
- data/README.md +1 -1
- data/lib/rbs_active_hash/active_hash.rb +59 -0
- data/lib/rbs_active_hash/associations.rb +91 -0
- data/lib/rbs_active_hash/rake_task.rb +2 -1
- data/lib/rbs_active_hash/version.rb +1 -1
- data/lib/rbs_active_hash.rb +1 -0
- data/rbs_collection.lock.yaml +20 -16
- data/sig/rbs_active_hash/active_hash.rbs +4 -0
- data/sig/rbs_active_hash/associations.rbs +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae3f09f4556a17ac66ced6e72014731d08f17f4b959a82f57fcc7a49e238f025
|
4
|
+
data.tar.gz: 6b4896ee1ac32dd933d1fd2c2796d42290eaf4ccae47d13ecbf16c3d8f07d488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16296cd5be97a656942d1abc219ce1fc31a09ddc5dec6f69489d1f805c566c959a5a55d3911b8fb7f31f27242d4d339c4d97aa4d73de37073f1c813c1c7afd6d
|
7
|
+
data.tar.gz: 83b4d3996b2d3aad75ac53d1400666f4c9275f184e8c2af962e62dcc0cb887327493285947f4e8f75ddd1a14995a2f40f6b0e79d0758f72c84b67f854782b7ca
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -7,7 +7,11 @@ gemspec
|
|
7
7
|
|
8
8
|
gem "rake", "~> 13.0"
|
9
9
|
|
10
|
-
gem "rubocop", "~> 1.
|
10
|
+
gem "rubocop", "~> 1.56"
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem "activerecord"
|
14
|
+
end
|
11
15
|
|
12
16
|
group :development do
|
13
17
|
gem "rspec", require: false
|
@@ -18,6 +22,5 @@ end
|
|
18
22
|
|
19
23
|
# dependencies only for signature
|
20
24
|
group :signature do
|
21
|
-
gem "activerecord"
|
22
25
|
gem "railties"
|
23
26
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs_active_hash (1.
|
4
|
+
rbs_active_hash (1.2.1)
|
5
5
|
active_hash
|
6
6
|
rbs
|
7
7
|
rbs_rails
|
@@ -9,32 +9,33 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
|
-
actionpack (7.0.
|
13
|
-
actionview (= 7.0.
|
14
|
-
activesupport (= 7.0.
|
12
|
+
actionpack (7.0.7)
|
13
|
+
actionview (= 7.0.7)
|
14
|
+
activesupport (= 7.0.7)
|
15
15
|
rack (~> 2.0, >= 2.2.4)
|
16
16
|
rack-test (>= 0.6.3)
|
17
17
|
rails-dom-testing (~> 2.0)
|
18
18
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
19
|
-
actionview (7.0.
|
20
|
-
activesupport (= 7.0.
|
19
|
+
actionview (7.0.7)
|
20
|
+
activesupport (= 7.0.7)
|
21
21
|
builder (~> 3.1)
|
22
22
|
erubi (~> 1.4)
|
23
23
|
rails-dom-testing (~> 2.0)
|
24
24
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
25
25
|
active_hash (3.2.0)
|
26
26
|
activesupport (>= 5.0.0)
|
27
|
-
activemodel (7.0.
|
28
|
-
activesupport (= 7.0.
|
29
|
-
activerecord (7.0.
|
30
|
-
activemodel (= 7.0.
|
31
|
-
activesupport (= 7.0.
|
32
|
-
activesupport (7.0.
|
27
|
+
activemodel (7.0.7)
|
28
|
+
activesupport (= 7.0.7)
|
29
|
+
activerecord (7.0.7)
|
30
|
+
activemodel (= 7.0.7)
|
31
|
+
activesupport (= 7.0.7)
|
32
|
+
activesupport (7.0.7)
|
33
33
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
34
34
|
i18n (>= 1.6, < 2)
|
35
35
|
minitest (>= 5.1)
|
36
36
|
tzinfo (~> 2.0)
|
37
37
|
ast (2.4.2)
|
38
|
+
base64 (0.1.1)
|
38
39
|
builder (3.2.4)
|
39
40
|
coderay (1.1.3)
|
40
41
|
concurrent-ruby (1.2.2)
|
@@ -57,9 +58,9 @@ GEM
|
|
57
58
|
nokogiri (>= 1.12.0)
|
58
59
|
method_source (1.0.0)
|
59
60
|
minitest (5.19.0)
|
60
|
-
nokogiri (1.15.
|
61
|
+
nokogiri (1.15.4-x86_64-darwin)
|
61
62
|
racc (~> 1.4)
|
62
|
-
nokogiri (1.15.
|
63
|
+
nokogiri (1.15.4-x86_64-linux)
|
63
64
|
racc (~> 1.4)
|
64
65
|
parallel (1.23.0)
|
65
66
|
parser (3.2.2.3)
|
@@ -69,19 +70,19 @@ GEM
|
|
69
70
|
coderay (~> 1.1)
|
70
71
|
method_source (~> 1.0)
|
71
72
|
racc (1.7.1)
|
72
|
-
rack (2.2.
|
73
|
+
rack (2.2.8)
|
73
74
|
rack-test (2.1.0)
|
74
75
|
rack (>= 1.3)
|
75
|
-
rails-dom-testing (2.
|
76
|
+
rails-dom-testing (2.2.0)
|
76
77
|
activesupport (>= 5.0.0)
|
77
78
|
minitest
|
78
79
|
nokogiri (>= 1.6)
|
79
80
|
rails-html-sanitizer (1.6.0)
|
80
81
|
loofah (~> 2.21)
|
81
82
|
nokogiri (~> 1.14)
|
82
|
-
railties (7.0.
|
83
|
-
actionpack (= 7.0.
|
84
|
-
activesupport (= 7.0.
|
83
|
+
railties (7.0.7)
|
84
|
+
actionpack (= 7.0.7)
|
85
|
+
activesupport (= 7.0.7)
|
85
86
|
method_source
|
86
87
|
rake (>= 12.2)
|
87
88
|
thor (~> 1.0)
|
@@ -113,7 +114,8 @@ GEM
|
|
113
114
|
diff-lcs (>= 1.2.0, < 2.0)
|
114
115
|
rspec-support (~> 3.12.0)
|
115
116
|
rspec-support (3.12.0)
|
116
|
-
rubocop (1.
|
117
|
+
rubocop (1.56.0)
|
118
|
+
base64 (~> 0.1.1)
|
117
119
|
json (~> 2.3)
|
118
120
|
language_server-protocol (>= 3.17.0)
|
119
121
|
parallel (~> 1.10)
|
@@ -128,7 +130,7 @@ GEM
|
|
128
130
|
parser (>= 3.2.1.0)
|
129
131
|
ruby-progressbar (1.13.0)
|
130
132
|
securerandom (0.2.2)
|
131
|
-
steep (1.5.
|
133
|
+
steep (1.5.3)
|
132
134
|
activesupport (>= 5.1)
|
133
135
|
concurrent-ruby (>= 1.1.10)
|
134
136
|
csv (>= 3.0.9)
|
@@ -150,7 +152,7 @@ GEM
|
|
150
152
|
tzinfo (2.0.6)
|
151
153
|
concurrent-ruby (~> 1.0)
|
152
154
|
unicode-display_width (2.4.2)
|
153
|
-
zeitwerk (2.6.
|
155
|
+
zeitwerk (2.6.11)
|
154
156
|
|
155
157
|
PLATFORMS
|
156
158
|
x86_64-darwin-19
|
@@ -164,7 +166,7 @@ DEPENDENCIES
|
|
164
166
|
rbs_active_hash!
|
165
167
|
rspec
|
166
168
|
rspec-daemon
|
167
|
-
rubocop (~> 1.
|
169
|
+
rubocop (~> 1.56)
|
168
170
|
steep
|
169
171
|
|
170
172
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ rbs_active_hash is a generator for [ActiveHash](https://github.com/active-hash/a
|
|
7
7
|
Add a new entry to your Gemfile and run `bundle install`:
|
8
8
|
|
9
9
|
group :development do
|
10
|
-
gem 'rbs_active_hash'
|
10
|
+
gem 'rbs_active_hash', require: false
|
11
11
|
end
|
12
12
|
|
13
13
|
After the installation, please run rake task generator:
|
@@ -40,6 +40,7 @@ module RbsActiveHash
|
|
40
40
|
<<~RBS
|
41
41
|
#{header}
|
42
42
|
#{enum_decls}
|
43
|
+
#{association_decls}
|
43
44
|
#{method_decls}
|
44
45
|
#{footer}
|
45
46
|
RBS
|
@@ -97,6 +98,64 @@ module RbsActiveHash
|
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
101
|
+
def association_decls
|
102
|
+
return unless klass.ancestors.include? ::ActiveHash::Associations
|
103
|
+
|
104
|
+
path, = Object.const_source_location(klass_name)
|
105
|
+
return unless path
|
106
|
+
|
107
|
+
parser = Associations::Parser.new
|
108
|
+
parser.parse(IO.read(path.to_s), klass_name.split("::").map(&:to_sym))
|
109
|
+
|
110
|
+
<<~RBS
|
111
|
+
include ActiveHash::Associations
|
112
|
+
extend ActiveHash::Associations::Methods
|
113
|
+
|
114
|
+
#{has_many_decls(parser.has_many)}
|
115
|
+
#{has_one_decls(parser.has_one)}
|
116
|
+
#{belongs_to_decls(parser.belongs_to)}
|
117
|
+
RBS
|
118
|
+
end
|
119
|
+
|
120
|
+
def has_many_decls(definitions) # rubocop:disable Naming/PredicateName
|
121
|
+
definitions.map do |definition|
|
122
|
+
association_id, options = definition
|
123
|
+
klass = options.fetch(:class_name, association_id.to_s.classify).constantize
|
124
|
+
|
125
|
+
relation = if Object.const_defined?(:ActiveRecord) && klass.ancestors.include?(ActiveRecord::Base)
|
126
|
+
"#{klass.name}::ActiveRecord_Relation"
|
127
|
+
else
|
128
|
+
"Array[#{klass.name}]"
|
129
|
+
end
|
130
|
+
|
131
|
+
<<~RBS
|
132
|
+
def #{association_id}: () -> #{relation}
|
133
|
+
def #{association_id.to_s.underscore.singularize}_ids: () -> Array[Integer]
|
134
|
+
RBS
|
135
|
+
end.join("\n")
|
136
|
+
end
|
137
|
+
|
138
|
+
def has_one_decls(definitions) # rubocop:disable Naming/PredicateName
|
139
|
+
definitions.map do |definition|
|
140
|
+
association_id, options = definition
|
141
|
+
class_name = options.fetch(:class_name, association_id.to_s.classify).constantize
|
142
|
+
|
143
|
+
"def #{association_id}: () -> #{class_name}"
|
144
|
+
end.join("\n")
|
145
|
+
end
|
146
|
+
|
147
|
+
def belongs_to_decls(definitions)
|
148
|
+
definitions.map do |definition|
|
149
|
+
association_id, options = definition
|
150
|
+
class_name = options.fetch(:class_name, association_id.to_s.classify).constantize
|
151
|
+
|
152
|
+
<<~RBS
|
153
|
+
def #{association_id}: () -> #{class_name}
|
154
|
+
def #{association_id}=: (Integer) -> Integer
|
155
|
+
RBS
|
156
|
+
end.join("\n")
|
157
|
+
end
|
158
|
+
|
100
159
|
def method_decls
|
101
160
|
method_names.map do |method|
|
102
161
|
method_type = stringify_type(method_types.fetch(method, "untyped"))
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rbs"
|
4
|
+
|
5
|
+
module RbsActiveHash
|
6
|
+
module Associations
|
7
|
+
class AssociationDefinition < RBS::AST::Members::Include
|
8
|
+
end
|
9
|
+
|
10
|
+
class RB < RBS::Prototype::RB
|
11
|
+
def process(node, decls:, comments:, context:)
|
12
|
+
case node.type
|
13
|
+
when :FCALL, :VCALL
|
14
|
+
case node.children.first
|
15
|
+
when :has_many, :has_one, :belongs_to
|
16
|
+
decls << AssociationDefinition.new(
|
17
|
+
name: RBS::TypeName.new(name: node.children.first, namespace: RBS::Namespace.root),
|
18
|
+
args: node.children[1],
|
19
|
+
annotations: [],
|
20
|
+
location: nil,
|
21
|
+
comment: nil
|
22
|
+
)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
else
|
27
|
+
super
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class Parser
|
33
|
+
attr_reader :has_many, :has_one, :belongs_to
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
@has_many = []
|
37
|
+
@has_one = []
|
38
|
+
@belongs_to = []
|
39
|
+
end
|
40
|
+
|
41
|
+
def parse(string, target)
|
42
|
+
parser = RB.new
|
43
|
+
parser.parse(string)
|
44
|
+
parser.decls.each do |decl|
|
45
|
+
process(decl, target)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def process(node, target)
|
50
|
+
case node
|
51
|
+
when RBS::AST::Declarations::Module, RBS::AST::Declarations::Class
|
52
|
+
name = node.name.split
|
53
|
+
if target[...name.size] == name
|
54
|
+
node.members.each do |member|
|
55
|
+
process(member, target[name.size...].to_a)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
when AssociationDefinition
|
59
|
+
process_association_definition(node) if target.empty?
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def process_association_definition(node)
|
64
|
+
case node.name.name
|
65
|
+
when :has_many
|
66
|
+
association_id, args = node_to_literal(node.args)
|
67
|
+
@has_many << [association_id, args.to_h]
|
68
|
+
when :has_one
|
69
|
+
association_id, args = node_to_literal(node.args)
|
70
|
+
@has_one << [association_id, args.to_h]
|
71
|
+
when :belongs_to
|
72
|
+
association_id, args = node_to_literal(node.args)
|
73
|
+
@belongs_to << [association_id, args.to_h]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def node_to_literal(node)
|
78
|
+
case node.type
|
79
|
+
when :LIST
|
80
|
+
node.children[...-1].map { |child| node_to_literal(child) }
|
81
|
+
when :LIT, :STR
|
82
|
+
node.children.first
|
83
|
+
when :HASH
|
84
|
+
Hash[*node_to_literal(node.children.first)]
|
85
|
+
else
|
86
|
+
node
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
require "pathname"
|
4
4
|
require "rake"
|
5
5
|
require "rake/tasklib"
|
6
|
-
require "rbs_active_hash"
|
7
6
|
|
8
7
|
module RbsActiveHash
|
9
8
|
class RakeTask < Rake::TaskLib
|
@@ -40,6 +39,8 @@ module RbsActiveHash
|
|
40
39
|
def define_generate_task
|
41
40
|
desc "Generate RBS files for ActiveHash models"
|
42
41
|
task("#{name}:generate": :environment) do
|
42
|
+
require "rbs_active_hash" # load RbsActiveHash lazily
|
43
|
+
|
43
44
|
Rails.application.eager_load!
|
44
45
|
|
45
46
|
::ActiveHash::Base.descendants.each do |klass|
|
data/lib/rbs_active_hash.rb
CHANGED
data/rbs_collection.lock.yaml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
sources:
|
3
3
|
- type: git
|
4
4
|
name: ruby/gem_rbs_collection
|
5
|
-
revision:
|
5
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
6
6
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
7
7
|
repo_dir: gems
|
8
8
|
path: ".gem_rbs_collection"
|
@@ -16,7 +16,7 @@ gems:
|
|
16
16
|
source:
|
17
17
|
type: git
|
18
18
|
name: ruby/gem_rbs_collection
|
19
|
-
revision:
|
19
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
20
20
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
21
21
|
repo_dir: gems
|
22
22
|
- name: actionview
|
@@ -24,7 +24,7 @@ gems:
|
|
24
24
|
source:
|
25
25
|
type: git
|
26
26
|
name: ruby/gem_rbs_collection
|
27
|
-
revision:
|
27
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
28
28
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
29
29
|
repo_dir: gems
|
30
30
|
- name: active_hash
|
@@ -32,7 +32,7 @@ gems:
|
|
32
32
|
source:
|
33
33
|
type: git
|
34
34
|
name: ruby/gem_rbs_collection
|
35
|
-
revision:
|
35
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
36
36
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
37
37
|
repo_dir: gems
|
38
38
|
- name: activemodel
|
@@ -40,7 +40,7 @@ gems:
|
|
40
40
|
source:
|
41
41
|
type: git
|
42
42
|
name: ruby/gem_rbs_collection
|
43
|
-
revision:
|
43
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
44
44
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
45
45
|
repo_dir: gems
|
46
46
|
- name: activerecord
|
@@ -48,7 +48,7 @@ gems:
|
|
48
48
|
source:
|
49
49
|
type: git
|
50
50
|
name: ruby/gem_rbs_collection
|
51
|
-
revision:
|
51
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
52
52
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
53
53
|
repo_dir: gems
|
54
54
|
- name: activesupport
|
@@ -56,7 +56,7 @@ gems:
|
|
56
56
|
source:
|
57
57
|
type: git
|
58
58
|
name: ruby/gem_rbs_collection
|
59
|
-
revision:
|
59
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
60
60
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
61
61
|
repo_dir: gems
|
62
62
|
- name: ast
|
@@ -64,9 +64,13 @@ gems:
|
|
64
64
|
source:
|
65
65
|
type: git
|
66
66
|
name: ruby/gem_rbs_collection
|
67
|
-
revision:
|
67
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
68
68
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
69
69
|
repo_dir: gems
|
70
|
+
- name: base64
|
71
|
+
version: '0'
|
72
|
+
source:
|
73
|
+
type: stdlib
|
70
74
|
- name: cgi
|
71
75
|
version: '0'
|
72
76
|
source:
|
@@ -76,7 +80,7 @@ gems:
|
|
76
80
|
source:
|
77
81
|
type: git
|
78
82
|
name: ruby/gem_rbs_collection
|
79
|
-
revision:
|
83
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
80
84
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
81
85
|
repo_dir: gems
|
82
86
|
- name: date
|
@@ -88,7 +92,7 @@ gems:
|
|
88
92
|
source:
|
89
93
|
type: git
|
90
94
|
name: ruby/gem_rbs_collection
|
91
|
-
revision:
|
95
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
92
96
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
93
97
|
repo_dir: gems
|
94
98
|
- name: json
|
@@ -116,7 +120,7 @@ gems:
|
|
116
120
|
source:
|
117
121
|
type: git
|
118
122
|
name: ruby/gem_rbs_collection
|
119
|
-
revision:
|
123
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
120
124
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
121
125
|
repo_dir: gems
|
122
126
|
- name: optparse
|
@@ -128,7 +132,7 @@ gems:
|
|
128
132
|
source:
|
129
133
|
type: git
|
130
134
|
name: ruby/gem_rbs_collection
|
131
|
-
revision:
|
135
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
132
136
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
133
137
|
repo_dir: gems
|
134
138
|
- name: pathname
|
@@ -140,7 +144,7 @@ gems:
|
|
140
144
|
source:
|
141
145
|
type: git
|
142
146
|
name: ruby/gem_rbs_collection
|
143
|
-
revision:
|
147
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
144
148
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
145
149
|
repo_dir: gems
|
146
150
|
- name: rails-dom-testing
|
@@ -148,7 +152,7 @@ gems:
|
|
148
152
|
source:
|
149
153
|
type: git
|
150
154
|
name: ruby/gem_rbs_collection
|
151
|
-
revision:
|
155
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
152
156
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
153
157
|
repo_dir: gems
|
154
158
|
- name: railties
|
@@ -156,7 +160,7 @@ gems:
|
|
156
160
|
source:
|
157
161
|
type: git
|
158
162
|
name: ruby/gem_rbs_collection
|
159
|
-
revision:
|
163
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
160
164
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
161
165
|
repo_dir: gems
|
162
166
|
- name: rainbow
|
@@ -164,7 +168,7 @@ gems:
|
|
164
168
|
source:
|
165
169
|
type: git
|
166
170
|
name: ruby/gem_rbs_collection
|
167
|
-
revision:
|
171
|
+
revision: a4c633634493ab7ae73219022f56acff56ab69af
|
168
172
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
169
173
|
repo_dir: gems
|
170
174
|
- name: rbs
|
@@ -16,6 +16,10 @@ module RbsActiveHash
|
|
16
16
|
def header: () -> String
|
17
17
|
def enum_decls: () -> String?
|
18
18
|
def constants: () -> Array[String]
|
19
|
+
def association_decls: () -> String?
|
20
|
+
def has_many_decls: (Array[[Symbol, Hash[untyped, untyped]]]) -> String
|
21
|
+
def has_one_decls: (Array[[Symbol, Hash[untyped, untyped]]]) -> String
|
22
|
+
def belongs_to_decls: (Array[[Symbol, Hash[untyped, untyped]]]) -> String
|
19
23
|
def method_decls: () -> String
|
20
24
|
def method_names: () -> Array[Symbol]
|
21
25
|
def method_types: () -> Hash[Symbol, untyped]
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module RbsActiveHash
|
2
|
+
module Associations
|
3
|
+
class AssociationDefinition < RBS::AST::Members::Include
|
4
|
+
end
|
5
|
+
|
6
|
+
class RB < RBS::Prototype::RB
|
7
|
+
end
|
8
|
+
|
9
|
+
class Parser
|
10
|
+
attr_reader has_many: Array[[Symbol, Hash[untyped, untyped]]]
|
11
|
+
attr_reader has_one: Array[[Symbol, Hash[untyped, untyped]]]
|
12
|
+
attr_reader belongs_to: Array[[Symbol, Hash[untyped, untyped]]]
|
13
|
+
|
14
|
+
def initialize: () -> void
|
15
|
+
def parse: (String string, Array[Symbol] target) -> void
|
16
|
+
def process: (RBS::AST::Declarations::t | RBS::AST::Members::t node, Array[Symbol] target) -> void
|
17
|
+
def process_association_definition: (AssociationDefinition node) -> void
|
18
|
+
def node_to_literal: (untyped node) -> untyped
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_active_hash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi KOMIYA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-08-
|
11
|
+
date: 2023-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_hash
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/generators/rbs_active_hash/install_generator.rb
|
73
73
|
- lib/rbs_active_hash.rb
|
74
74
|
- lib/rbs_active_hash/active_hash.rb
|
75
|
+
- lib/rbs_active_hash/associations.rb
|
75
76
|
- lib/rbs_active_hash/rake_task.rb
|
76
77
|
- lib/rbs_active_hash/version.rb
|
77
78
|
- rbs_active_hash.gemspec
|
@@ -80,6 +81,7 @@ files:
|
|
80
81
|
- sig/generators/rbs_active_hash/install_generator.rbs
|
81
82
|
- sig/rbs_active_hash.rbs
|
82
83
|
- sig/rbs_active_hash/active_hash.rbs
|
84
|
+
- sig/rbs_active_hash/associations.rbs
|
83
85
|
- sig/rbs_active_hash/rake_task.rbs
|
84
86
|
- sig/shims/rake.rbs
|
85
87
|
- sig/shims/thor.rbs
|