rbs_draper 0.1.1 → 0.1.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: 8c95d27feecc3c5d521e7a613fe3a9e076e90953f2d0f4f3b639b99d1fe4f48d
4
- data.tar.gz: 258c93e835b97785036a214987fb2f91df8186f9f1164ec902b9a06ba0ee919d
3
+ metadata.gz: 7d2bfcf84e0f5af5a65871e40710100241df8232a871e7794f3f52be4637f41a
4
+ data.tar.gz: 3402cdab07e8e6b782c8230108232dfc60f3ab3b719ba3f160b9158c32237f49
5
5
  SHA512:
6
- metadata.gz: 790e0ecb25f3bd26233990ff3bd8e71bfe25a0276f60401d5ebe52d205daf7ad9e0a88ca3234e2d752c29e3d2d30dc7821df67136fbf60747a96f28425ddab9e
7
- data.tar.gz: 14aa193094bf45c5ace190831b9c6bacadd24e898462d8e6dbf286f8de80016ddf92813f7101d2fd950bd8e2d492203c5dbfdb20bf1149658304caa243fcb79b
6
+ metadata.gz: 236ba1a705da99b87bbeb5bf3eab2df035cf1701a390fb3b70db428529e052613b75123ccde23f06b1c40056443cc7043defa06c58ff32621aba59d7e54b3aab
7
+ data.tar.gz: 5ed785300e261837ab808217eeca0a0a438cbd3d07b2bd8c3dc70632b56ff53e7f0db552745e76d5f93e88e907e4e3fddbc20fc22f393d56ad00403118f6751b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_draper (0.1.1)
4
+ rbs_draper (0.1.2)
5
5
  draper
6
6
  rbs_rails
7
7
 
@@ -18,10 +18,11 @@ module RbsDraper
18
18
  end
19
19
 
20
20
  class Generator
21
- attr_reader :klass
21
+ attr_reader :klass, :klass_name
22
22
 
23
23
  def initialize(klass)
24
24
  @klass = klass
25
+ @klass_name = RbsRails::Util.module_name(klass)
25
26
  end
26
27
 
27
28
  def generate
@@ -39,16 +40,23 @@ module RbsDraper
39
40
  end
40
41
 
41
42
  def header
42
- module_defs = module_names.map { |module_name| "module #{module_name}" }
43
+ namespace = +""
44
+ klass_name.split("::").map do |mod_name|
45
+ namespace += "::#{mod_name}"
46
+ mod_object = Object.const_get(namespace)
47
+ case mod_object
48
+ when Class
49
+ # @type var superclass: Class
50
+ superclass = _ = mod_object.superclass
51
+ superclass_name = RbsRails::Util.module_name(superclass)
43
52
 
44
- class_name = klass.name.split("::").last
45
- class_def = if klass.superclass
46
- "class #{class_name} < #{klass.superclass}"
47
- else
48
- "class #{class_name}"
49
- end
50
-
51
- (module_defs + [class_def]).join("\n")
53
+ "class #{mod_name} < ::#{superclass_name}"
54
+ when Module
55
+ "module #{mod_name}"
56
+ else
57
+ raise "unreachable"
58
+ end
59
+ end.join("\n")
52
60
  end
53
61
 
54
62
  def method_decls
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsDraper
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
@@ -5,6 +5,7 @@ module RbsDraper
5
5
 
6
6
  class Generator
7
7
  attr_reader klass: Class
8
+ attr_reader klass_name: String
8
9
 
9
10
  def initialize: (Class klass) -> void
10
11
  def generate: () -> String
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takeshi KOMIYA