rbs_draper 0.1.0 → 0.1.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: 2e6df474118e1aa1523fc02aa5fd55e15d4c329ce9503147e2f252b69dc3656e
4
- data.tar.gz: 78da07e88141b84609208766a4b270548da02964b313d2d462529c5afae9441a
3
+ metadata.gz: 8c95d27feecc3c5d521e7a613fe3a9e076e90953f2d0f4f3b639b99d1fe4f48d
4
+ data.tar.gz: 258c93e835b97785036a214987fb2f91df8186f9f1164ec902b9a06ba0ee919d
5
5
  SHA512:
6
- metadata.gz: e1774f4eebbc89a4092d0c3b1e38e53886a1740d5bb6ac275f31ed48db0c28e1847746ce22080844d18c96b6173d2355dc87a60267abef9020d25d29c1346d0f
7
- data.tar.gz: 68837472313ad5112d16741a02048dd8484d38b7a10c0aaabcdf437289f521a9834bbe4b207d67021b6a7884b9d9fd1e841d449565e51a7390c4912a49c391b4
6
+ metadata.gz: 790e0ecb25f3bd26233990ff3bd8e71bfe25a0276f60401d5ebe52d205daf7ad9e0a88ca3234e2d752c29e3d2d30dc7821df67136fbf60747a96f28425ddab9e
7
+ data.tar.gz: 14aa193094bf45c5ace190831b9c6bacadd24e898462d8e6dbf286f8de80016ddf92813f7101d2fd950bd8e2d492203c5dbfdb20bf1149658304caa243fcb79b
data/.rubocop.yml CHANGED
@@ -18,3 +18,6 @@ Layout/LineLength:
18
18
  Metrics/BlockLength:
19
19
  Exclude:
20
20
  - spec/**/*.rb
21
+
22
+ Metrics/MethodLength:
23
+ Max: 20
@@ -2,6 +2,7 @@
2
2
  "recommendations": [
3
3
  "shopify.ruby-lsp",
4
4
  "soutaro.steep-vscode",
5
- "tk0miya.rspec-daemon"
5
+ "tk0miya.rspec-daemon",
6
+ "tk0miya.rbs-helper"
6
7
  ]
7
8
  }
@@ -1,5 +1,6 @@
1
1
  {
2
2
  "[ruby]": {
3
3
  "editor.defaultFormatter": "Shopify.ruby-lsp"
4
- }
4
+ },
5
+ "rbs-helper.signature-directory": "sig"
5
6
  }
data/Gemfile CHANGED
@@ -7,7 +7,7 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "rubocop", "~> 1.21"
10
+ gem "rubocop", "~> 1.52"
11
11
 
12
12
  group :development do
13
13
  gem "rspec", require: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs_draper (0.1.0)
4
+ rbs_draper (0.1.1)
5
5
  draper
6
6
  rbs_rails
7
7
 
@@ -76,7 +76,7 @@ GEM
76
76
  pry (0.14.2)
77
77
  coderay (~> 1.1)
78
78
  method_source (~> 1.0)
79
- racc (1.7.0)
79
+ racc (1.7.1)
80
80
  rack (2.2.7)
81
81
  rack-test (2.1.0)
82
82
  rack (>= 1.3)
@@ -122,10 +122,10 @@ GEM
122
122
  diff-lcs (>= 1.2.0, < 2.0)
123
123
  rspec-support (~> 3.12.0)
124
124
  rspec-support (3.12.0)
125
- rubocop (1.52.0)
125
+ rubocop (1.52.1)
126
126
  json (~> 2.3)
127
127
  parallel (~> 1.10)
128
- parser (>= 3.2.0.0)
128
+ parser (>= 3.2.2.3)
129
129
  rainbow (>= 2.2.2, < 4.0)
130
130
  regexp_parser (>= 1.8, < 3.0)
131
131
  rexml (>= 3.2.5, < 4.0)
@@ -172,7 +172,7 @@ DEPENDENCIES
172
172
  rbs_draper!
173
173
  rspec
174
174
  rspec-daemon
175
- rubocop (~> 1.21)
175
+ rubocop (~> 1.52)
176
176
  steep
177
177
 
178
178
  BUNDLED WITH
@@ -11,10 +11,11 @@ module RbsDraper
11
11
  end
12
12
 
13
13
  class Generator
14
- attr_reader :klass, :rbs_builder
14
+ attr_reader :klass, :klass_name, :rbs_builder
15
15
 
16
16
  def initialize(klass, rbs_builder)
17
17
  @klass = klass
18
+ @klass_name = RbsRails::Util.module_name(klass)
18
19
  @rbs_builder = rbs_builder
19
20
  end
20
21
 
@@ -37,16 +38,23 @@ module RbsDraper
37
38
  end
38
39
 
39
40
  def header
40
- module_defs = module_names.map { |module_name| "module #{module_name}" }
41
-
42
- class_name = klass.name.split("::").last
43
- class_def = if klass.superclass
44
- "class #{class_name} < #{klass.superclass.name}"
45
- else
46
- "class #{class_name}"
47
- end
48
-
49
- (module_defs + [class_def]).join("\n")
41
+ namespace = +""
42
+ klass_name.split("::").map do |mod_name|
43
+ namespace += "::#{mod_name}"
44
+ mod_object = Object.const_get(namespace)
45
+ case mod_object
46
+ when Class
47
+ # @type var superclass: Class
48
+ superclass = _ = mod_object.superclass
49
+ superclass_name = RbsRails::Util.module_name(superclass)
50
+
51
+ "class #{mod_name} < ::#{superclass_name}"
52
+ when Module
53
+ "module #{mod_name}"
54
+ else
55
+ raise "unreachable"
56
+ end
57
+ end.join("\n")
50
58
  end
51
59
 
52
60
  def method_decls
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsDraper
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -4,6 +4,7 @@ module RbsDraper
4
4
 
5
5
  class Generator
6
6
  attr_reader klass: Class
7
+ attr_reader klass_name: String
7
8
  attr_reader rbs_builder: RBS::DefinitionBuilder
8
9
 
9
10
  @decorated_class: RBS::Definition
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_draper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.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-06-11 00:00:00.000000000 Z
11
+ date: 2023-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: draper