rbs_draper 0.1.3 → 1.0.0

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: 04a25d9a1afb7ef89b810010ec0d31ca211e130ebebee773dfb5e5268624ad99
4
- data.tar.gz: 97dc5e93239065b05cd1979623d99c40f4b530ac3b022a2d1d19d4b6c2b1948d
3
+ metadata.gz: 3ab0cf7b71bd6ed489df32f624962c6a8cb46e2fe3e05a6ce9a6864106465dde
4
+ data.tar.gz: 4f9db1dd8274da25ff5907544647ae9c4e8160fe5ed3fbb5aa6dd1a77ab0daba
5
5
  SHA512:
6
- metadata.gz: 8596d05ca36e6850e3f5c58620ea262a9a2561d6d350cfe3d1b56f83b071414faf9080cd37005c5ebddb80029421baf2fbdc6660821710eec296aa1628401d53
7
- data.tar.gz: c8b75eac9e00a7e3a51b0eabb2239182797ad86722d51f365c4943c4015d97f0493535f1ff3a014ce58fbeba274bb791e566513d684be65ff38d8042dfdc171b
6
+ metadata.gz: c12feee4cf6e98dbfa4e172f1e569f51ecc1cf163a8e26ddd08fb72a44e5de60beaf6f8469871a2752547765ea0506335977c8da0cdc6c532f8595649914eb50
7
+ data.tar.gz: 408294ee26cc2e601d40b035e6537cff035d46e6b2baf3422549665be48982a383d4cb0169d4bd5fe98cebd90bbaeac04f5f8b3b61a007948a5513203a000520
data/.rubocop.yml CHANGED
@@ -15,6 +15,9 @@ Style/StringLiteralsInInterpolation:
15
15
  Layout/LineLength:
16
16
  Max: 120
17
17
 
18
+ Metrics/AbcSize:
19
+ Max: 20
20
+
18
21
  Metrics/BlockLength:
19
22
  Exclude:
20
23
  - spec/**/*.rb
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "rubocop", "~> 1.55"
10
+ gem "rubocop", "~> 1.56"
11
11
 
12
12
  group :development do
13
13
  gem "rspec", require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_draper (0.1.3)
4
+ rbs_draper (1.0.0)
5
+ activesupport
5
6
  draper
6
7
  fileutils
7
8
  rbs
@@ -10,34 +11,35 @@ PATH
10
11
  GEM
11
12
  remote: https://rubygems.org/
12
13
  specs:
13
- actionpack (7.0.6)
14
- actionview (= 7.0.6)
15
- activesupport (= 7.0.6)
14
+ actionpack (7.0.7)
15
+ actionview (= 7.0.7)
16
+ activesupport (= 7.0.7)
16
17
  rack (~> 2.0, >= 2.2.4)
17
18
  rack-test (>= 0.6.3)
18
19
  rails-dom-testing (~> 2.0)
19
20
  rails-html-sanitizer (~> 1.0, >= 1.2.0)
20
- actionview (7.0.6)
21
- activesupport (= 7.0.6)
21
+ actionview (7.0.7)
22
+ activesupport (= 7.0.7)
22
23
  builder (~> 3.1)
23
24
  erubi (~> 1.4)
24
25
  rails-dom-testing (~> 2.0)
25
26
  rails-html-sanitizer (~> 1.1, >= 1.2.0)
26
- activemodel (7.0.6)
27
- activesupport (= 7.0.6)
27
+ activemodel (7.0.7)
28
+ activesupport (= 7.0.7)
28
29
  activemodel-serializers-xml (1.0.2)
29
30
  activemodel (> 5.x)
30
31
  activesupport (> 5.x)
31
32
  builder (~> 3.1)
32
- activerecord (7.0.6)
33
- activemodel (= 7.0.6)
34
- activesupport (= 7.0.6)
35
- activesupport (7.0.6)
33
+ activerecord (7.0.7)
34
+ activemodel (= 7.0.7)
35
+ activesupport (= 7.0.7)
36
+ activesupport (7.0.7)
36
37
  concurrent-ruby (~> 1.0, >= 1.0.2)
37
38
  i18n (>= 1.6, < 2)
38
39
  minitest (>= 5.1)
39
40
  tzinfo (~> 2.0)
40
41
  ast (2.4.2)
42
+ base64 (0.1.1)
41
43
  builder (3.2.4)
42
44
  coderay (1.1.3)
43
45
  concurrent-ruby (1.2.2)
@@ -67,9 +69,9 @@ GEM
67
69
  nokogiri (>= 1.12.0)
68
70
  method_source (1.0.0)
69
71
  minitest (5.19.0)
70
- nokogiri (1.15.2-x86_64-darwin)
72
+ nokogiri (1.15.4-x86_64-darwin)
71
73
  racc (~> 1.4)
72
- nokogiri (1.15.2-x86_64-linux)
74
+ nokogiri (1.15.4-x86_64-linux)
73
75
  racc (~> 1.4)
74
76
  parallel (1.23.0)
75
77
  parser (3.2.2.3)
@@ -79,19 +81,19 @@ GEM
79
81
  coderay (~> 1.1)
80
82
  method_source (~> 1.0)
81
83
  racc (1.7.1)
82
- rack (2.2.7)
84
+ rack (2.2.8)
83
85
  rack-test (2.1.0)
84
86
  rack (>= 1.3)
85
- rails-dom-testing (2.1.1)
87
+ rails-dom-testing (2.2.0)
86
88
  activesupport (>= 5.0.0)
87
89
  minitest
88
90
  nokogiri (>= 1.6)
89
91
  rails-html-sanitizer (1.6.0)
90
92
  loofah (~> 2.21)
91
93
  nokogiri (~> 1.14)
92
- railties (7.0.6)
93
- actionpack (= 7.0.6)
94
- activesupport (= 7.0.6)
94
+ railties (7.0.7)
95
+ actionpack (= 7.0.7)
96
+ activesupport (= 7.0.7)
95
97
  method_source
96
98
  rake (>= 12.2)
97
99
  thor (~> 1.0)
@@ -125,7 +127,8 @@ GEM
125
127
  diff-lcs (>= 1.2.0, < 2.0)
126
128
  rspec-support (~> 3.12.0)
127
129
  rspec-support (3.12.0)
128
- rubocop (1.55.0)
130
+ rubocop (1.56.0)
131
+ base64 (~> 0.1.1)
129
132
  json (~> 2.3)
130
133
  language_server-protocol (>= 3.17.0)
131
134
  parallel (~> 1.10)
@@ -141,7 +144,7 @@ GEM
141
144
  ruby-progressbar (1.13.0)
142
145
  ruby2_keywords (0.0.5)
143
146
  securerandom (0.2.2)
144
- steep (1.5.2)
147
+ steep (1.5.3)
145
148
  activesupport (>= 5.1)
146
149
  concurrent-ruby (>= 1.1.10)
147
150
  csv (>= 3.0.9)
@@ -163,7 +166,7 @@ GEM
163
166
  tzinfo (2.0.6)
164
167
  concurrent-ruby (~> 1.0)
165
168
  unicode-display_width (2.4.2)
166
- zeitwerk (2.6.8)
169
+ zeitwerk (2.6.11)
167
170
 
168
171
  PLATFORMS
169
172
  x86_64-darwin-19
@@ -177,7 +180,7 @@ DEPENDENCIES
177
180
  rbs_draper!
178
181
  rspec
179
182
  rspec-daemon
180
- rubocop (~> 1.55)
183
+ rubocop (~> 1.56)
181
184
  steep
182
185
 
183
186
  BUNDLED WITH
data/README.md CHANGED
@@ -7,19 +7,13 @@ rbs_draper is a generator for decorators using [Draper](https://github.com/drape
7
7
  Add a new entry to your Gemfile and run `bundle install`:
8
8
 
9
9
  group :development do
10
- gem 'rbs_draper'
10
+ gem 'rbs_draper', require: false
11
11
  end
12
12
 
13
13
  After the installation, please run rake task generator:
14
14
 
15
15
  bundle exec rails g rbs_draper:install
16
16
 
17
- Additionally, it would be better to add the following entry to your `rbs_collection.yml`:
18
-
19
- gems:
20
- - name: rbs_draper
21
- ignore: true
22
-
23
17
  ## Usage
24
18
 
25
19
  1. Run `rbs:draper:clean` at first
@@ -30,7 +30,7 @@ module RbsDraper
30
30
  def klass_decl
31
31
  <<~RBS
32
32
  #{header}
33
- def object: () -> #{klass.name.to_s.sub(/Decorator$/, "")}
33
+ #{object_method_decls}
34
34
 
35
35
  #{method_decls}
36
36
  #{footer}
@@ -57,6 +57,18 @@ module RbsDraper
57
57
  end.join("\n")
58
58
  end
59
59
 
60
+ def object_method_decls
61
+ object_name = klass_name.to_s.sub(/Decorator$/, "")
62
+ if object_name.include?("::")
63
+ "def object: () -> #{object_name}"
64
+ else
65
+ <<~RBS
66
+ def object: () -> #{object_name}
67
+ def #{object_name.underscore}: () -> #{object_name}
68
+ RBS
69
+ end
70
+ end
71
+
60
72
  def method_decls
61
73
  delegated_methods.filter_map do |name, method|
62
74
  next if user_defined_class&.methods&.fetch(name, nil)
@@ -43,6 +43,8 @@ module RbsDraper
43
43
  def define_base_class_generate_task
44
44
  desc "Generate RBS files for base classes"
45
45
  task("#{name}:base_class:generate": :environment) do
46
+ require "rbs_draper" # load RbsDraper lazily
47
+
46
48
  signature_root_dir.mkpath
47
49
 
48
50
  basedir = Pathname(__FILE__).dirname
@@ -54,6 +56,8 @@ module RbsDraper
54
56
  def define_decoratables_generate_task
55
57
  desc "Generate RBS files for decoratable models"
56
58
  task("#{name}:decoratables:generate": :environment) do
59
+ require "rbs_draper" # load RbsDraper lazily
60
+
57
61
  Rails.application.eager_load!
58
62
 
59
63
  RbsDraper::Decoratable.all.each do |klass|
@@ -1,5 +1,6 @@
1
1
  module Draper
2
2
  class Decorator
3
+ def self.delegate_all: () -> void
3
4
  def decorated?: () -> bool
4
5
  def decorated_with?: (untyped decorator_class) -> bool
5
6
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsDraper
4
- VERSION = "0.1.3"
4
+ VERSION = "1.0.0"
5
5
  end
@@ -2,7 +2,7 @@
2
2
  sources:
3
3
  - type: git
4
4
  name: ruby/gem_rbs_collection
5
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
5
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
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: 9612e5e67697153dcc7464c01115db44d29b1e34
19
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
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: 9612e5e67697153dcc7464c01115db44d29b1e34
27
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
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: 9612e5e67697153dcc7464c01115db44d29b1e34
35
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
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: 9612e5e67697153dcc7464c01115db44d29b1e34
43
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
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: 9612e5e67697153dcc7464c01115db44d29b1e34
51
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
52
52
  remote: https://github.com/ruby/gem_rbs_collection.git
53
53
  repo_dir: gems
54
54
  - name: ast
@@ -56,9 +56,13 @@ gems:
56
56
  source:
57
57
  type: git
58
58
  name: ruby/gem_rbs_collection
59
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
59
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
60
60
  remote: https://github.com/ruby/gem_rbs_collection.git
61
61
  repo_dir: gems
62
+ - name: base64
63
+ version: '0'
64
+ source:
65
+ type: stdlib
62
66
  - name: cgi
63
67
  version: '0'
64
68
  source:
@@ -68,7 +72,7 @@ gems:
68
72
  source:
69
73
  type: git
70
74
  name: ruby/gem_rbs_collection
71
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
75
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
72
76
  remote: https://github.com/ruby/gem_rbs_collection.git
73
77
  repo_dir: gems
74
78
  - name: date
@@ -84,7 +88,7 @@ gems:
84
88
  source:
85
89
  type: git
86
90
  name: ruby/gem_rbs_collection
87
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
91
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
88
92
  remote: https://github.com/ruby/gem_rbs_collection.git
89
93
  repo_dir: gems
90
94
  - name: json
@@ -112,7 +116,7 @@ gems:
112
116
  source:
113
117
  type: git
114
118
  name: ruby/gem_rbs_collection
115
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
119
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
116
120
  remote: https://github.com/ruby/gem_rbs_collection.git
117
121
  repo_dir: gems
118
122
  - name: optparse
@@ -124,7 +128,7 @@ gems:
124
128
  source:
125
129
  type: git
126
130
  name: ruby/gem_rbs_collection
127
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
131
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
128
132
  remote: https://github.com/ruby/gem_rbs_collection.git
129
133
  repo_dir: gems
130
134
  - name: pathname
@@ -136,7 +140,7 @@ gems:
136
140
  source:
137
141
  type: git
138
142
  name: ruby/gem_rbs_collection
139
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
143
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
140
144
  remote: https://github.com/ruby/gem_rbs_collection.git
141
145
  repo_dir: gems
142
146
  - name: rails-dom-testing
@@ -144,7 +148,7 @@ gems:
144
148
  source:
145
149
  type: git
146
150
  name: ruby/gem_rbs_collection
147
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
151
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
148
152
  remote: https://github.com/ruby/gem_rbs_collection.git
149
153
  repo_dir: gems
150
154
  - name: railties
@@ -152,7 +156,7 @@ gems:
152
156
  source:
153
157
  type: git
154
158
  name: ruby/gem_rbs_collection
155
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
159
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
156
160
  remote: https://github.com/ruby/gem_rbs_collection.git
157
161
  repo_dir: gems
158
162
  - name: rainbow
@@ -160,7 +164,7 @@ gems:
160
164
  source:
161
165
  type: git
162
166
  name: ruby/gem_rbs_collection
163
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
167
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
164
168
  remote: https://github.com/ruby/gem_rbs_collection.git
165
169
  repo_dir: gems
166
170
  - name: rbs
@@ -180,7 +184,7 @@ gems:
180
184
  source:
181
185
  type: git
182
186
  name: ruby/gem_rbs_collection
183
- revision: 9612e5e67697153dcc7464c01115db44d29b1e34
187
+ revision: a4c633634493ab7ae73219022f56acff56ab69af
184
188
  remote: https://github.com/ruby/gem_rbs_collection.git
185
189
  repo_dir: gems
186
190
  - name: securerandom
data/rbs_draper.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
+ spec.add_dependency "activesupport"
30
31
  spec.add_dependency "draper"
31
32
  spec.add_dependency "fileutils"
32
33
  spec.add_dependency "rbs"
@@ -17,6 +17,7 @@ module RbsDraper
17
17
 
18
18
  def klass_decl: () -> String
19
19
  def header: () -> String
20
+ def object_method_decls: () -> String
20
21
  def method_decls: () -> String?
21
22
  def footer: () -> String
22
23
  def module_names: () -> Array[String]
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 1.0.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-08-02 00:00:00.000000000 Z
11
+ date: 2023-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: draper
15
29
  requirement: !ruby/object:Gem::Requirement