rbs_active_hash 1.0.0 → 1.0.2
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/.vscode/extensions.json +2 -1
- data/.vscode/settings.json +2 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +7 -6
- data/lib/rbs_active_hash/active_hash.rb +21 -9
- data/lib/rbs_active_hash/version.rb +1 -1
- data/sig/rbs_active_hash/active_hash.rbs +2 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5bd0859aca0abeafa29b299ee1a1aa61e35c047fd38b55f40221021a1d020f35
|
4
|
+
data.tar.gz: 4e4da104614dc73ebbcf0dd21dba228186794216e925dbe5d3bd024e2c2cfa4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9495fd300438b29d29667df2943a92dacc153deb347bd92f6e1d9c42b6f4420d972f068bcfdd155ad89015c82918a8fafe81ff0c396697be07fdc5fc03ef843a
|
7
|
+
data.tar.gz: fc05bb1f89e98266fba16a77c524265e67098ab5f341386f274d7be9c24c5d0ed9ba80ad869c04a3231b795e4dfec51c750f29e895b458c96f22bb5939b24326
|
data/.rubocop.yml
CHANGED
data/.vscode/extensions.json
CHANGED
data/.vscode/settings.json
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rbs_active_hash (1.0.
|
4
|
+
rbs_active_hash (1.0.2)
|
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.
|
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.
|
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.
|
114
|
+
rubocop (1.52.1)
|
114
115
|
json (~> 2.3)
|
115
116
|
parallel (~> 1.10)
|
116
|
-
parser (>= 3.2.
|
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.
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
@@ -88,7 +102,7 @@ module RbsActiveHash
|
|
88
102
|
method_type = stringify_type(method_types.fetch(method, "untyped"))
|
89
103
|
<<~RBS
|
90
104
|
def #{method}: () -> #{method_type}
|
91
|
-
def #{method}=: (#{method_type} value) ->
|
105
|
+
def #{method}=: (#{method_type} value) -> #{method_type}
|
92
106
|
def #{method}?: () -> bool
|
93
107
|
def self.find_by_#{method}: (#{method_type} value) -> self?
|
94
108
|
def self.find_all_by_#{method}: (#{method_type} value) -> Array[self]
|
@@ -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
|
@@ -4,7 +4,8 @@ module RbsActiveHash
|
|
4
4
|
def self.class_to_rbs: (Class klass) -> String
|
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 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.
|
4
|
+
version: 1.0.2
|
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
|
+
date: 2023-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_hash
|