rbs_active_hash 1.4.1 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50b3e286a30ef5111438bd8167f51f42b72a58af5fca5cd6351808c3e08a45ca
4
- data.tar.gz: '009908add2d81dac55c52a572c3ceafcef090ef05778487985645062313ac40c'
3
+ metadata.gz: c72503e55cdd29dfb738e4cf1154b5673de210dabcb9c987770020f6421b37fb
4
+ data.tar.gz: 3f8b643bf0c6febc8d74b9139dc7db95a40feba1976c4213634ab4ba3e2c53cb
5
5
  SHA512:
6
- metadata.gz: 96db691ce7b799010753a0bb711f952d0dac12c352842548c0a2f5b9a1ec41f2c263b00f5cec4849df261c8e19b2343afe922981d66abe0ee11b1acb3b019e6e
7
- data.tar.gz: a383ca9ab7058d7fd2ab8beea9203f707e5ab91e74f713508f5912d7293b2289f84604410658e05c28822ff6c53a31a78c6386fe426fff3c861988357fbfe7b6
6
+ metadata.gz: 4ec043fdcc777e755c87b739a432e01769520f7eff3d9137dbe054c260c632def1bd5aa13b5cd81a29f95f960408caa6231f6db0ea77c430f92d63260ed90342
7
+ data.tar.gz: 6892cf7036260f002def3aeaf016529b40f401ec78e03e539ef5d61a7ad56a12d89c77901ba3b08f04e8cf33cb5c93fffbf7bddb248aaa2a5cfe891850ebe87f
data/.rubocop.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.7
2
+ TargetRubyVersion: 3.2
3
+ NewCops: enable
4
+
5
+ plugins:
6
+ - rubocop-rake
7
+ - rubocop-rspec
3
8
 
4
9
  Style/Documentation:
5
10
  Enabled: false
@@ -12,6 +17,9 @@ Style/StringLiteralsInInterpolation:
12
17
  Enabled: true
13
18
  EnforcedStyle: double_quotes
14
19
 
20
+ Layout/LeadingCommentSpace:
21
+ AllowRBSInlineAnnotation: true
22
+
15
23
  Layout/LineLength:
16
24
  Max: 120
17
25
 
@@ -33,3 +41,9 @@ Metrics/MethodLength:
33
41
 
34
42
  Metrics/PerceivedComplexity:
35
43
  Max: 10
44
+
45
+ RSpec/NamedSubject:
46
+ Enabled: false
47
+
48
+ RSpec/MultipleExpectations:
49
+ Max: 10
@@ -2,8 +2,22 @@
2
2
  "[ruby]": {
3
3
  "editor.defaultFormatter": "Shopify.ruby-lsp"
4
4
  },
5
- "rbs-helper.signature-directory": "sig",
6
5
  "cSpell.words": [
7
- "Cyclomatic"
8
- ]
6
+ "activerecord",
7
+ "bindir",
8
+ "boolish",
9
+ "Colour",
10
+ "Cyclomatic",
11
+ "FCALL",
12
+ "klass",
13
+ "KOMIYA",
14
+ "raketask",
15
+ "rubocop",
16
+ "rubygems",
17
+ "Takeshi",
18
+ "tk0miya",
19
+ "VCALL"
20
+ ],
21
+ "rbs-helper.rbs-inline-signature-directory": "sig/",
22
+ "rbs-helper.rbs-inline-on-save": true
9
23
  }
data/Gemfile CHANGED
@@ -5,9 +5,11 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in rbs_active_hash.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem "rake", "~> 13.3"
9
9
 
10
- gem "rubocop", "~> 1.57"
10
+ gem "rubocop", "~> 1.81"
11
+ gem "rubocop-rake"
12
+ gem "rubocop-rspec"
11
13
 
12
14
  group :test do
13
15
  gem "activerecord"
@@ -17,6 +19,7 @@ group :development do
17
19
  gem "rspec", require: false
18
20
  gem "rspec-daemon", require: false
19
21
 
22
+ gem "rbs-inline", require: false
20
23
  gem "steep"
21
24
  end
22
25
 
data/Gemfile.lock CHANGED
@@ -1,169 +1,227 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_active_hash (1.4.1)
4
+ rbs_active_hash (1.6.0)
5
5
  active_hash
6
6
  rbs
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actionpack (7.0.7.2)
12
- actionview (= 7.0.7.2)
13
- activesupport (= 7.0.7.2)
14
- rack (~> 2.0, >= 2.2.4)
11
+ actionpack (7.2.2.2)
12
+ actionview (= 7.2.2.2)
13
+ activesupport (= 7.2.2.2)
14
+ nokogiri (>= 1.8.5)
15
+ racc
16
+ rack (>= 2.2.4, < 3.2)
17
+ rack-session (>= 1.0.1)
15
18
  rack-test (>= 0.6.3)
16
- rails-dom-testing (~> 2.0)
17
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
18
- actionview (7.0.7.2)
19
- activesupport (= 7.0.7.2)
19
+ rails-dom-testing (~> 2.2)
20
+ rails-html-sanitizer (~> 1.6)
21
+ useragent (~> 0.16)
22
+ actionview (7.2.2.2)
23
+ activesupport (= 7.2.2.2)
20
24
  builder (~> 3.1)
21
- erubi (~> 1.4)
22
- rails-dom-testing (~> 2.0)
23
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
24
- active_hash (3.2.1)
25
- activesupport (>= 5.0.0)
26
- activemodel (7.0.7.2)
27
- activesupport (= 7.0.7.2)
28
- activerecord (7.0.7.2)
29
- activemodel (= 7.0.7.2)
30
- activesupport (= 7.0.7.2)
31
- activesupport (7.0.7.2)
32
- concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ erubi (~> 1.11)
26
+ rails-dom-testing (~> 2.2)
27
+ rails-html-sanitizer (~> 1.6)
28
+ active_hash (4.0.0)
29
+ activesupport (>= 6.1.0)
30
+ activemodel (7.2.2.2)
31
+ activesupport (= 7.2.2.2)
32
+ activerecord (7.2.2.2)
33
+ activemodel (= 7.2.2.2)
34
+ activesupport (= 7.2.2.2)
35
+ timeout (>= 0.4.0)
36
+ activesupport (7.2.2.2)
37
+ base64
38
+ benchmark (>= 0.3)
39
+ bigdecimal
40
+ concurrent-ruby (~> 1.0, >= 1.3.1)
41
+ connection_pool (>= 2.2.5)
42
+ drb
33
43
  i18n (>= 1.6, < 2)
44
+ logger (>= 1.4.2)
34
45
  minitest (>= 5.1)
35
- tzinfo (~> 2.0)
36
- ast (2.4.2)
37
- base64 (0.1.1)
38
- builder (3.2.4)
39
- coderay (1.1.3)
40
- concurrent-ruby (1.2.2)
46
+ securerandom (>= 0.3)
47
+ tzinfo (~> 2.0, >= 2.0.5)
48
+ ast (2.4.3)
49
+ base64 (0.3.0)
50
+ benchmark (0.4.1)
51
+ bigdecimal (3.2.2)
52
+ builder (3.3.0)
53
+ concurrent-ruby (1.3.5)
54
+ connection_pool (2.5.3)
41
55
  crass (1.0.6)
42
- csv (3.2.7)
43
- diff-lcs (1.5.0)
44
- erubi (1.12.0)
45
- ffi (1.15.5)
46
- fileutils (1.7.1)
47
- i18n (1.14.1)
56
+ csv (3.3.3)
57
+ date (3.4.1)
58
+ diff-lcs (1.6.2)
59
+ drb (2.2.3)
60
+ erubi (1.13.0)
61
+ ffi (1.17.1-arm64-darwin)
62
+ ffi (1.17.1-x86_64-darwin)
63
+ ffi (1.17.1-x86_64-linux-gnu)
64
+ fileutils (1.7.3)
65
+ i18n (1.14.7)
48
66
  concurrent-ruby (~> 1.0)
49
- json (2.6.3)
50
- language_server-protocol (3.17.0.3)
51
- listen (3.8.0)
67
+ io-console (0.8.0)
68
+ irb (1.14.2)
69
+ rdoc (>= 4.0.0)
70
+ reline (>= 0.4.2)
71
+ json (2.15.0)
72
+ language_server-protocol (3.17.0.5)
73
+ lint_roller (1.1.0)
74
+ listen (3.9.0)
52
75
  rb-fsevent (~> 0.10, >= 0.10.3)
53
76
  rb-inotify (~> 0.9, >= 0.9.10)
54
- logger (1.5.3)
55
- loofah (2.21.3)
77
+ logger (1.7.0)
78
+ loofah (2.23.1)
56
79
  crass (~> 1.0.2)
57
80
  nokogiri (>= 1.12.0)
58
- method_source (1.0.0)
59
- minitest (5.20.0)
60
- nokogiri (1.15.4-x86_64-darwin)
81
+ minitest (5.25.5)
82
+ mutex_m (0.3.0)
83
+ nokogiri (1.18.9-arm64-darwin)
84
+ racc (~> 1.4)
85
+ nokogiri (1.18.9-x86_64-darwin)
61
86
  racc (~> 1.4)
62
- nokogiri (1.15.4-x86_64-linux)
87
+ nokogiri (1.18.9-x86_64-linux-gnu)
63
88
  racc (~> 1.4)
64
- parallel (1.23.0)
65
- parser (3.2.2.4)
89
+ parallel (1.27.0)
90
+ parser (3.3.9.0)
66
91
  ast (~> 2.4.1)
67
92
  racc
68
- pry (0.14.2)
69
- coderay (~> 1.1)
70
- method_source (~> 1.0)
71
- racc (1.7.1)
72
- rack (2.2.8)
93
+ prism (1.5.1)
94
+ psych (5.2.1)
95
+ date
96
+ stringio
97
+ racc (1.8.1)
98
+ rack (3.1.16)
99
+ rack-session (2.1.1)
100
+ base64 (>= 0.1.0)
101
+ rack (>= 3.0.0)
73
102
  rack-test (2.1.0)
74
103
  rack (>= 1.3)
104
+ rackup (2.2.1)
105
+ rack (>= 3)
75
106
  rails-dom-testing (2.2.0)
76
107
  activesupport (>= 5.0.0)
77
108
  minitest
78
109
  nokogiri (>= 1.6)
79
- rails-html-sanitizer (1.6.0)
110
+ rails-html-sanitizer (1.6.2)
80
111
  loofah (~> 2.21)
81
- nokogiri (~> 1.14)
82
- railties (7.0.7.2)
83
- actionpack (= 7.0.7.2)
84
- activesupport (= 7.0.7.2)
85
- method_source
112
+ nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
113
+ railties (7.2.2.2)
114
+ actionpack (= 7.2.2.2)
115
+ activesupport (= 7.2.2.2)
116
+ irb (~> 1.13)
117
+ rackup (>= 1.0.0)
86
118
  rake (>= 12.2)
87
- thor (~> 1.0)
88
- zeitwerk (~> 2.5)
119
+ thor (~> 1.0, >= 1.2.2)
120
+ zeitwerk (~> 2.6)
89
121
  rainbow (3.1.1)
90
- rake (13.0.6)
122
+ rake (13.3.0)
91
123
  rb-fsevent (0.11.2)
92
- rb-inotify (0.10.1)
124
+ rb-inotify (0.11.1)
93
125
  ffi (~> 1.0)
94
- rbs (3.1.3)
95
- regexp_parser (2.8.2)
96
- rexml (3.2.6)
97
- rspec (3.12.0)
98
- rspec-core (~> 3.12.0)
99
- rspec-expectations (~> 3.12.0)
100
- rspec-mocks (~> 3.12.0)
101
- rspec-core (3.12.2)
102
- rspec-support (~> 3.12.0)
103
- rspec-daemon (0.1.5)
104
- pry
126
+ rbs (3.9.5)
127
+ logger
128
+ rbs-inline (0.12.0)
129
+ prism (>= 0.29)
130
+ rbs (>= 3.8.0)
131
+ rdoc (6.9.0)
132
+ psych (>= 4.0.0)
133
+ regexp_parser (2.11.3)
134
+ reline (0.5.12)
135
+ io-console (~> 0.5)
136
+ rspec (3.13.1)
137
+ rspec-core (~> 3.13.0)
138
+ rspec-expectations (~> 3.13.0)
139
+ rspec-mocks (~> 3.13.0)
140
+ rspec-core (3.13.4)
141
+ rspec-support (~> 3.13.0)
142
+ rspec-daemon (1.1.1)
105
143
  rspec
106
- rspec-expectations (3.12.3)
144
+ rspec-expectations (3.13.5)
107
145
  diff-lcs (>= 1.2.0, < 2.0)
108
- rspec-support (~> 3.12.0)
109
- rspec-mocks (3.12.5)
146
+ rspec-support (~> 3.13.0)
147
+ rspec-mocks (3.13.5)
110
148
  diff-lcs (>= 1.2.0, < 2.0)
111
- rspec-support (~> 3.12.0)
112
- rspec-support (3.12.0)
113
- rubocop (1.57.1)
114
- base64 (~> 0.1.1)
149
+ rspec-support (~> 3.13.0)
150
+ rspec-support (3.13.4)
151
+ rubocop (1.81.1)
115
152
  json (~> 2.3)
116
- language_server-protocol (>= 3.17.0)
153
+ language_server-protocol (~> 3.17.0.2)
154
+ lint_roller (~> 1.1.0)
117
155
  parallel (~> 1.10)
118
- parser (>= 3.2.2.4)
156
+ parser (>= 3.3.0.2)
119
157
  rainbow (>= 2.2.2, < 4.0)
120
- regexp_parser (>= 1.8, < 3.0)
121
- rexml (>= 3.2.5, < 4.0)
122
- rubocop-ast (>= 1.28.1, < 2.0)
158
+ regexp_parser (>= 2.9.3, < 3.0)
159
+ rubocop-ast (>= 1.47.1, < 2.0)
123
160
  ruby-progressbar (~> 1.7)
124
- unicode-display_width (>= 2.4.0, < 3.0)
125
- rubocop-ast (1.29.0)
126
- parser (>= 3.2.1.0)
161
+ unicode-display_width (>= 2.4.0, < 4.0)
162
+ rubocop-ast (1.47.1)
163
+ parser (>= 3.3.7.2)
164
+ prism (~> 1.4)
165
+ rubocop-rake (0.7.1)
166
+ lint_roller (~> 1.1)
167
+ rubocop (>= 1.72.1)
168
+ rubocop-rspec (3.7.0)
169
+ lint_roller (~> 1.1)
170
+ rubocop (~> 1.72, >= 1.72.1)
127
171
  ruby-progressbar (1.13.0)
128
- securerandom (0.2.2)
129
- steep (1.5.3)
172
+ securerandom (0.4.1)
173
+ steep (1.10.0)
130
174
  activesupport (>= 5.1)
131
175
  concurrent-ruby (>= 1.1.10)
132
176
  csv (>= 3.0.9)
133
177
  fileutils (>= 1.1.0)
134
178
  json (>= 2.1.0)
135
- language_server-protocol (>= 3.15, < 4.0)
179
+ language_server-protocol (>= 3.17.0.4, < 4.0)
136
180
  listen (~> 3.0)
137
181
  logger (>= 1.3.0)
182
+ mutex_m (>= 0.3.0)
138
183
  parser (>= 3.1)
139
184
  rainbow (>= 2.2.2, < 4.0)
140
- rbs (>= 3.1.0)
185
+ rbs (~> 3.9)
141
186
  securerandom (>= 0.1)
142
187
  strscan (>= 1.0.0)
143
- terminal-table (>= 2, < 4)
144
- strscan (3.0.6)
145
- terminal-table (3.0.2)
146
- unicode-display_width (>= 1.1.1, < 3)
147
- thor (1.2.2)
188
+ terminal-table (>= 2, < 5)
189
+ uri (>= 0.12.0)
190
+ stringio (3.1.2)
191
+ strscan (3.1.2)
192
+ terminal-table (4.0.0)
193
+ unicode-display_width (>= 1.1.1, < 4)
194
+ thor (1.3.2)
195
+ timeout (0.4.3)
148
196
  tzinfo (2.0.6)
149
197
  concurrent-ruby (~> 1.0)
150
- unicode-display_width (2.5.0)
151
- zeitwerk (2.6.11)
198
+ unicode-display_width (3.2.0)
199
+ unicode-emoji (~> 4.1)
200
+ unicode-emoji (4.1.0)
201
+ uri (1.0.3)
202
+ useragent (0.16.11)
203
+ zeitwerk (2.6.18)
152
204
 
153
205
  PLATFORMS
206
+ arm64-darwin-24
154
207
  x86_64-darwin-19
155
208
  x86_64-darwin-21
209
+ x86_64-darwin-23
210
+ x86_64-darwin-24
156
211
  x86_64-linux
157
212
 
158
213
  DEPENDENCIES
159
214
  activerecord
160
215
  railties
161
- rake (~> 13.0)
216
+ rake (~> 13.3)
217
+ rbs-inline
162
218
  rbs_active_hash!
163
219
  rspec
164
220
  rspec-daemon
165
- rubocop (~> 1.57)
221
+ rubocop (~> 1.81)
222
+ rubocop-rake
223
+ rubocop-rspec
166
224
  steep
167
225
 
168
226
  BUNDLED WITH
169
- 2.4.4
227
+ 2.3.27
data/Steepfile CHANGED
@@ -8,4 +8,5 @@ target :lib do
8
8
  check "lib"
9
9
 
10
10
  configure_code_diagnostics(D::Ruby.lenient)
11
+ implicitly_returns_nil!
11
12
  end
@@ -4,7 +4,7 @@ require "rails"
4
4
 
5
5
  module RbsActiveHash
6
6
  class InstallGenerator < Rails::Generators::Base
7
- def create_raketask
7
+ def create_raketask #: void
8
8
  create_file "lib/tasks/rbs_active_hash.rake", <<~RUBY
9
9
  # frozen_string_literal: true
10
10
 
@@ -12,6 +12,7 @@ module RbsActiveHash
12
12
  end
13
13
 
14
14
  class RB < RBS::Prototype::RB
15
+ # @rbs override
15
16
  def process(node, decls:, comments:, context:)
16
17
  case node.type
17
18
  when :FCALL, :VCALL
@@ -42,16 +43,21 @@ module RbsActiveHash
42
43
  end
43
44
 
44
45
  class Parser
45
- attr_reader :has_many, :has_one, :belongs_to, :scopes
46
+ attr_reader :has_many #: Array[[Symbol, Hash[untyped, untyped]]]
47
+ attr_reader :has_one #: Array[[Symbol, Hash[untyped, untyped]]]
48
+ attr_reader :belongs_to #: Array[[Symbol, Hash[untyped, untyped]]]
49
+ attr_reader :scopes #: Array[[Symbol, Hash[untyped, untyped]]]
46
50
 
47
- def initialize
51
+ def initialize #: void
48
52
  @has_many = []
49
53
  @has_one = []
50
54
  @belongs_to = []
51
55
  @scopes = []
52
56
  end
53
57
 
54
- def parse(string, target)
58
+ # @rbs string: String
59
+ # @rbs target: Array[Symbol]
60
+ def parse(string, target) #: void
55
61
  parser = RB.new
56
62
  parser.parse(string)
57
63
  parser.decls.each do |decl|
@@ -59,7 +65,9 @@ module RbsActiveHash
59
65
  end
60
66
  end
61
67
 
62
- def process(node, target)
68
+ # @rbs node: RBS::AST::Declarations::t | RBS::AST::Members::t
69
+ # @rbs target: Array[Symbol]
70
+ def process(node, target) #: void
63
71
  case node
64
72
  when RBS::AST::Declarations::Module, RBS::AST::Declarations::Class
65
73
  name = node.name.split
@@ -75,7 +83,8 @@ module RbsActiveHash
75
83
  end
76
84
  end
77
85
 
78
- def process_association_definition(node)
86
+ # @rbs node: AssociationDefinition
87
+ def process_association_definition(node) #: void
79
88
  case node.name.name
80
89
  when :has_many
81
90
  association_id, args = node_to_literal(node.args)
@@ -89,21 +98,23 @@ module RbsActiveHash
89
98
  end
90
99
  end
91
100
 
92
- def process_scope_definition(node)
101
+ # @rbs node: ScopeDefinition
102
+ def process_scope_definition(node) #: void
93
103
  scope_id, args = node_to_literal(node.args)
94
- @scopes << [scope_id, args.to_h]
104
+ @scopes << [scope_id, args]
95
105
  end
96
106
 
97
- def node_to_literal(node)
107
+ # @rbs node: untyped
108
+ def node_to_literal(node) #: untyped
98
109
  case node.type
99
110
  when :LIST
100
111
  node.children[...-1].map { |child| node_to_literal(child) }
101
- when :LIT, :STR
112
+ when :LIT, :STR, :SYM
102
113
  node.children.first
103
114
  when :HASH
104
115
  Hash[*node_to_literal(node.children.first)]
105
116
  when :LAMBDA
106
- {} # Convert to empty hash because rbs_active_hash does not process lambda
117
+ node.children.first.children.first # Convert to the list of argument names
107
118
  else
108
119
  node
109
120
  end