rbs_active_hash 1.0.0 → 1.0.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: a40c37520928e6b4e5f6049311691c16966c1819008648702b9fdfa7abb0a156
4
- data.tar.gz: c2d4212d760b5970ae09919641a88cdca6bd4469e12271a545d7226692281b99
3
+ metadata.gz: 57044cf3bbe008c0523f22f062fb7936a43ddce6a03e17f04e02daef661c092d
4
+ data.tar.gz: b6533e6014fcef654e87d2187e381dced145f2f4828567e0e226b241d7258233
5
5
  SHA512:
6
- metadata.gz: cf19e092d7dac5139dd6ba69bc136e692efc0b4dd6624f084e24de9a57327ec32bb4dcd777c7da6b25586925c4103738bf2796f962db200f5077ad7356f9ff59
7
- data.tar.gz: c9a1fc5bcf3c671f2cc4954b0639ea13a461318583d55434e3bbe58f7036594b215d587b59eddedb89f5db6702cb5451c64ec0f45bcaa0cb262bf2b8b79e8941
6
+ metadata.gz: ba76fab12f70ac6cb4bae32d6861657f4932f5e7509a2b33e273d6bd7ed954eab626af709fcc91780c6f68caad7de36c05796f4aa2cb17befd7708200a99ef79
7
+ data.tar.gz: ac00937fc78c4fd2e098ab1154aedf79a1626ab48e810ee543143087a4d83424b5547708c7b9edf7fcf5431f5d9e8e2eea54a17562e01a961fab0e1a5196908e
data/.rubocop.yml CHANGED
@@ -19,6 +19,9 @@ Metrics/BlockLength:
19
19
  Exclude:
20
20
  - spec/**/*_spec.rb
21
21
 
22
+ Metrics/ClassLength:
23
+ Max: 200
24
+
22
25
  Metrics/MethodLength:
23
26
  Max: 20
24
27
 
@@ -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_active_hash (1.0.0)
4
+ rbs_active_hash (1.0.1)
5
5
  active_hash
6
6
  rbs_rails
7
7
 
@@ -61,8 +61,9 @@ GEM
61
61
  nokogiri (1.15.2-x86_64-linux)
62
62
  racc (~> 1.4)
63
63
  parallel (1.23.0)
64
- parser (3.2.2.1)
64
+ parser (3.2.2.3)
65
65
  ast (~> 2.4.1)
66
+ racc
66
67
  pry (0.14.2)
67
68
  coderay (~> 1.1)
68
69
  method_source (~> 1.0)
@@ -92,7 +93,7 @@ GEM
92
93
  rbs_rails (0.12.0)
93
94
  parser
94
95
  rbs (>= 1)
95
- regexp_parser (2.8.0)
96
+ regexp_parser (2.8.1)
96
97
  rexml (3.2.5)
97
98
  rspec (3.12.0)
98
99
  rspec-core (~> 3.12.0)
@@ -110,10 +111,10 @@ GEM
110
111
  diff-lcs (>= 1.2.0, < 2.0)
111
112
  rspec-support (~> 3.12.0)
112
113
  rspec-support (3.12.0)
113
- rubocop (1.52.0)
114
+ rubocop (1.52.1)
114
115
  json (~> 2.3)
115
116
  parallel (~> 1.10)
116
- parser (>= 3.2.0.0)
117
+ parser (>= 3.2.2.3)
117
118
  rainbow (>= 2.2.2, < 4.0)
118
119
  regexp_parser (>= 1.8, < 3.0)
119
120
  rexml (>= 3.2.5, < 4.0)
@@ -159,7 +160,7 @@ DEPENDENCIES
159
160
  rbs_active_hash!
160
161
  rspec
161
162
  rspec-daemon
162
- rubocop (~> 1.21)
163
+ rubocop (~> 1.52)
163
164
  steep
164
165
 
165
166
  BUNDLED WITH
@@ -15,8 +15,11 @@ module RbsActiveHash
15
15
  end
16
16
 
17
17
  class Generator
18
+ attr_reader :klass, :klass_name
19
+
18
20
  def initialize(klass)
19
21
  @klass = klass
22
+ @klass_name = RbsRails::Util.module_name(klass)
20
23
  end
21
24
 
22
25
  def generate
@@ -43,12 +46,23 @@ module RbsActiveHash
43
46
  end
44
47
 
45
48
  def header
46
- module_defs = module_names.map { |module_name| "module #{module_name}" }
47
-
48
- class_name = klass.name.split("::").last
49
- class_def = "class #{class_name} < ::#{klass.superclass}"
50
-
51
- (module_defs + [class_def]).join("\n")
49
+ namespace = +""
50
+ klass_name.split("::").map do |mod_name|
51
+ namespace += "::#{mod_name}"
52
+ mod_object = Object.const_get(namespace)
53
+ case mod_object
54
+ when Class
55
+ # @type var superclass: Class
56
+ superclass = _ = mod_object.superclass
57
+ superclass_name = RbsRails::Util.module_name(superclass)
58
+
59
+ "class #{mod_name} < ::#{superclass_name}"
60
+ when Module
61
+ "module #{mod_name}"
62
+ else
63
+ raise "unreachable"
64
+ end
65
+ end.join("\n")
52
66
  end
53
67
 
54
68
  def module_names
@@ -139,8 +153,6 @@ module RbsActiveHash
139
153
  type.to_s
140
154
  end
141
155
  end
142
-
143
- attr_reader :klass
144
156
  end
145
157
  end
146
158
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RbsActiveHash
4
- VERSION = "1.0.0"
4
+ VERSION = "1.0.1"
5
5
  end
@@ -4,7 +4,8 @@ module RbsActiveHash
4
4
  def self.class_to_rbs: (Class klass) -> String
5
5
 
6
6
  class Generator
7
- @klass: Class
7
+ attr_reader klass: Class
8
+ attr_reader klass_name: String
8
9
 
9
10
  def initialize: (Class class) -> void
10
11
  def generate: () -> String
@@ -22,8 +23,6 @@ module RbsActiveHash
22
23
  def footer: () -> String
23
24
 
24
25
  def stringify_type: (untyped type) -> String
25
-
26
- attr_reader klass: Class
27
26
  end
28
27
  end
29
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs_active_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.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-14 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: active_hash