rbs_rails 0.10.0 → 0.10.1
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/CHANGELOG.md +18 -0
- data/DESIGN.md +36 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +68 -65
- data/README.md +11 -25
- data/lib/rbs_rails/active_record.rb +8 -0
- data/lib/rbs_rails/dependency_builder.rb +2 -2
- data/lib/rbs_rails/rake_task.rb +1 -0
- data/lib/rbs_rails/version.rb +1 -1
- data/rbs_collection.lock.yaml +2 -2
- data/sig/rbs_rails/active_record.rbs +1 -0
- data/sig/rbs_rails/dependency_builder.rbs +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16dd1379f4621410d78e352c8fdc8750d3fb469d8c395aee77de85d2f8570279
|
4
|
+
data.tar.gz: e50b75cc1e64a8630c1508805d146d2cf5edad065cdcab502f910fcb84bc51ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12136882eeebf0e2219af85c6393f6b8a74c4bc6f268b57d5b9c931a99fa42ee81ed9deb9885d4209f28dbf43d9d57563641379031c199397cf520a7dc417f10
|
7
|
+
data.tar.gz: 40ffd8a1525501f736f759769a95183e3933da0c1063e5e939b6c4ccf23ae9d98731ef782c23f6c7eb6b7280b2c39f535379886edeb3abeb423810cf2ead58ac
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.10.1 (2022-03-23)
|
6
|
+
|
7
|
+
### Bug Fixes
|
8
|
+
|
9
|
+
* Generate dependency types of relations. [#216](https://github.com/pocke/rbs_rails/pull/216)
|
10
|
+
|
11
|
+
## 0.10.0 (2022-03-18)
|
12
|
+
|
13
|
+
### New Features
|
14
|
+
|
15
|
+
* Support `has_secure_password`. [#193](https://github.com/pocke/rbs_rails/pull/193)
|
16
|
+
* Support Active Storage. [#195](https://github.com/pocke/rbs_rails/pull/195)
|
17
|
+
|
18
|
+
### Bug Fixes
|
19
|
+
|
20
|
+
* Use absolute path for class names to avoid using incorrect class. [#201](https://github.com/pocke/rbs_rails/pull/201)
|
21
|
+
* Fix NoMethodError on enum with `_default` option. [#208](https://github.com/pocke/rbs_rails/pull/208)
|
22
|
+
|
5
23
|
## 0.9.0 (2021-09-18)
|
6
24
|
|
7
25
|
### New Features
|
data/DESIGN.md
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# RBS Generator for Active Record models
|
2
|
+
|
3
|
+
The RBS generator for Active Record models focus on generating methods that are generated by Active Record.
|
4
|
+
For example, it generates the following things.
|
5
|
+
|
6
|
+
* Classes which inherit `ActiveRecord::Base`
|
7
|
+
* Generated methods by Active Record
|
8
|
+
* Column methods. e.g. `name` and `name=` methods for `name` column.
|
9
|
+
* Relation methods. e.g. `users` and `users=` methods for `has_many :users`.
|
10
|
+
* And so on.
|
11
|
+
|
12
|
+
I designed it generates "valid" RBSs. "valid" means the generated RBSs pass `rbs validate` only with `rbs collection`.
|
13
|
+
So if you need to do something to pass `rbs validate`, it's a bug. For example, if you see `RBS::NoSuperclassFoundError` for the generated RBS, it is a bug.
|
14
|
+
|
15
|
+
RBS Rails focuses on generating "generated" methods. It means it doesn't generate methods that are defined by the user.
|
16
|
+
For example:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
class User < ApplicationRecord
|
20
|
+
# RBS Rails generates articles methods and so on
|
21
|
+
# becasue they are generated by Active Record.
|
22
|
+
has_many :articles
|
23
|
+
|
24
|
+
# RBS Rails does NOT generate full_name method
|
25
|
+
# because the user defines it.
|
26
|
+
def full_name
|
27
|
+
first_name + last_name
|
28
|
+
end
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
You can use `rbs prototype rb`, `rbs prototype runtime` and `typeprof` commands to generate them.
|
33
|
+
|
34
|
+
# RBS Generator for the path helper
|
35
|
+
|
36
|
+
TODO
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,68 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs_rails (0.10.
|
4
|
+
rbs_rails (0.10.1)
|
5
5
|
parser
|
6
6
|
rbs (>= 1)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
actioncable (6.
|
12
|
-
actionpack (= 6.
|
11
|
+
actioncable (6.1.5)
|
12
|
+
actionpack (= 6.1.5)
|
13
|
+
activesupport (= 6.1.5)
|
13
14
|
nio4r (~> 2.0)
|
14
15
|
websocket-driver (>= 0.6.1)
|
15
|
-
actionmailbox (6.
|
16
|
-
actionpack (= 6.
|
17
|
-
activejob (= 6.
|
18
|
-
activerecord (= 6.
|
19
|
-
activestorage (= 6.
|
20
|
-
activesupport (= 6.
|
16
|
+
actionmailbox (6.1.5)
|
17
|
+
actionpack (= 6.1.5)
|
18
|
+
activejob (= 6.1.5)
|
19
|
+
activerecord (= 6.1.5)
|
20
|
+
activestorage (= 6.1.5)
|
21
|
+
activesupport (= 6.1.5)
|
21
22
|
mail (>= 2.7.1)
|
22
|
-
actionmailer (6.
|
23
|
-
actionpack (= 6.
|
24
|
-
actionview (= 6.
|
25
|
-
activejob (= 6.
|
23
|
+
actionmailer (6.1.5)
|
24
|
+
actionpack (= 6.1.5)
|
25
|
+
actionview (= 6.1.5)
|
26
|
+
activejob (= 6.1.5)
|
27
|
+
activesupport (= 6.1.5)
|
26
28
|
mail (~> 2.5, >= 2.5.4)
|
27
29
|
rails-dom-testing (~> 2.0)
|
28
|
-
actionpack (6.
|
29
|
-
actionview (= 6.
|
30
|
-
activesupport (= 6.
|
31
|
-
rack (~> 2.0, >= 2.0.
|
30
|
+
actionpack (6.1.5)
|
31
|
+
actionview (= 6.1.5)
|
32
|
+
activesupport (= 6.1.5)
|
33
|
+
rack (~> 2.0, >= 2.0.9)
|
32
34
|
rack-test (>= 0.6.3)
|
33
35
|
rails-dom-testing (~> 2.0)
|
34
36
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
35
|
-
actiontext (6.
|
36
|
-
actionpack (= 6.
|
37
|
-
activerecord (= 6.
|
38
|
-
activestorage (= 6.
|
39
|
-
activesupport (= 6.
|
37
|
+
actiontext (6.1.5)
|
38
|
+
actionpack (= 6.1.5)
|
39
|
+
activerecord (= 6.1.5)
|
40
|
+
activestorage (= 6.1.5)
|
41
|
+
activesupport (= 6.1.5)
|
40
42
|
nokogiri (>= 1.8.5)
|
41
|
-
actionview (6.
|
42
|
-
activesupport (= 6.
|
43
|
+
actionview (6.1.5)
|
44
|
+
activesupport (= 6.1.5)
|
43
45
|
builder (~> 3.1)
|
44
46
|
erubi (~> 1.4)
|
45
47
|
rails-dom-testing (~> 2.0)
|
46
48
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
47
|
-
activejob (6.
|
48
|
-
activesupport (= 6.
|
49
|
+
activejob (6.1.5)
|
50
|
+
activesupport (= 6.1.5)
|
49
51
|
globalid (>= 0.3.6)
|
50
|
-
activemodel (6.
|
51
|
-
activesupport (= 6.
|
52
|
-
activerecord (6.
|
53
|
-
activemodel (= 6.
|
54
|
-
activesupport (= 6.
|
55
|
-
activestorage (6.
|
56
|
-
actionpack (= 6.
|
57
|
-
activejob (= 6.
|
58
|
-
activerecord (= 6.
|
59
|
-
|
60
|
-
|
52
|
+
activemodel (6.1.5)
|
53
|
+
activesupport (= 6.1.5)
|
54
|
+
activerecord (6.1.5)
|
55
|
+
activemodel (= 6.1.5)
|
56
|
+
activesupport (= 6.1.5)
|
57
|
+
activestorage (6.1.5)
|
58
|
+
actionpack (= 6.1.5)
|
59
|
+
activejob (= 6.1.5)
|
60
|
+
activerecord (= 6.1.5)
|
61
|
+
activesupport (= 6.1.5)
|
62
|
+
marcel (~> 1.0)
|
63
|
+
mini_mime (>= 1.1.0)
|
64
|
+
activesupport (6.1.5)
|
61
65
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
62
|
-
i18n (>=
|
63
|
-
minitest (
|
64
|
-
tzinfo (~>
|
65
|
-
zeitwerk (~> 2.
|
66
|
+
i18n (>= 1.6, < 2)
|
67
|
+
minitest (>= 5.1)
|
68
|
+
tzinfo (~> 2.0)
|
69
|
+
zeitwerk (~> 2.3)
|
66
70
|
ast (2.4.2)
|
67
71
|
builder (3.2.4)
|
68
72
|
concurrent-ruby (1.1.9)
|
@@ -98,32 +102,32 @@ GEM
|
|
98
102
|
rack (2.2.3)
|
99
103
|
rack-test (1.1.0)
|
100
104
|
rack (>= 1.0, < 3)
|
101
|
-
rails (6.
|
102
|
-
actioncable (= 6.
|
103
|
-
actionmailbox (= 6.
|
104
|
-
actionmailer (= 6.
|
105
|
-
actionpack (= 6.
|
106
|
-
actiontext (= 6.
|
107
|
-
actionview (= 6.
|
108
|
-
activejob (= 6.
|
109
|
-
activemodel (= 6.
|
110
|
-
activerecord (= 6.
|
111
|
-
activestorage (= 6.
|
112
|
-
activesupport (= 6.
|
113
|
-
bundler (>= 1.
|
114
|
-
railties (= 6.
|
105
|
+
rails (6.1.5)
|
106
|
+
actioncable (= 6.1.5)
|
107
|
+
actionmailbox (= 6.1.5)
|
108
|
+
actionmailer (= 6.1.5)
|
109
|
+
actionpack (= 6.1.5)
|
110
|
+
actiontext (= 6.1.5)
|
111
|
+
actionview (= 6.1.5)
|
112
|
+
activejob (= 6.1.5)
|
113
|
+
activemodel (= 6.1.5)
|
114
|
+
activerecord (= 6.1.5)
|
115
|
+
activestorage (= 6.1.5)
|
116
|
+
activesupport (= 6.1.5)
|
117
|
+
bundler (>= 1.15.0)
|
118
|
+
railties (= 6.1.5)
|
115
119
|
sprockets-rails (>= 2.0.0)
|
116
120
|
rails-dom-testing (2.0.3)
|
117
121
|
activesupport (>= 4.2.0)
|
118
122
|
nokogiri (>= 1.6)
|
119
123
|
rails-html-sanitizer (1.4.2)
|
120
124
|
loofah (~> 2.3)
|
121
|
-
railties (6.
|
122
|
-
actionpack (= 6.
|
123
|
-
activesupport (= 6.
|
125
|
+
railties (6.1.5)
|
126
|
+
actionpack (= 6.1.5)
|
127
|
+
activesupport (= 6.1.5)
|
124
128
|
method_source
|
125
|
-
rake (>=
|
126
|
-
thor (
|
129
|
+
rake (>= 12.2)
|
130
|
+
thor (~> 1.0)
|
127
131
|
rainbow (3.1.1)
|
128
132
|
rake (13.0.6)
|
129
133
|
rb-fsevent (0.11.1)
|
@@ -149,9 +153,8 @@ GEM
|
|
149
153
|
terminal-table (3.0.2)
|
150
154
|
unicode-display_width (>= 1.1.1, < 3)
|
151
155
|
thor (1.2.1)
|
152
|
-
|
153
|
-
|
154
|
-
thread_safe (~> 0.1)
|
156
|
+
tzinfo (2.0.4)
|
157
|
+
concurrent-ruby (~> 1.0)
|
155
158
|
unicode-display_width (2.1.0)
|
156
159
|
websocket-driver (0.7.5)
|
157
160
|
websocket-extensions (>= 0.1.0)
|
@@ -164,11 +167,11 @@ PLATFORMS
|
|
164
167
|
|
165
168
|
DEPENDENCIES
|
166
169
|
minitest
|
167
|
-
rails (>= 6.0, <
|
170
|
+
rails (>= 6.0, < 7)
|
168
171
|
rake (~> 13.0)
|
169
172
|
rbs (>= 2)
|
170
173
|
rbs_rails!
|
171
174
|
steep
|
172
175
|
|
173
176
|
BUNDLED WITH
|
174
|
-
2.
|
177
|
+
2.3.9
|
data/README.md
CHANGED
@@ -35,44 +35,30 @@ Then, the following three tasks are available.
|
|
35
35
|
* `rbs_rails:all`: Execute all tasks of RBS Rails
|
36
36
|
|
37
37
|
|
38
|
+
### Install RBS for `rails` gem
|
38
39
|
|
40
|
+
You need to install `rails` gem's RBS files. I highly recommend using `rbs collection`.
|
41
|
+
|
42
|
+
1. Add `gem 'rails'` to your `Gemfile`.
|
43
|
+
1. Then execute the following commands
|
44
|
+
```console
|
45
|
+
$ bundle install
|
46
|
+
$ bundle exec rbs collection install
|
47
|
+
```
|
39
48
|
|
40
49
|
### Steep integration
|
41
50
|
|
42
|
-
|
51
|
+
Put the following code as `Steepfile`.
|
43
52
|
|
44
53
|
```ruby
|
45
|
-
# Steepfile
|
46
|
-
|
47
54
|
target :app do
|
48
55
|
signature 'sig'
|
49
56
|
|
50
57
|
check 'app'
|
51
|
-
|
52
|
-
repo_path "path/to/rbs_repo"
|
53
|
-
|
54
|
-
library 'pathname'
|
55
|
-
library 'logger'
|
56
|
-
library 'mutex_m'
|
57
|
-
library 'date'
|
58
|
-
library 'monitor'
|
59
|
-
library 'singleton'
|
60
|
-
library 'tsort'
|
61
|
-
library 'time'
|
62
|
-
|
63
|
-
library 'rack'
|
64
|
-
|
65
|
-
library 'activesupport'
|
66
|
-
library 'actionpack'
|
67
|
-
library 'activejob'
|
68
|
-
library 'activemodel'
|
69
|
-
library 'actionview'
|
70
|
-
library 'activerecord'
|
71
|
-
library 'railties'
|
72
58
|
end
|
73
59
|
```
|
74
60
|
|
75
|
-
|
61
|
+
That's all! Now you can check your Rails app statically with `steep check` command.
|
76
62
|
|
77
63
|
## Development
|
78
64
|
|
@@ -122,9 +122,13 @@ module RbsRails
|
|
122
122
|
|
123
123
|
private def has_many
|
124
124
|
klass.reflect_on_all_associations(:has_many).map do |a|
|
125
|
+
@dependencies << a.klass.name
|
126
|
+
|
125
127
|
singular_name = a.name.to_s.singularize
|
126
128
|
type = Util.module_name(a.klass)
|
127
129
|
collection_type = "#{type}::ActiveRecord_Associations_CollectionProxy"
|
130
|
+
@dependencies << collection_type
|
131
|
+
|
128
132
|
<<~RUBY.chomp
|
129
133
|
def #{a.name}: () -> #{collection_type}
|
130
134
|
def #{a.name}=: (#{collection_type} | Array[#{type}]) -> (#{collection_type} | Array[#{type}])
|
@@ -136,6 +140,8 @@ module RbsRails
|
|
136
140
|
|
137
141
|
private def has_one
|
138
142
|
klass.reflect_on_all_associations(:has_one).map do |a|
|
143
|
+
@dependencies << a.klass.name unless a.polymorphic?
|
144
|
+
|
139
145
|
type = a.polymorphic? ? 'untyped' : Util.module_name(a.klass)
|
140
146
|
type_optional = optional(type)
|
141
147
|
<<~RUBY.chomp
|
@@ -151,6 +157,8 @@ module RbsRails
|
|
151
157
|
|
152
158
|
private def belongs_to
|
153
159
|
klass.reflect_on_all_associations(:belongs_to).map do |a|
|
160
|
+
@dependencies << a.klass.name unless a.polymorphic?
|
161
|
+
|
154
162
|
type = a.polymorphic? ? 'untyped' : Util.module_name(a.klass)
|
155
163
|
type_optional = optional(type)
|
156
164
|
# @type var methods: Array[String]
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module RbsRails
|
2
2
|
class DependencyBuilder
|
3
|
-
attr_reader :deps
|
3
|
+
attr_reader :deps, :done
|
4
4
|
|
5
5
|
def initialize
|
6
6
|
@deps = []
|
7
|
+
@done = Set.new(['ActiveRecord::Base', 'ActiveRecord', 'Object'])
|
7
8
|
end
|
8
9
|
|
9
10
|
def build
|
10
11
|
dep_rbs = +""
|
11
|
-
done = Set.new(['ActiveRecord::Base', 'ActiveRecord', 'Object'])
|
12
12
|
deps.uniq!
|
13
13
|
while dep = deps.shift
|
14
14
|
next unless done.add?(dep)
|
data/lib/rbs_rails/rake_task.rb
CHANGED
data/lib/rbs_rails/version.rb
CHANGED
data/rbs_collection.lock.yaml
CHANGED
@@ -67,7 +67,7 @@ gems:
|
|
67
67
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
68
68
|
repo_dir: gems
|
69
69
|
- name: activerecord
|
70
|
-
version: '6.
|
70
|
+
version: '6.1'
|
71
71
|
source:
|
72
72
|
type: git
|
73
73
|
name: ruby/gem_rbs_collection
|
@@ -75,7 +75,7 @@ gems:
|
|
75
75
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
76
76
|
repo_dir: gems
|
77
77
|
- name: activestorage
|
78
|
-
version: '6.
|
78
|
+
version: '6.1'
|
79
79
|
source:
|
80
80
|
type: git
|
81
81
|
name: ruby/gem_rbs_collection
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masataka Pocke Kuwabara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- ".gitignore"
|
51
51
|
- ".gitmodules"
|
52
52
|
- CHANGELOG.md
|
53
|
+
- DESIGN.md
|
53
54
|
- Gemfile
|
54
55
|
- Gemfile.lock
|
55
56
|
- LICENSE
|