rbs_activesupport 1.6.0 → 1.7.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: 438e19cbb21787f29c6c4d2f2793aa07a2423c6fd42ee9540763d232df0ace2b
4
- data.tar.gz: 6af95ed3168cbd3ae7b8ef97365b36d6b3c2a03cc844b0303395cb4f0716ff98
3
+ metadata.gz: 19e6a457737b5dee37126028620021e9dd1254163d07aa7782a13866c28d1495
4
+ data.tar.gz: 8328c3624346731e91e7eb2b3e6ecb11724688986a87b793ee8803d9112c8448
5
5
  SHA512:
6
- metadata.gz: e447d750370fd50cf83d448a5356a520e5f6de2b4ef15bc1bfcf6cf449002052e5b9b37fac7986a07cdb130d5e760adf957f1d0f64e2128493618992f2d96485
7
- data.tar.gz: 7dcd6171ed89a66d898732e8e3b27401021fad63a5ad10e7a4f3fcf312e411a11e934fe338e65c242949af9f41df36fec7b37f1544f37558cecd5b3466481be4
6
+ metadata.gz: 27ac5ddadd39ff5aaf643931505f86b947555fa17a719a293926a320deb670c800e903de433352ed4866adc66f8e464f2bfe883931158852670ae2df4413a8e5
7
+ data.tar.gz: acefab7cbee5e46cdf80108a30f762f71c73a90b888bf465cd0b596968b80501335e261f92fc98ab4caaa6b5bf6f9b88ae3a09eceec1f9f4a899eeb1b96910f9
data/.rubocop.yml CHANGED
@@ -1,5 +1,10 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 3.2
3
+ NewCops: enable
4
+
5
+ plugins:
6
+ - rubocop-rake
7
+ - rubocop-rspec
3
8
 
4
9
  Layout/LeadingCommentSpace:
5
10
  Enabled: false
@@ -25,6 +30,21 @@ Metrics/MethodLength:
25
30
  Exclude:
26
31
  - "lib/rbs_activesupport/ast.rb"
27
32
 
33
+ RSpec/ExampleLength:
34
+ Max: 30
35
+
36
+ RSpec/MultipleExpectations:
37
+ Enabled: false
38
+
39
+ RSpec/MultipleMemoizedHelpers:
40
+ Max: 10
41
+
42
+ RSpec/NamedSubject:
43
+ Enabled: false
44
+
45
+ RSpec/NestedGroups:
46
+ Max: 5
47
+
28
48
  Style/AccessorGrouping:
29
49
  Enabled: false
30
50
 
@@ -34,6 +54,9 @@ Style/CommentedKeyword:
34
54
  Style/Documentation:
35
55
  Enabled: false
36
56
 
57
+ Style/HashSyntax:
58
+ EnforcedShorthandSyntax: always
59
+
37
60
  Style/StringLiterals:
38
61
  EnforcedStyle: double_quotes
39
62
 
@@ -8,6 +8,7 @@
8
8
  "Cyclomatic",
9
9
  "DEFN",
10
10
  "FCALL",
11
+ "Includee",
11
12
  "ivar",
12
13
  "KOMIYA",
13
14
  "mattr",
@@ -17,6 +18,7 @@
17
18
  "raketask",
18
19
  "readlines",
19
20
  "rmtree",
21
+ "rubocop",
20
22
  "Takeshi",
21
23
  "tasklib",
22
24
  "tk0miya",
@@ -33,7 +33,8 @@ module RbsActivesupport
33
33
  # @rbs namespace: RBS::Namespace
34
34
  # @rbs method_calls: Array[Parser::MethodCall]
35
35
  # @rbs context: RBS::Namespace?
36
- def build_method_calls(namespace, method_calls, context) #: Array[t]
36
+ # @rbs options: Hash[Symbol, untyped]
37
+ def build_method_calls(namespace, method_calls, context, options = {}) #: Array[t]
37
38
  method_calls.flat_map do |method_call|
38
39
  case method_call.name
39
40
  when :class_attribute
@@ -43,7 +44,9 @@ module RbsActivesupport
43
44
  when :cattr_accessor, :mattr_accessor, :cattr_reader, :mattr_reader, :cattr_writer, :mattr_writer
44
45
  build_attribute_accessor(method_call)
45
46
  when :include
46
- build_include(namespace, method_call, context)
47
+ # implicit include is an "include" internally (e.g. include call in the included block)
48
+ implicit = options.fetch(:implicit_include, false)
49
+ build_include(namespace, method_call, context, implicit:)
47
50
  end
48
51
  rescue StandardError => e
49
52
  puts "ERROR: #{namespace}:#{method_call.name}: Failed to build method calls: #{e}"
@@ -90,7 +93,8 @@ module RbsActivesupport
90
93
  # @rbs namespace: RBS::Namespace
91
94
  # @rbs method_call: Parser::MethodCall
92
95
  # @rbs context: RBS::Namespace?
93
- def build_include(namespace, method_call, context) #: Array[t] # rubocop:disable Metrics/AbcSize
96
+ # @rbs implicit: bool
97
+ def build_include(namespace, method_call, context, implicit:) #: Array[t] # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
94
98
  module_paths = eval_include_args(method_call.args)
95
99
  module_paths.delete_if do |module_path|
96
100
  unless module_path.is_a?(RBS::Namespace)
@@ -99,7 +103,7 @@ module RbsActivesupport
99
103
  end
100
104
  end
101
105
  module_paths.filter_map do |module_path|
102
- include = Include.new(context || namespace, module_path, { private: method_call.private? })
106
+ include = Include.new(context || namespace, module_path, { private: method_call.private?, implicit: })
103
107
 
104
108
  if include.module_name
105
109
  next if included_modules.include?(include.module_name)
@@ -107,9 +111,12 @@ module RbsActivesupport
107
111
  included_modules << include.module_name
108
112
  end
109
113
 
110
- ([include] +
111
- build_method_calls(namespace, include.nested_includes, include.module_name) +
112
- build_method_calls(namespace, include.method_calls_in_included_block, include.module_name))
114
+ calls = [] #: Array[t]
115
+ calls << include if include.implicit? || (include.concern? && include.classmethods?)
116
+ calls.concat(build_method_calls(namespace, include.nested_includes, include.module_name))
117
+ calls.concat(build_method_calls(namespace, include.method_calls_in_included_block, include.module_name,
118
+ { implicit_include: true }))
119
+ calls
113
120
  end.flatten
114
121
  end
115
122
 
@@ -164,14 +171,10 @@ module RbsActivesupport
164
171
  # @rbs decl: Include
165
172
  def render_include(decl) #: String
166
173
  module_name = decl.module_name || decl.module_path
167
- if decl.concern? && decl.classmethods?
168
- <<~RBS
169
- include #{module_name.to_s.delete_suffix("::")}
170
- extend #{module_name}ClassMethods
171
- RBS
172
- else
173
- "include #{module_name.to_s.delete_suffix("::")}"
174
- end
174
+ mods = []
175
+ mods << "include #{module_name.to_s.delete_suffix("::")}" if decl.implicit?
176
+ mods << "extend #{module_name}ClassMethods" if decl.concern? && decl.classmethods?
177
+ mods.join("\n")
175
178
  end
176
179
 
177
180
  # @rbs namespace: RBS::Namespace
@@ -51,6 +51,14 @@ module RbsActivesupport
51
51
  self.module&.const_defined?(:ClassMethods)
52
52
  end
53
53
 
54
+ def explicit? #: bool
55
+ !implicit?
56
+ end
57
+
58
+ def implicit? #: bool
59
+ options.fetch(:implicit, false)
60
+ end
61
+
54
62
  def nested_includes #: Array[Parser::MethodCall]
55
63
  return [] unless module_name
56
64
  return [] unless parser
@@ -77,7 +85,7 @@ module RbsActivesupport
77
85
 
78
86
  private
79
87
 
80
- # @rbs @parser: Parser
88
+ # @rbs @parser: Parser?
81
89
 
82
90
  # @rbs %a{pure}
83
91
  def parser #: Parser?
@@ -85,10 +93,11 @@ module RbsActivesupport
85
93
 
86
94
  @parser ||= begin
87
95
  path, = Object.const_source_location(module_name.to_s.delete_suffix("::")) #: String?
88
- return nil unless path && File.exist?(path)
89
96
 
90
- Parser.new(parse_included_block: true).tap do |parser|
91
- parser.parse(File.read(path))
97
+ if path && File.exist?(path)
98
+ Parser.new(parse_included_block: true).tap do |parser|
99
+ parser.parse(File.read(path))
100
+ end
92
101
  end
93
102
  end
94
103
  end
@@ -13,7 +13,7 @@ module RbsActivesupport
13
13
 
14
14
  # @rbs name: Symbol
15
15
  # @rbs &block: ?(self) -> void
16
- def initialize(name = :'rbs:activesupport', &block) #: void
16
+ def initialize(name = :"rbs:activesupport", &block) #: void
17
17
  super()
18
18
 
19
19
  @name = name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsActivesupport
4
- VERSION = "1.6.0"
4
+ VERSION = "1.7.0"
5
5
  end
@@ -6,7 +6,7 @@ gems:
6
6
  source:
7
7
  type: git
8
8
  name: ruby/gem_rbs_collection
9
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
9
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
10
10
  remote: https://github.com/ruby/gem_rbs_collection.git
11
11
  repo_dir: gems
12
12
  - name: actionview
@@ -14,7 +14,7 @@ gems:
14
14
  source:
15
15
  type: git
16
16
  name: ruby/gem_rbs_collection
17
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
17
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
18
18
  remote: https://github.com/ruby/gem_rbs_collection.git
19
19
  repo_dir: gems
20
20
  - name: activesupport
@@ -22,7 +22,7 @@ gems:
22
22
  source:
23
23
  type: git
24
24
  name: ruby/gem_rbs_collection
25
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
25
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
26
26
  remote: https://github.com/ruby/gem_rbs_collection.git
27
27
  repo_dir: gems
28
28
  - name: ast
@@ -30,7 +30,7 @@ gems:
30
30
  source:
31
31
  type: git
32
32
  name: ruby/gem_rbs_collection
33
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
33
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
34
34
  remote: https://github.com/ruby/gem_rbs_collection.git
35
35
  repo_dir: gems
36
36
  - name: base64
@@ -38,7 +38,7 @@ gems:
38
38
  source:
39
39
  type: git
40
40
  name: ruby/gem_rbs_collection
41
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
41
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
42
42
  remote: https://github.com/ruby/gem_rbs_collection.git
43
43
  repo_dir: gems
44
44
  - name: benchmark
@@ -50,7 +50,7 @@ gems:
50
50
  source:
51
51
  type: git
52
52
  name: ruby/gem_rbs_collection
53
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
53
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
54
54
  remote: https://github.com/ruby/gem_rbs_collection.git
55
55
  repo_dir: gems
56
56
  - name: cgi
@@ -62,7 +62,7 @@ gems:
62
62
  source:
63
63
  type: git
64
64
  name: ruby/gem_rbs_collection
65
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
65
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
66
66
  remote: https://github.com/ruby/gem_rbs_collection.git
67
67
  repo_dir: gems
68
68
  - name: connection_pool
@@ -70,7 +70,7 @@ gems:
70
70
  source:
71
71
  type: git
72
72
  name: ruby/gem_rbs_collection
73
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
73
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
74
74
  remote: https://github.com/ruby/gem_rbs_collection.git
75
75
  repo_dir: gems
76
76
  - name: date
@@ -94,7 +94,7 @@ gems:
94
94
  source:
95
95
  type: git
96
96
  name: ruby/gem_rbs_collection
97
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
97
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
98
98
  remote: https://github.com/ruby/gem_rbs_collection.git
99
99
  repo_dir: gems
100
100
  - name: io-console
@@ -114,23 +114,19 @@ gems:
114
114
  source:
115
115
  type: git
116
116
  name: ruby/gem_rbs_collection
117
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
117
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
118
118
  remote: https://github.com/ruby/gem_rbs_collection.git
119
119
  repo_dir: gems
120
120
  - name: monitor
121
121
  version: '0'
122
122
  source:
123
123
  type: stdlib
124
- - name: mutex_m
125
- version: 0.3.0
126
- source:
127
- type: rubygems
128
124
  - name: nokogiri
129
125
  version: '1.11'
130
126
  source:
131
127
  type: git
132
128
  name: ruby/gem_rbs_collection
133
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
129
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
134
130
  remote: https://github.com/ruby/gem_rbs_collection.git
135
131
  repo_dir: gems
136
132
  - name: openssl
@@ -146,7 +142,7 @@ gems:
146
142
  source:
147
143
  type: git
148
144
  name: ruby/gem_rbs_collection
149
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
145
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
150
146
  remote: https://github.com/ruby/gem_rbs_collection.git
151
147
  repo_dir: gems
152
148
  - name: parser
@@ -154,7 +150,7 @@ gems:
154
150
  source:
155
151
  type: git
156
152
  name: ruby/gem_rbs_collection
157
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
153
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
158
154
  remote: https://github.com/ruby/gem_rbs_collection.git
159
155
  repo_dir: gems
160
156
  - name: pathname
@@ -166,7 +162,7 @@ gems:
166
162
  source:
167
163
  type: git
168
164
  name: ruby/gem_rbs_collection
169
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
165
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
170
166
  remote: https://github.com/ruby/gem_rbs_collection.git
171
167
  repo_dir: gems
172
168
  - name: rails-dom-testing
@@ -174,7 +170,7 @@ gems:
174
170
  source:
175
171
  type: git
176
172
  name: ruby/gem_rbs_collection
177
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
173
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
178
174
  remote: https://github.com/ruby/gem_rbs_collection.git
179
175
  repo_dir: gems
180
176
  - name: rails-html-sanitizer
@@ -182,7 +178,7 @@ gems:
182
178
  source:
183
179
  type: git
184
180
  name: ruby/gem_rbs_collection
185
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
181
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
186
182
  remote: https://github.com/ruby/gem_rbs_collection.git
187
183
  repo_dir: gems
188
184
  - name: railties
@@ -190,7 +186,7 @@ gems:
190
186
  source:
191
187
  type: git
192
188
  name: ruby/gem_rbs_collection
193
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
189
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
194
190
  remote: https://github.com/ruby/gem_rbs_collection.git
195
191
  repo_dir: gems
196
192
  - name: rainbow
@@ -198,7 +194,7 @@ gems:
198
194
  source:
199
195
  type: git
200
196
  name: ruby/gem_rbs_collection
201
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
197
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
202
198
  remote: https://github.com/ruby/gem_rbs_collection.git
203
199
  repo_dir: gems
204
200
  - name: rake
@@ -206,7 +202,7 @@ gems:
206
202
  source:
207
203
  type: git
208
204
  name: ruby/gem_rbs_collection
209
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
205
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
210
206
  remote: https://github.com/ruby/gem_rbs_collection.git
211
207
  repo_dir: gems
212
208
  - name: rbs
@@ -222,7 +218,7 @@ gems:
222
218
  source:
223
219
  type: git
224
220
  name: ruby/gem_rbs_collection
225
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
221
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
226
222
  remote: https://github.com/ruby/gem_rbs_collection.git
227
223
  repo_dir: gems
228
224
  - name: ripper
@@ -234,7 +230,7 @@ gems:
234
230
  source:
235
231
  type: git
236
232
  name: ruby/gem_rbs_collection
237
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
233
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
238
234
  remote: https://github.com/ruby/gem_rbs_collection.git
239
235
  repo_dir: gems
240
236
  - name: rubocop-ast
@@ -242,7 +238,7 @@ gems:
242
238
  source:
243
239
  type: git
244
240
  name: ruby/gem_rbs_collection
245
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
241
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
246
242
  remote: https://github.com/ruby/gem_rbs_collection.git
247
243
  repo_dir: gems
248
244
  - name: securerandom
@@ -270,7 +266,7 @@ gems:
270
266
  source:
271
267
  type: git
272
268
  name: ruby/gem_rbs_collection
273
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
269
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
274
270
  remote: https://github.com/ruby/gem_rbs_collection.git
275
271
  repo_dir: gems
276
272
  - name: time
@@ -290,7 +286,7 @@ gems:
290
286
  source:
291
287
  type: git
292
288
  name: ruby/gem_rbs_collection
293
- revision: 4af987b9b70455bd4493ef5a10e885f36e6ca6f6
289
+ revision: 2b3fb8480d3433c9c4b083ad52430a8253efbe5b
294
290
  remote: https://github.com/ruby/gem_rbs_collection.git
295
291
  repo_dir: gems
296
292
  - name: uri
@@ -26,7 +26,8 @@ module RbsActivesupport
26
26
  # @rbs namespace: RBS::Namespace
27
27
  # @rbs method_calls: Array[Parser::MethodCall]
28
28
  # @rbs context: RBS::Namespace?
29
- def build_method_calls: (RBS::Namespace namespace, Array[Parser::MethodCall] method_calls, RBS::Namespace? context) -> Array[t]
29
+ # @rbs options: Hash[Symbol, untyped]
30
+ def build_method_calls: (RBS::Namespace namespace, Array[Parser::MethodCall] method_calls, RBS::Namespace? context, ?Hash[Symbol, untyped] options) -> Array[t]
30
31
 
31
32
  # @rbs method_call: Parser::MethodCall
32
33
  def build_attribute_accessor: (Parser::MethodCall method_call) -> Array[AttributeAccessor]
@@ -41,7 +42,8 @@ module RbsActivesupport
41
42
  # @rbs namespace: RBS::Namespace
42
43
  # @rbs method_call: Parser::MethodCall
43
44
  # @rbs context: RBS::Namespace?
44
- def build_include: (RBS::Namespace namespace, Parser::MethodCall method_call, RBS::Namespace? context) -> Array[t]
45
+ # @rbs implicit: bool
46
+ def build_include: (RBS::Namespace namespace, Parser::MethodCall method_call, RBS::Namespace? context, implicit: bool) -> Array[t]
45
47
 
46
48
  # @rbs namespace: RBS::Namespace
47
49
  # @rbs decl: t
@@ -25,6 +25,10 @@ module RbsActivesupport
25
25
 
26
26
  def classmethods?: () -> boolish
27
27
 
28
+ def explicit?: () -> bool
29
+
30
+ def implicit?: () -> bool
31
+
28
32
  def nested_includes: () -> Array[Parser::MethodCall]
29
33
 
30
34
  def method_calls_in_included_block: () -> Array[Parser::MethodCall]
@@ -35,7 +39,7 @@ module RbsActivesupport
35
39
 
36
40
  private
37
41
 
38
- @parser: Parser
42
+ @parser: Parser?
39
43
 
40
44
  # @rbs %a{pure}
41
45
  %a{pure}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_activesupport
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi KOMIYA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-28 00:00:00.000000000 Z
11
+ date: 2025-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -106,6 +106,7 @@ metadata:
106
106
  homepage_uri: https://github.com/tk0miya/rbs_activesupport
107
107
  source_code_uri: https://github.com/tk0miya/rbs_activesupport
108
108
  changelog_uri: https://github.com/tk0miya/rbs_activesupport
109
+ rubygems_mfa_required: 'true'
109
110
  post_install_message:
110
111
  rdoc_options: []
111
112
  require_paths: