rbs_discard 0.2.0 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcc5d14581a5b5fb41056a46d728cf48eab3e00f9676dac56a30babd780390c2
4
- data.tar.gz: 90474ed72c5f2a5f35329f7b8109f947e5365a9a4370c790ec3b5e349f9d0ab4
3
+ metadata.gz: cf799cb56cfe433c75127cb1b808b8f36f97ec442f489df8849e77e732ff252f
4
+ data.tar.gz: a2cf51f37804a9e661245142259d61eaacaa5beed2dbeb26f55e52ce38f686f9
5
5
  SHA512:
6
- metadata.gz: a28c5d18e7b896db467807782fce14e83b19a81f0f49b7f224765fa99eaea96af5b446e41ca98c3dd8bfd638706e6a7222cf29ec0fbaa4281c8b0d93632cffd5
7
- data.tar.gz: c8c8767266fa7be7da5d53cb78554dbe339d4db9d19da69e598586dba76c9a56311f4bce55e677c39d96932761cb2a6de5ad84102651225756061f61fe78c8b6
6
+ metadata.gz: e16101f420de3625c4e8733329c8c954426da24646296d4c7ca5d19d7634b1656010059d973f12937bbcc08f7b660051f12f785db34107779f55cc6dff06bdbf
7
+ data.tar.gz: f8acb01a7d6c008d4819a5f599c6c81559dc87270515705058a726ea7888237091a0d38440d72bd18ceaef099064ad91e04858e0527507cca24c161cba337c73
data/.rubocop.yml CHANGED
@@ -21,3 +21,6 @@ Layout/LineLength:
21
21
 
22
22
  Layout/MethodLength:
23
23
  Max: 20
24
+
25
+ Metrics/AbcSize:
26
+ Max: 20
@@ -6,8 +6,11 @@ module RbsDiscard
6
6
  class InstallGenerator < ::Rails::Generators::Base
7
7
  def create_raketask
8
8
  create_file "lib/tasks/rbs_discard.rake", <<~RUBY
9
+ # frozen_string_literal: true
10
+
9
11
  begin
10
12
  require "rbs_discard/rake_task"
13
+
11
14
  RbsDiscard::RakeTask.new
12
15
  rescue LoadError
13
16
  # failed to load rbs_discard. Skip to load rbs_discard tasks.
@@ -1,7 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rbs"
4
- require "rbs_rails"
5
4
 
6
5
  module RbsDiscard
7
6
  module Discard
@@ -22,17 +21,11 @@ module RbsDiscard
22
21
 
23
22
  def initialize(klass)
24
23
  @klass = klass
25
- @klass_name = RbsRails::Util.module_name(klass)
24
+ @klass_name = klass.name || ""
26
25
  end
27
26
 
28
27
  def generate
29
- RbsRails::Util.format_rbs klass_decl
30
- end
31
-
32
- private
33
-
34
- def klass_decl
35
- <<~RBS
28
+ format <<~RBS
36
29
  #{header}
37
30
  class ActiveRecord_Relation
38
31
  include Discard::Model::Relation
@@ -51,6 +44,15 @@ module RbsDiscard
51
44
  RBS
52
45
  end
53
46
 
47
+ private
48
+
49
+ def format(rbs)
50
+ parsed = RBS::Parser.parse_signature(rbs)
51
+ StringIO.new.tap do |out|
52
+ RBS::Writer.new(out: out).write(parsed[1] + parsed[2])
53
+ end.string
54
+ end
55
+
54
56
  def header
55
57
  namespace = +""
56
58
  klass_name.split("::").map do |mod_name|
@@ -60,7 +62,7 @@ module RbsDiscard
60
62
  when Class
61
63
  # @type var superclass: Class
62
64
  superclass = _ = mod_object.superclass
63
- superclass_name = RbsRails::Util.module_name(superclass)
65
+ superclass_name = superclass.name || "Object"
64
66
 
65
67
  "class #{mod_name} < ::#{superclass_name}"
66
68
  when Module
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "active_support"
3
4
  require "pathname"
4
5
  require "rake/tasklib"
5
6
 
@@ -46,7 +47,7 @@ module RbsDiscard
46
47
 
47
48
  RbsDiscard::Discard.all.each do |klass|
48
49
  rbs = RbsDiscard::Discard.class_to_rbs(klass)
49
- path = signature_root_dir / "app/models/#{klass.name.underscore}.rbs"
50
+ path = signature_root_dir / "app/models/#{klass.name.to_s.underscore}.rbs"
50
51
  path.dirname.mkpath
51
52
  path.write(rbs)
52
53
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsDiscard
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.2"
5
5
  end
@@ -2,21 +2,49 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
5
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
6
6
  remote: https://github.com/ruby/gem_rbs_collection.git
7
7
  repo_dir: gems
8
8
  path: ".gem_rbs_collection"
9
9
  gems:
10
- - name: abbrev
11
- version: '0'
10
+ - name: actionmailer
11
+ version: '7.0'
12
12
  source:
13
- type: stdlib
13
+ type: git
14
+ name: ruby/gem_rbs_collection
15
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
16
+ remote: https://github.com/ruby/gem_rbs_collection.git
17
+ repo_dir: gems
18
+ - name: actionpack
19
+ version: '6.0'
20
+ source:
21
+ type: git
22
+ name: ruby/gem_rbs_collection
23
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
24
+ remote: https://github.com/ruby/gem_rbs_collection.git
25
+ repo_dir: gems
26
+ - name: actionview
27
+ version: '6.0'
28
+ source:
29
+ type: git
30
+ name: ruby/gem_rbs_collection
31
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
32
+ remote: https://github.com/ruby/gem_rbs_collection.git
33
+ repo_dir: gems
34
+ - name: activejob
35
+ version: '6.0'
36
+ source:
37
+ type: git
38
+ name: ruby/gem_rbs_collection
39
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
40
+ remote: https://github.com/ruby/gem_rbs_collection.git
41
+ repo_dir: gems
14
42
  - name: activemodel
15
43
  version: '7.0'
16
44
  source:
17
45
  type: git
18
46
  name: ruby/gem_rbs_collection
19
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
47
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
20
48
  remote: https://github.com/ruby/gem_rbs_collection.git
21
49
  repo_dir: gems
22
50
  - name: activerecord
@@ -24,7 +52,15 @@ gems:
24
52
  source:
25
53
  type: git
26
54
  name: ruby/gem_rbs_collection
27
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
55
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
56
+ remote: https://github.com/ruby/gem_rbs_collection.git
57
+ repo_dir: gems
58
+ - name: activestorage
59
+ version: '6.1'
60
+ source:
61
+ type: git
62
+ name: ruby/gem_rbs_collection
63
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
28
64
  remote: https://github.com/ruby/gem_rbs_collection.git
29
65
  repo_dir: gems
30
66
  - name: activesupport
@@ -32,7 +68,7 @@ gems:
32
68
  source:
33
69
  type: git
34
70
  name: ruby/gem_rbs_collection
35
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
71
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
36
72
  remote: https://github.com/ruby/gem_rbs_collection.git
37
73
  repo_dir: gems
38
74
  - name: ast
@@ -40,31 +76,51 @@ gems:
40
76
  source:
41
77
  type: git
42
78
  name: ruby/gem_rbs_collection
43
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
79
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
44
80
  remote: https://github.com/ruby/gem_rbs_collection.git
45
81
  repo_dir: gems
46
82
  - name: base64
47
83
  version: '0'
48
84
  source:
49
85
  type: stdlib
86
+ - name: cgi
87
+ version: '0'
88
+ source:
89
+ type: stdlib
50
90
  - name: concurrent-ruby
51
91
  version: '1.1'
52
92
  source:
53
93
  type: git
54
94
  name: ruby/gem_rbs_collection
55
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
95
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
56
96
  remote: https://github.com/ruby/gem_rbs_collection.git
57
97
  repo_dir: gems
58
98
  - name: date
59
99
  version: '0'
60
100
  source:
61
101
  type: stdlib
102
+ - name: erb
103
+ version: '0'
104
+ source:
105
+ type: stdlib
106
+ - name: fileutils
107
+ version: '0'
108
+ source:
109
+ type: stdlib
110
+ - name: globalid
111
+ version: '1.1'
112
+ source:
113
+ type: git
114
+ name: ruby/gem_rbs_collection
115
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
116
+ remote: https://github.com/ruby/gem_rbs_collection.git
117
+ repo_dir: gems
62
118
  - name: i18n
63
119
  version: '1.10'
64
120
  source:
65
121
  type: git
66
122
  name: ruby/gem_rbs_collection
67
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
123
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
68
124
  remote: https://github.com/ruby/gem_rbs_collection.git
69
125
  repo_dir: gems
70
126
  - name: json
@@ -75,6 +131,14 @@ gems:
75
131
  version: '0'
76
132
  source:
77
133
  type: stdlib
134
+ - name: mail
135
+ version: '2.8'
136
+ source:
137
+ type: git
138
+ name: ruby/gem_rbs_collection
139
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
140
+ remote: https://github.com/ruby/gem_rbs_collection.git
141
+ repo_dir: gems
78
142
  - name: minitest
79
143
  version: '0'
80
144
  source:
@@ -87,42 +151,58 @@ gems:
87
151
  version: '0'
88
152
  source:
89
153
  type: stdlib
90
- - name: optparse
91
- version: '0'
154
+ - name: nokogiri
155
+ version: '1.11'
92
156
  source:
93
- type: stdlib
157
+ type: git
158
+ name: ruby/gem_rbs_collection
159
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
160
+ remote: https://github.com/ruby/gem_rbs_collection.git
161
+ repo_dir: gems
94
162
  - name: parallel
95
163
  version: '1.20'
96
164
  source:
97
165
  type: git
98
166
  name: ruby/gem_rbs_collection
99
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
167
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
100
168
  remote: https://github.com/ruby/gem_rbs_collection.git
101
169
  repo_dir: gems
102
170
  - name: pathname
103
171
  version: '0'
104
172
  source:
105
173
  type: stdlib
106
- - name: rainbow
107
- version: '3.0'
174
+ - name: rack
175
+ version: '2.2'
108
176
  source:
109
177
  type: git
110
178
  name: ruby/gem_rbs_collection
111
- revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
179
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
112
180
  remote: https://github.com/ruby/gem_rbs_collection.git
113
181
  repo_dir: gems
114
- - name: rbs
115
- version: 3.2.0
182
+ - name: rails-dom-testing
183
+ version: '2.0'
116
184
  source:
117
- type: rubygems
118
- - name: rbs_rails
119
- version: 0.12.0
185
+ type: git
186
+ name: ruby/gem_rbs_collection
187
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
188
+ remote: https://github.com/ruby/gem_rbs_collection.git
189
+ repo_dir: gems
190
+ - name: railties
191
+ version: '6.0'
120
192
  source:
121
- type: rubygems
122
- - name: rdoc
123
- version: '0'
193
+ type: git
194
+ name: ruby/gem_rbs_collection
195
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
196
+ remote: https://github.com/ruby/gem_rbs_collection.git
197
+ repo_dir: gems
198
+ - name: rainbow
199
+ version: '3.0'
124
200
  source:
125
- type: stdlib
201
+ type: git
202
+ name: ruby/gem_rbs_collection
203
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
204
+ remote: https://github.com/ruby/gem_rbs_collection.git
205
+ repo_dir: gems
126
206
  - name: securerandom
127
207
  version: '0'
128
208
  source:
@@ -131,12 +211,24 @@ gems:
131
211
  version: '0'
132
212
  source:
133
213
  type: stdlib
214
+ - name: tempfile
215
+ version: '0'
216
+ source:
217
+ type: stdlib
134
218
  - name: time
135
219
  version: '0'
136
220
  source:
137
221
  type: stdlib
222
+ - name: timeout
223
+ version: '0'
224
+ source:
225
+ type: stdlib
138
226
  - name: tsort
139
227
  version: '0'
140
228
  source:
141
229
  type: stdlib
230
+ - name: uri
231
+ version: '0'
232
+ source:
233
+ type: stdlib
142
234
  gemfile_lock_path: Gemfile.lock
data/rbs_collection.yaml CHANGED
@@ -16,3 +16,6 @@ path: .gem_rbs_collection
16
16
  gems:
17
17
  # Skip loading rbs gem's RBS.
18
18
  # It's unnecessary if you don't use rbs as a library.
19
+
20
+ - name: fileutils
21
+ - name: pathname
data/rbs_discard.gemspec CHANGED
@@ -29,7 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.require_paths = ["lib"]
30
30
 
31
31
  spec.add_dependency "discard"
32
- spec.add_dependency "rbs_rails"
32
+ spec.add_dependency "rails"
33
33
 
34
34
  # For more information and examples about making a new gem, check out our
35
35
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -12,7 +12,7 @@ module RbsDiscard
12
12
 
13
13
  private
14
14
 
15
- def klass_decl: () -> String
15
+ def format: (String rbs) -> String
16
16
  def header: () -> String
17
17
  def footer: () -> String
18
18
  end
@@ -0,0 +1,5 @@
1
+ class Thor
2
+ module Actions
3
+ def create_file: (String destination, *String? args, ?config: bool) ?{ () -> void } -> untyped
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_discard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
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-31 00:00:00.000000000 Z
11
+ date: 2023-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: discard
@@ -25,7 +25,7 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rbs_rails
28
+ name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -68,6 +68,7 @@ files:
68
68
  - sig/rbs_discard/rake_task.rbs
69
69
  - sig/shims/discard.rbs
70
70
  - sig/shims/rake.rbs
71
+ - sig/shims/thor.rbs
71
72
  homepage: https://github.com/tk0miya/rbs_discard
72
73
  licenses:
73
74
  - MIT