rbs_heuristic_prototype 0.5.1 → 0.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 +4 -4
- data/Gemfile.lock +16 -16
- data/README.md +2 -0
- data/lib/rbs_heuristic_prototype/filters/controller_concerns_filter.rb +47 -0
- data/lib/rbs_heuristic_prototype/rake_task.rb +1 -0
- data/lib/rbs_heuristic_prototype/version.rb +1 -1
- data/lib/rbs_heuristic_prototype.rb +1 -0
- data/rbs_collection.lock.yaml +15 -15
- data/sig/rbs_heuristic_prototype/filters/controller_concerns_filter.rbs +9 -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: 5e7e11861501ff2a314a91b2f337ad4d2eb221ebe592370e45af6e92ea948702
|
4
|
+
data.tar.gz: 44ffa57df421f66295eca2b851a284aa081261ef54260cb2b504cad251462cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab5dec88b9972879a5e138af3b6cec83570fde7dad9b639ce4d8a23b7c8e5f3658d58817b9fb0578bd201a511e5694b377a184842d933e08fdfb6608524ee848
|
7
|
+
data.tar.gz: 9f889db54fe192e9ec8e2b825fa65181e400f7f7459a1cc8a6a1f04917c6314390bd9c59194b87040e98e20859f345d5fde6f7bde803e2870dc13e4ebe31d44b
|
data/Gemfile.lock
CHANGED
@@ -1,32 +1,32 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs_heuristic_prototype (0.
|
4
|
+
rbs_heuristic_prototype (0.6.0)
|
5
5
|
activesupport
|
6
6
|
rbs
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actionpack (7.0.7)
|
12
|
-
actionview (= 7.0.7)
|
13
|
-
activesupport (= 7.0.7)
|
11
|
+
actionpack (7.0.7.2)
|
12
|
+
actionview (= 7.0.7.2)
|
13
|
+
activesupport (= 7.0.7.2)
|
14
14
|
rack (~> 2.0, >= 2.2.4)
|
15
15
|
rack-test (>= 0.6.3)
|
16
16
|
rails-dom-testing (~> 2.0)
|
17
17
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
18
|
-
actionview (7.0.7)
|
19
|
-
activesupport (= 7.0.7)
|
18
|
+
actionview (7.0.7.2)
|
19
|
+
activesupport (= 7.0.7.2)
|
20
20
|
builder (~> 3.1)
|
21
21
|
erubi (~> 1.4)
|
22
22
|
rails-dom-testing (~> 2.0)
|
23
23
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
24
|
-
activemodel (7.0.7)
|
25
|
-
activesupport (= 7.0.7)
|
26
|
-
activerecord (7.0.7)
|
27
|
-
activemodel (= 7.0.7)
|
28
|
-
activesupport (= 7.0.7)
|
29
|
-
activesupport (7.0.7)
|
24
|
+
activemodel (7.0.7.2)
|
25
|
+
activesupport (= 7.0.7.2)
|
26
|
+
activerecord (7.0.7.2)
|
27
|
+
activemodel (= 7.0.7.2)
|
28
|
+
activesupport (= 7.0.7.2)
|
29
|
+
activesupport (7.0.7.2)
|
30
30
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
31
31
|
i18n (>= 1.6, < 2)
|
32
32
|
minitest (>= 5.1)
|
@@ -77,9 +77,9 @@ GEM
|
|
77
77
|
rails-html-sanitizer (1.6.0)
|
78
78
|
loofah (~> 2.21)
|
79
79
|
nokogiri (~> 1.14)
|
80
|
-
railties (7.0.7)
|
81
|
-
actionpack (= 7.0.7)
|
82
|
-
activesupport (= 7.0.7)
|
80
|
+
railties (7.0.7.2)
|
81
|
+
actionpack (= 7.0.7.2)
|
82
|
+
activesupport (= 7.0.7.2)
|
83
83
|
method_source
|
84
84
|
rake (>= 12.2)
|
85
85
|
thor (~> 1.0)
|
@@ -108,7 +108,7 @@ GEM
|
|
108
108
|
diff-lcs (>= 1.2.0, < 2.0)
|
109
109
|
rspec-support (~> 3.12.0)
|
110
110
|
rspec-support (3.12.0)
|
111
|
-
rubocop (1.56.
|
111
|
+
rubocop (1.56.2)
|
112
112
|
base64 (~> 0.1.1)
|
113
113
|
json (~> 2.3)
|
114
114
|
language_server-protocol (>= 3.17.0)
|
data/README.md
CHANGED
@@ -39,6 +39,8 @@ by `rbs prototype` according to the heuristic rules.
|
|
39
39
|
* This is useful to define intermediate modules automatically like what Rails and zeitwerk does.
|
40
40
|
* Rule 5:
|
41
41
|
* Convert a module reference without type arguments (ex. `include Enumerable`) to a module reference with type arguments (ex. `include Enumerable[untyped]`)
|
42
|
+
* Rule 6:
|
43
|
+
* Convert a module definition of controller concerns to have its module-self-types (ex. `module Loginable` to `module Loginable: ApplicationController`)
|
42
44
|
|
43
45
|
## Development
|
44
46
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "base"
|
4
|
+
require "active_support/concern"
|
5
|
+
|
6
|
+
module RbsHeuristicPrototype
|
7
|
+
module Filters
|
8
|
+
class ControllerConcernsFilter < Base
|
9
|
+
def process_module(decl)
|
10
|
+
mod = const_get(decl)
|
11
|
+
if controller_concern?(mod) && decl.self_types.empty?
|
12
|
+
RBS::AST::Declarations::Module.new(
|
13
|
+
name: decl.name,
|
14
|
+
type_params: decl.type_params,
|
15
|
+
members: decl.members,
|
16
|
+
self_types: self_types_for(mod),
|
17
|
+
annotations: decl.annotations,
|
18
|
+
location: decl.location,
|
19
|
+
comment: decl.comment
|
20
|
+
)
|
21
|
+
else
|
22
|
+
decl
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def controller_concern?(mod)
|
27
|
+
return false unless mod.instance_variable_defined?(:@_dependencies)
|
28
|
+
|
29
|
+
source_location = Kernel.const_source_location(mod.name)
|
30
|
+
return false unless source_location
|
31
|
+
|
32
|
+
filename, = source_location.first
|
33
|
+
filename.include?("app/controllers/concerns")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self_types_for(mod)
|
37
|
+
name = if Kernel.const_get("ApplicationController") && !(mod > ApplicationController)
|
38
|
+
TypeName("::ApplicationController")
|
39
|
+
else
|
40
|
+
TypeName("::ActionController::Base")
|
41
|
+
end
|
42
|
+
|
43
|
+
[RBS::AST::Declarations::Module::Self.new(name: name, args: [], location: nil)]
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -9,6 +9,7 @@ module RbsHeuristicPrototype
|
|
9
9
|
FILTERS = {
|
10
10
|
active_model_validations: "RbsHeuristicPrototype::Filters::ActiveModelValidationsFilter",
|
11
11
|
boolean_methods: "RbsHeuristicPrototype::Filters::BooleanMethodsFilter",
|
12
|
+
controller_concerns: "RbsHeuristicPrototype::Filters::ControllerConcernsFilter",
|
12
13
|
deep_module: "RbsHeuristicPrototype::Filters::DeepModuleFilter",
|
13
14
|
symbol_array_constants: "RbsHeuristicPrototype::Filters::SymbolArrayConstantsFilter",
|
14
15
|
type_args: "RbsHeuristicPrototype::Filters::TypeArgsFilter"
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "rbs_heuristic_prototype/filters/active_model_validations_filter"
|
4
4
|
require_relative "rbs_heuristic_prototype/filters/boolean_methods_filter"
|
5
|
+
require_relative "rbs_heuristic_prototype/filters/controller_concerns_filter"
|
5
6
|
require_relative "rbs_heuristic_prototype/filters/deep_module_filter"
|
6
7
|
require_relative "rbs_heuristic_prototype/filters/symbol_array_constants_filter"
|
7
8
|
require_relative "rbs_heuristic_prototype/filters/type_args_filter"
|
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: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
28
28
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
29
29
|
repo_dir: gems
|
30
30
|
- name: activemodel
|
@@ -32,7 +32,7 @@ gems:
|
|
32
32
|
source:
|
33
33
|
type: git
|
34
34
|
name: ruby/gem_rbs_collection
|
35
|
-
revision:
|
35
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
36
36
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
37
37
|
repo_dir: gems
|
38
38
|
- name: activerecord
|
@@ -40,7 +40,7 @@ gems:
|
|
40
40
|
source:
|
41
41
|
type: git
|
42
42
|
name: ruby/gem_rbs_collection
|
43
|
-
revision:
|
43
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
44
44
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
45
45
|
repo_dir: gems
|
46
46
|
- name: activesupport
|
@@ -48,7 +48,7 @@ gems:
|
|
48
48
|
source:
|
49
49
|
type: git
|
50
50
|
name: ruby/gem_rbs_collection
|
51
|
-
revision:
|
51
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
52
52
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
53
53
|
repo_dir: gems
|
54
54
|
- name: ast
|
@@ -56,7 +56,7 @@ gems:
|
|
56
56
|
source:
|
57
57
|
type: git
|
58
58
|
name: ruby/gem_rbs_collection
|
59
|
-
revision:
|
59
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
60
60
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
61
61
|
repo_dir: gems
|
62
62
|
- name: base64
|
@@ -72,7 +72,7 @@ gems:
|
|
72
72
|
source:
|
73
73
|
type: git
|
74
74
|
name: ruby/gem_rbs_collection
|
75
|
-
revision:
|
75
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
76
76
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
77
77
|
repo_dir: gems
|
78
78
|
- name: date
|
@@ -84,7 +84,7 @@ gems:
|
|
84
84
|
source:
|
85
85
|
type: git
|
86
86
|
name: ruby/gem_rbs_collection
|
87
|
-
revision:
|
87
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
88
88
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
89
89
|
repo_dir: gems
|
90
90
|
- name: json
|
@@ -112,7 +112,7 @@ gems:
|
|
112
112
|
source:
|
113
113
|
type: git
|
114
114
|
name: ruby/gem_rbs_collection
|
115
|
-
revision:
|
115
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
116
116
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
117
117
|
repo_dir: gems
|
118
118
|
- name: optparse
|
@@ -124,7 +124,7 @@ gems:
|
|
124
124
|
source:
|
125
125
|
type: git
|
126
126
|
name: ruby/gem_rbs_collection
|
127
|
-
revision:
|
127
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
128
128
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
129
129
|
repo_dir: gems
|
130
130
|
- name: pathname
|
@@ -136,7 +136,7 @@ gems:
|
|
136
136
|
source:
|
137
137
|
type: git
|
138
138
|
name: ruby/gem_rbs_collection
|
139
|
-
revision:
|
139
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
140
140
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
141
141
|
repo_dir: gems
|
142
142
|
- name: rails-dom-testing
|
@@ -144,7 +144,7 @@ gems:
|
|
144
144
|
source:
|
145
145
|
type: git
|
146
146
|
name: ruby/gem_rbs_collection
|
147
|
-
revision:
|
147
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
148
148
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
149
149
|
repo_dir: gems
|
150
150
|
- name: railties
|
@@ -152,7 +152,7 @@ gems:
|
|
152
152
|
source:
|
153
153
|
type: git
|
154
154
|
name: ruby/gem_rbs_collection
|
155
|
-
revision:
|
155
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
156
156
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
157
157
|
repo_dir: gems
|
158
158
|
- name: rainbow
|
@@ -160,7 +160,7 @@ gems:
|
|
160
160
|
source:
|
161
161
|
type: git
|
162
162
|
name: ruby/gem_rbs_collection
|
163
|
-
revision:
|
163
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
164
164
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
165
165
|
repo_dir: gems
|
166
166
|
- name: rbs
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module RbsHeuristicPrototype
|
2
|
+
module Filters
|
3
|
+
class BooleanMethodsFilter < Base
|
4
|
+
def process_module: (RBS::AST::Declarations::Module decl) -> RBS::AST::Declarations::Module
|
5
|
+
def controller_concern?: (Module mod) -> bool
|
6
|
+
def self_types_for: (Module mod) -> Array[RBS::AST::Declarations::Module::Self]
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_heuristic_prototype
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.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: 2023-
|
11
|
+
date: 2023-09-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- lib/rbs_heuristic_prototype/filters/active_model_validations_filter.rb
|
62
62
|
- lib/rbs_heuristic_prototype/filters/base.rb
|
63
63
|
- lib/rbs_heuristic_prototype/filters/boolean_methods_filter.rb
|
64
|
+
- lib/rbs_heuristic_prototype/filters/controller_concerns_filter.rb
|
64
65
|
- lib/rbs_heuristic_prototype/filters/deep_module_filter.rb
|
65
66
|
- lib/rbs_heuristic_prototype/filters/symbol_array_constants_filter.rb
|
66
67
|
- lib/rbs_heuristic_prototype/filters/type_args_filter.rb
|
@@ -75,6 +76,7 @@ files:
|
|
75
76
|
- sig/rbs_heuristic_prototype/filters/active_model_validations_filter.rbs
|
76
77
|
- sig/rbs_heuristic_prototype/filters/base.rbs
|
77
78
|
- sig/rbs_heuristic_prototype/filters/boolean_methods_filter.rbs
|
79
|
+
- sig/rbs_heuristic_prototype/filters/controller_concerns_filter.rbs
|
78
80
|
- sig/rbs_heuristic_prototype/filters/deep_module_filter.rbs
|
79
81
|
- sig/rbs_heuristic_prototype/filters/symbol_array_constants_filter.rbs
|
80
82
|
- sig/rbs_heuristic_prototype/rake_task.rbs
|