rbs_draper 0.1.3 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +26 -23
- data/README.md +6 -5
- data/lib/generators/rbs_draper/install_generator.rb +7 -1
- data/lib/rbs_draper/decorator.rb +24 -10
- data/lib/rbs_draper/rake_task.rb +8 -2
- data/lib/rbs_draper/sig/decorator.rbs +1 -0
- data/lib/rbs_draper/version.rb +1 -1
- data/rbs_collection.lock.yaml +20 -16
- data/rbs_draper.gemspec +1 -0
- data/sig/rbs_draper/decorator.rbs +6 -4
- data/sig/rbs_draper/rake_task.rbs +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4264323a47d34195f99e7e52dfed772f191d1c1b6ff2b67aea3ae8bebcc2c207
|
4
|
+
data.tar.gz: 884b7eb9869e61ab465d63ac2f5878226491bbd40b7612a6bf9dae071d1a16c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4489ad1ad8ae877970dfae0d89ae95466aa5796cedb4fa0b9af95be5fed7fc0096b6ca0266c0d1e0ef660ed80394865c19f44f7f74f338919d52a99af60e4ac
|
7
|
+
data.tar.gz: 9130a8eaa678d68be89334e8927c06f9d18a6356fb85cbf3fcd237eace146a3a4326a3b07792978f833988fd555542af307b486d1caf99c022c91a709ed7491e
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs_draper (
|
4
|
+
rbs_draper (1.1.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.
|
14
|
-
actionview (= 7.0.
|
15
|
-
activesupport (= 7.0.
|
14
|
+
actionpack (7.0.7.2)
|
15
|
+
actionview (= 7.0.7.2)
|
16
|
+
activesupport (= 7.0.7.2)
|
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.
|
21
|
-
activesupport (= 7.0.
|
21
|
+
actionview (7.0.7.2)
|
22
|
+
activesupport (= 7.0.7.2)
|
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.
|
27
|
-
activesupport (= 7.0.
|
27
|
+
activemodel (7.0.7.2)
|
28
|
+
activesupport (= 7.0.7.2)
|
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.
|
33
|
-
activemodel (= 7.0.
|
34
|
-
activesupport (= 7.0.
|
35
|
-
activesupport (7.0.
|
33
|
+
activerecord (7.0.7.2)
|
34
|
+
activemodel (= 7.0.7.2)
|
35
|
+
activesupport (= 7.0.7.2)
|
36
|
+
activesupport (7.0.7.2)
|
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.
|
72
|
+
nokogiri (1.15.4-x86_64-darwin)
|
71
73
|
racc (~> 1.4)
|
72
|
-
nokogiri (1.15.
|
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.
|
84
|
+
rack (2.2.8)
|
83
85
|
rack-test (2.1.0)
|
84
86
|
rack (>= 1.3)
|
85
|
-
rails-dom-testing (2.
|
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.
|
93
|
-
actionpack (= 7.0.
|
94
|
-
activesupport (= 7.0.
|
94
|
+
railties (7.0.7.2)
|
95
|
+
actionpack (= 7.0.7.2)
|
96
|
+
activesupport (= 7.0.7.2)
|
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.
|
130
|
+
rubocop (1.56.1)
|
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.
|
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.
|
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.
|
183
|
+
rubocop (~> 1.56)
|
181
184
|
steep
|
182
185
|
|
183
186
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -7,18 +7,19 @@ 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
|
-
|
17
|
+
If you have decorators having different names from models, you can specify the mapping from
|
18
|
+
decorator names to model names in `lib/tasks/rbs_draper.rake`. For example:
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
RbsDraper::RakeTask.new do |task|
|
21
|
+
task.mapping = -> { { AdminUserDecorator: User } }
|
22
|
+
end
|
22
23
|
|
23
24
|
## Usage
|
24
25
|
|
@@ -8,7 +8,13 @@ module RbsDraper
|
|
8
8
|
create_file "lib/tasks/rbs_draper.rake", <<~RUBY
|
9
9
|
begin
|
10
10
|
require 'rbs_draper/rake_task'
|
11
|
-
|
11
|
+
|
12
|
+
RbsDraper::RakeTask.new do |task|
|
13
|
+
# If you have decorators having different names from models, you can specify the mapping from decorator names to model names.
|
14
|
+
# The value should be a lambda that returns a hash to load decorators and models easily.
|
15
|
+
#
|
16
|
+
# task.mapping = -> { { AdminUserDecorator: User } }
|
17
|
+
end
|
12
18
|
rescue LoadError
|
13
19
|
# failed to load rbs_draper. Skip to load rbs_draper tasks.
|
14
20
|
end
|
data/lib/rbs_draper/decorator.rb
CHANGED
@@ -6,21 +6,22 @@ require "rbs_rails"
|
|
6
6
|
|
7
7
|
module RbsDraper
|
8
8
|
module Decorator
|
9
|
-
def self.class_to_rbs(klass, rbs_builder)
|
10
|
-
Generator.new(klass, rbs_builder).generate
|
9
|
+
def self.class_to_rbs(klass, rbs_builder, decorated_class: nil)
|
10
|
+
Generator.new(klass, rbs_builder, decorated_class: decorated_class).generate
|
11
11
|
end
|
12
12
|
|
13
13
|
class Generator
|
14
|
-
attr_reader :klass, :klass_name, :rbs_builder
|
14
|
+
attr_reader :klass, :klass_name, :rbs_builder, :decorated_class
|
15
15
|
|
16
|
-
def initialize(klass, rbs_builder)
|
16
|
+
def initialize(klass, rbs_builder, decorated_class: nil)
|
17
17
|
@klass = klass
|
18
18
|
@klass_name = RbsRails::Util.module_name(klass)
|
19
19
|
@rbs_builder = rbs_builder
|
20
|
+
@decorated_class = decorated_class
|
20
21
|
end
|
21
22
|
|
22
23
|
def generate
|
23
|
-
return if
|
24
|
+
return if decorated_class_def.blank?
|
24
25
|
|
25
26
|
RbsRails::Util.format_rbs klass_decl
|
26
27
|
end
|
@@ -30,7 +31,7 @@ module RbsDraper
|
|
30
31
|
def klass_decl
|
31
32
|
<<~RBS
|
32
33
|
#{header}
|
33
|
-
|
34
|
+
#{object_method_decls}
|
34
35
|
|
35
36
|
#{method_decls}
|
36
37
|
#{footer}
|
@@ -57,6 +58,18 @@ module RbsDraper
|
|
57
58
|
end.join("\n")
|
58
59
|
end
|
59
60
|
|
61
|
+
def object_method_decls
|
62
|
+
object_name = decorated_class&.name || klass.name.to_s.sub(/Decorator$/, "")
|
63
|
+
if object_name.include?("::")
|
64
|
+
"def object: () -> #{object_name}"
|
65
|
+
else
|
66
|
+
<<~RBS
|
67
|
+
def object: () -> #{object_name}
|
68
|
+
def #{object_name.underscore}: () -> #{object_name}
|
69
|
+
RBS
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
60
73
|
def method_decls
|
61
74
|
delegated_methods.filter_map do |name, method|
|
62
75
|
next if user_defined_class&.methods&.fetch(name, nil)
|
@@ -75,9 +88,10 @@ module RbsDraper
|
|
75
88
|
end
|
76
89
|
end
|
77
90
|
|
78
|
-
def
|
79
|
-
|
80
|
-
|
91
|
+
def decorated_class_def
|
92
|
+
class_name = decorated_class&.name || klass.name.to_s.sub(/Decorator$/, "")
|
93
|
+
type_name = RBS::TypeName(class_name).absolute!
|
94
|
+
@decorated_class_def ||= rbs_builder.build_instance(type_name)
|
81
95
|
rescue StandardError
|
82
96
|
nil
|
83
97
|
end
|
@@ -85,7 +99,7 @@ module RbsDraper
|
|
85
99
|
def delegated_methods
|
86
100
|
return [] unless klass.ancestors.include? ::Draper::AutomaticDelegation
|
87
101
|
|
88
|
-
decorated_klass =
|
102
|
+
decorated_klass = decorated_class_def
|
89
103
|
return [] unless decorated_klass
|
90
104
|
|
91
105
|
decorated_klass.methods.keys.sort.filter_map do |name|
|
data/lib/rbs_draper/rake_task.rb
CHANGED
@@ -8,13 +8,14 @@ require "rake/tasklib"
|
|
8
8
|
|
9
9
|
module RbsDraper
|
10
10
|
class RakeTask < Rake::TaskLib
|
11
|
-
attr_accessor :name, :signature_root_dir
|
11
|
+
attr_accessor :name, :signature_root_dir, :mapping
|
12
12
|
|
13
13
|
def initialize(name = :'rbs:draper', &block)
|
14
14
|
super()
|
15
15
|
|
16
16
|
@name = name
|
17
17
|
@signature_root_dir = Pathname(Rails.root / "sig/draper")
|
18
|
+
@mapping = -> { {} }
|
18
19
|
|
19
20
|
block&.call(self)
|
20
21
|
|
@@ -43,6 +44,8 @@ module RbsDraper
|
|
43
44
|
def define_base_class_generate_task
|
44
45
|
desc "Generate RBS files for base classes"
|
45
46
|
task("#{name}:base_class:generate": :environment) do
|
47
|
+
require "rbs_draper" # load RbsDraper lazily
|
48
|
+
|
46
49
|
signature_root_dir.mkpath
|
47
50
|
|
48
51
|
basedir = Pathname(__FILE__).dirname
|
@@ -54,6 +57,8 @@ module RbsDraper
|
|
54
57
|
def define_decoratables_generate_task
|
55
58
|
desc "Generate RBS files for decoratable models"
|
56
59
|
task("#{name}:decoratables:generate": :environment) do
|
60
|
+
require "rbs_draper" # load RbsDraper lazily
|
61
|
+
|
57
62
|
Rails.application.eager_load!
|
58
63
|
|
59
64
|
RbsDraper::Decoratable.all.each do |klass|
|
@@ -70,10 +75,11 @@ module RbsDraper
|
|
70
75
|
task("#{name}:decorators:generate": :environment) do
|
71
76
|
Rails.application.eager_load!
|
72
77
|
|
78
|
+
decorated_classes = mapping.call
|
73
79
|
Draper::Decorator.descendants.each do |klass|
|
74
80
|
path = signature_root_dir / "app/decorators/#{klass.name.underscore}.rbs"
|
75
81
|
path.dirname.mkpath
|
76
|
-
rbs = RbsDraper::Decorator.class_to_rbs(klass, rbs_builder)
|
82
|
+
rbs = RbsDraper::Decorator.class_to_rbs(klass, rbs_builder, decorated_class: decorated_classes[klass])
|
77
83
|
path.write rbs if rbs
|
78
84
|
end
|
79
85
|
end
|
data/lib/rbs_draper/version.rb
CHANGED
data/rbs_collection.lock.yaml
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
sources:
|
3
3
|
- type: git
|
4
4
|
name: ruby/gem_rbs_collection
|
5
|
-
revision:
|
5
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
19
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
27
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
35
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
43
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
51
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
59
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
75
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
91
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
119
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
131
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
143
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
151
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
159
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
167
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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:
|
187
|
+
revision: 306d1aec19defeb177e217d8aad9812a52bcd5eb
|
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"
|
@@ -1,26 +1,28 @@
|
|
1
1
|
module RbsDraper
|
2
2
|
module Decorator
|
3
|
-
def self.class_to_rbs: (singleton(Draper::Decorator) klass, RBS::DefinitionBuilder rbs_builder) -> String?
|
3
|
+
def self.class_to_rbs: (singleton(Draper::Decorator) klass, RBS::DefinitionBuilder rbs_builder, ?decorated_class: singleton(Class)?) -> String?
|
4
4
|
|
5
5
|
class Generator
|
6
6
|
attr_reader klass: singleton(Draper::Decorator)
|
7
7
|
attr_reader klass_name: String
|
8
8
|
attr_reader rbs_builder: RBS::DefinitionBuilder
|
9
|
+
attr_reader decorated_class: singleton(Class)?
|
9
10
|
|
10
|
-
@
|
11
|
+
@decorated_class_def: RBS::Definition
|
11
12
|
@user_defined_class: RBS::Definition
|
12
13
|
|
13
|
-
def initialize: (singleton(Draper::Decorator) klass, RBS::DefinitionBuilder rbs_builder) -> void
|
14
|
+
def initialize: (singleton(Draper::Decorator) klass, RBS::DefinitionBuilder rbs_builder, ?decorated_class: singleton(Class)?) -> void
|
14
15
|
def generate: () -> String?
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def klass_decl: () -> String
|
19
20
|
def header: () -> String
|
21
|
+
def object_method_decls: () -> String
|
20
22
|
def method_decls: () -> String?
|
21
23
|
def footer: () -> String
|
22
24
|
def module_names: () -> Array[String]
|
23
|
-
def
|
25
|
+
def decorated_class_def: () -> RBS::Definition?
|
24
26
|
def delegated_methods: () -> Array[[Symbol, RBS::Definition::Method]]
|
25
27
|
def user_defined_class: () -> RBS::Definition?
|
26
28
|
end
|
@@ -2,10 +2,12 @@ module RbsDraper
|
|
2
2
|
class RakeTask < Rake::TaskLib
|
3
3
|
attr_accessor name: Symbol
|
4
4
|
attr_accessor signature_root_dir: Pathname
|
5
|
+
attr_accessor mapping: ^() -> Hash[singleton(Class), singleton(Class)]
|
5
6
|
|
6
7
|
@name: Symbol
|
7
8
|
@rbs_builder: RBS::DefinitionBuilder
|
8
9
|
@signature_root_dir: Pathname
|
10
|
+
@mapping: ^() -> Hash[singleton(Class), singleton(Class)]
|
9
11
|
|
10
12
|
def initialize: (?Symbol name) ?{ (RakeTask) -> void } -> void
|
11
13
|
def define_setup_task: () -> void
|
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:
|
4
|
+
version: 1.1.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-
|
11
|
+
date: 2023-09-02 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
|