rbs_discard 0.1.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: bb5871880723cc38c79cb94b0cb842970fd73f2774868bf15c26891d1ba1bee9
4
- data.tar.gz: 992f1729ee3c71fb446fcbb5fc6f2d5edbdc62bf0166ac26d7bcb3d578c7192a
3
+ metadata.gz: 7487ba958cc9bb1f8dbe5cdc7c574858497f86e413a1581fc757663dd0139958
4
+ data.tar.gz: 9709aec5f69db36c2f1029e36cfa1b2fbeb12dea5fbe2caa877ccf5c43682543
5
5
  SHA512:
6
- metadata.gz: f2640c58ca91c63ecffb863af1061346a05872b53e7667cab85655a74770f1530dfecfbc1aefa25c980d2402fa1184ba5dc0e8a28e3653fc178b83019b5446f6
7
- data.tar.gz: 03d9a68fa4e0de5851a449591fb7558fdb793eea891a98267b48b736e9dec5a741002194594a8450825c2d97644d20ace7d9bc84439033d4c3ad6c4749376494
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,8 +1,10 @@
1
1
  module Discard
2
2
  module Model
3
3
  module ClassMethods
4
- def before_discard: (*untyped) ? { () -> void } -> void
5
- def after_discard: (*untyped) ? { () -> void } -> void
4
+ type callback = Symbol | ^() [self: instance] -> void
5
+
6
+ def before_discard: (*callback) ? { () [self: instance] -> void } -> void
7
+ def after_discard: (*callback) ? { () [self: instance] -> void } -> void
6
8
  def discard_all: () -> void
7
9
  def discard_all!: () -> void
8
10
  def undiscard_all: () -> void
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsDiscard
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.1"
5
5
  end
@@ -2,17 +2,49 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: a4c633634493ab7ae73219022f56acff56ab69af
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: actionmailer
11
+ version: '7.0'
12
+ source:
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
10
42
  - name: activemodel
11
43
  version: '7.0'
12
44
  source:
13
45
  type: git
14
46
  name: ruby/gem_rbs_collection
15
- revision: a4c633634493ab7ae73219022f56acff56ab69af
47
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
16
48
  remote: https://github.com/ruby/gem_rbs_collection.git
17
49
  repo_dir: gems
18
50
  - name: activerecord
@@ -20,7 +52,15 @@ gems:
20
52
  source:
21
53
  type: git
22
54
  name: ruby/gem_rbs_collection
23
- revision: a4c633634493ab7ae73219022f56acff56ab69af
55
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
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
24
64
  remote: https://github.com/ruby/gem_rbs_collection.git
25
65
  repo_dir: gems
26
66
  - name: activesupport
@@ -28,7 +68,7 @@ gems:
28
68
  source:
29
69
  type: git
30
70
  name: ruby/gem_rbs_collection
31
- revision: a4c633634493ab7ae73219022f56acff56ab69af
71
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
32
72
  remote: https://github.com/ruby/gem_rbs_collection.git
33
73
  repo_dir: gems
34
74
  - name: ast
@@ -36,31 +76,47 @@ gems:
36
76
  source:
37
77
  type: git
38
78
  name: ruby/gem_rbs_collection
39
- revision: a4c633634493ab7ae73219022f56acff56ab69af
79
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
40
80
  remote: https://github.com/ruby/gem_rbs_collection.git
41
81
  repo_dir: gems
42
82
  - name: base64
43
83
  version: '0'
44
84
  source:
45
85
  type: stdlib
86
+ - name: cgi
87
+ version: '0'
88
+ source:
89
+ type: stdlib
46
90
  - name: concurrent-ruby
47
91
  version: '1.1'
48
92
  source:
49
93
  type: git
50
94
  name: ruby/gem_rbs_collection
51
- revision: a4c633634493ab7ae73219022f56acff56ab69af
95
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
52
96
  remote: https://github.com/ruby/gem_rbs_collection.git
53
97
  repo_dir: gems
54
98
  - name: date
55
99
  version: '0'
56
100
  source:
57
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
58
114
  - name: i18n
59
115
  version: '1.10'
60
116
  source:
61
117
  type: git
62
118
  name: ruby/gem_rbs_collection
63
- revision: a4c633634493ab7ae73219022f56acff56ab69af
119
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
64
120
  remote: https://github.com/ruby/gem_rbs_collection.git
65
121
  repo_dir: gems
66
122
  - name: json
@@ -71,6 +127,14 @@ gems:
71
127
  version: '0'
72
128
  source:
73
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
74
138
  - name: minitest
75
139
  version: '0'
76
140
  source:
@@ -83,12 +147,48 @@ gems:
83
147
  version: '0'
84
148
  source:
85
149
  type: stdlib
150
+ - name: nokogiri
151
+ version: '1.11'
152
+ source:
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
86
158
  - name: parallel
87
159
  version: '1.20'
88
160
  source:
89
161
  type: git
90
162
  name: ruby/gem_rbs_collection
91
- revision: a4c633634493ab7ae73219022f56acff56ab69af
163
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
164
+ remote: https://github.com/ruby/gem_rbs_collection.git
165
+ repo_dir: gems
166
+ - name: pathname
167
+ version: '0'
168
+ source:
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
92
192
  remote: https://github.com/ruby/gem_rbs_collection.git
93
193
  repo_dir: gems
94
194
  - name: rainbow
@@ -96,7 +196,7 @@ gems:
96
196
  source:
97
197
  type: git
98
198
  name: ruby/gem_rbs_collection
99
- revision: a4c633634493ab7ae73219022f56acff56ab69af
199
+ revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
100
200
  remote: https://github.com/ruby/gem_rbs_collection.git
101
201
  repo_dir: gems
102
202
  - name: securerandom
@@ -107,8 +207,24 @@ gems:
107
207
  version: '0'
108
208
  source:
109
209
  type: stdlib
210
+ - name: tempfile
211
+ version: '0'
212
+ source:
213
+ type: stdlib
110
214
  - name: time
111
215
  version: '0'
112
216
  source:
113
217
  type: stdlib
218
+ - name: timeout
219
+ version: '0'
220
+ source:
221
+ type: stdlib
222
+ - name: tsort
223
+ version: '0'
224
+ source:
225
+ type: stdlib
226
+ - name: uri
227
+ version: '0'
228
+ source:
229
+ type: stdlib
114
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.1.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-27 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