rbs_discard 0.2.0 → 0.2.1

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: 7487ba958cc9bb1f8dbe5cdc7c574858497f86e413a1581fc757663dd0139958
4
+ data.tar.gz: 9709aec5f69db36c2f1029e36cfa1b2fbeb12dea5fbe2caa877ccf5c43682543
5
5
  SHA512:
6
- metadata.gz: a28c5d18e7b896db467807782fce14e83b19a81f0f49b7f224765fa99eaea96af5b446e41ca98c3dd8bfd638706e6a7222cf29ec0fbaa4281c8b0d93632cffd5
7
- data.tar.gz: c8c8767266fa7be7da5d53cb78554dbe339d4db9d19da69e598586dba76c9a56311f4bce55e677c39d96932761cb2a6de5ad84102651225756061f61fe78c8b6
6
+ metadata.gz: ae83684d280146625a7f62d61e235221780bc873d253580f5cdffced0bb57b29a6d950ed5c208abbd2867775d0ed45a3b7248a0d8ce4659bffee9f964a7c94f3
7
+ data.tar.gz: ff2467e246fd48a46ec033cec33c38d1daaa9deb5b7f1d4978a4df87b9b398b76ebf92fcdd3dd02e5ce4a84ec05a5e914a406a7d09dd2bba9bfdc9008f5ed93a
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 "activesupport"
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.1"
5
5
  end
@@ -2,15 +2,43 @@
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:
@@ -27,6 +55,14 @@ gems:
27
55
  revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
28
56
  remote: https://github.com/ruby/gem_rbs_collection.git
29
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
64
+ remote: https://github.com/ruby/gem_rbs_collection.git
65
+ repo_dir: gems
30
66
  - name: activesupport
31
67
  version: '7.0'
32
68
  source:
@@ -47,6 +83,10 @@ gems:
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:
@@ -59,6 +99,18 @@ gems:
59
99
  version: '0'
60
100
  source:
61
101
  type: stdlib
102
+ - name: fileutils
103
+ version: '0'
104
+ source:
105
+ type: stdlib
106
+ - name: globalid
107
+ version: '1.1'
108
+ source:
109
+ type: git
110
+ name: ruby/gem_rbs_collection
111
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
112
+ remote: https://github.com/ruby/gem_rbs_collection.git
113
+ repo_dir: gems
62
114
  - name: i18n
63
115
  version: '1.10'
64
116
  source:
@@ -75,6 +127,14 @@ gems:
75
127
  version: '0'
76
128
  source:
77
129
  type: stdlib
130
+ - name: mail
131
+ version: '2.8'
132
+ source:
133
+ type: git
134
+ name: ruby/gem_rbs_collection
135
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
136
+ remote: https://github.com/ruby/gem_rbs_collection.git
137
+ repo_dir: gems
78
138
  - name: minitest
79
139
  version: '0'
80
140
  source:
@@ -87,10 +147,14 @@ gems:
87
147
  version: '0'
88
148
  source:
89
149
  type: stdlib
90
- - name: optparse
91
- version: '0'
150
+ - name: nokogiri
151
+ version: '1.11'
92
152
  source:
93
- type: stdlib
153
+ type: git
154
+ name: ruby/gem_rbs_collection
155
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
156
+ remote: https://github.com/ruby/gem_rbs_collection.git
157
+ repo_dir: gems
94
158
  - name: parallel
95
159
  version: '1.20'
96
160
  source:
@@ -103,6 +167,30 @@ gems:
103
167
  version: '0'
104
168
  source:
105
169
  type: stdlib
170
+ - name: rack
171
+ version: '2.2'
172
+ source:
173
+ type: git
174
+ name: ruby/gem_rbs_collection
175
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
176
+ remote: https://github.com/ruby/gem_rbs_collection.git
177
+ repo_dir: gems
178
+ - name: rails-dom-testing
179
+ version: '2.0'
180
+ source:
181
+ type: git
182
+ name: ruby/gem_rbs_collection
183
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
184
+ remote: https://github.com/ruby/gem_rbs_collection.git
185
+ repo_dir: gems
186
+ - name: railties
187
+ version: '6.0'
188
+ source:
189
+ type: git
190
+ name: ruby/gem_rbs_collection
191
+ revision: 5666e737d2b27a8425b4e3855c1a38cae54989f7
192
+ remote: https://github.com/ruby/gem_rbs_collection.git
193
+ repo_dir: gems
106
194
  - name: rainbow
107
195
  version: '3.0'
108
196
  source:
@@ -111,23 +199,15 @@ gems:
111
199
  revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
112
200
  remote: https://github.com/ruby/gem_rbs_collection.git
113
201
  repo_dir: gems
114
- - name: rbs
115
- version: 3.2.0
116
- source:
117
- type: rubygems
118
- - name: rbs_rails
119
- version: 0.12.0
120
- source:
121
- type: rubygems
122
- - name: rdoc
202
+ - name: securerandom
123
203
  version: '0'
124
204
  source:
125
205
  type: stdlib
126
- - name: securerandom
206
+ - name: singleton
127
207
  version: '0'
128
208
  source:
129
209
  type: stdlib
130
- - name: singleton
210
+ - name: tempfile
131
211
  version: '0'
132
212
  source:
133
213
  type: stdlib
@@ -135,8 +215,16 @@ gems:
135
215
  version: '0'
136
216
  source:
137
217
  type: stdlib
218
+ - name: timeout
219
+ version: '0'
220
+ source:
221
+ type: stdlib
138
222
  - name: tsort
139
223
  version: '0'
140
224
  source:
141
225
  type: stdlib
226
+ - name: uri
227
+ version: '0'
228
+ source:
229
+ type: stdlib
142
230
  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.1
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-02 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