mangrove 0.22.0 → 0.23.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mangrove/version.rb +1 -1
- data/lib/tapioca/dsl/compilers/mangrove_enum.rb +37 -7
- 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: c1fff1639273ef4d4926c8a962ccca0717601bf37b5358f2ba65d1d3dd6f30ea
|
4
|
+
data.tar.gz: beb11055a2c9fff7b68af66586a226b97fe53cec2d22fb67180f81d1613eb07c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82a914cdda372923944b1ff69839cc46b7bc00e26b2aca4abe91308bbb7d40ac6ce2fe0959eb6a8ae0d4b09f029744d83f807fa6e2b4d1e4469fa4eba56edbc7
|
7
|
+
data.tar.gz: 4dc31bad6e1b504d1c175d787074d0e2623964bbeceeb292300e6c84103e5dc8917177e8d191060a759c28dae1eaf7ff4ab9fbb40557300f2630a5e1ea90c83b
|
data/lib/mangrove/version.rb
CHANGED
@@ -24,20 +24,24 @@ module Tapioca
|
|
24
24
|
RBI::Helper.new("sealed")
|
25
25
|
)
|
26
26
|
|
27
|
-
variants = constant
|
28
|
-
|
27
|
+
variants = constant
|
28
|
+
.constants
|
29
|
+
.filter_map { |variant_name|
|
30
|
+
maybe_variant = constant.const_get(variant_name, false)
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
32
|
+
if maybe_variant.instance_variable_defined?(:@__mangrove__enum_inner_type)
|
33
|
+
maybe_variant
|
34
|
+
end
|
35
|
+
}
|
36
|
+
.sort_by { |variant| variant.name.to_s }
|
34
37
|
|
35
38
|
inner_types = variants.map { |variant|
|
36
|
-
inner_type = variant.instance_variable_get(:@__mangrove__enum_inner_type)
|
39
|
+
inner_type = runtime_type_to_type_name(variant.instance_variable_get(:@__mangrove__enum_inner_type))
|
37
40
|
constant_type.create_class(variant.name.gsub(/.*::/, ""), superclass_name: constant_type.fully_qualified_name) { |variant_type|
|
38
41
|
variant_type.create_method("initialize", parameters: [create_param("inner", type: inner_type)], return_type: "void")
|
39
42
|
variant_type.create_method("inner", return_type: inner_type)
|
40
43
|
variant_type.create_method("as_super", return_type: constant.name.to_s)
|
44
|
+
variant_type.sort_nodes!
|
41
45
|
}
|
42
46
|
|
43
47
|
inner_type
|
@@ -45,8 +49,34 @@ module Tapioca
|
|
45
49
|
|
46
50
|
constant_type.create_method("inner", return_type: "T.any(#{inner_types.join(", ")})")
|
47
51
|
constant_type.create_method("as_super", return_type: constant.name.to_s)
|
52
|
+
constant_type.sort_nodes!
|
48
53
|
}
|
49
54
|
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
sig { params(runtime_type: T.untyped).returns(String) }
|
59
|
+
def runtime_type_to_type_name(runtime_type)
|
60
|
+
if runtime_type.is_a?(Array)
|
61
|
+
content = runtime_type.map { |inner|
|
62
|
+
runtime_type_to_type_name(inner)
|
63
|
+
}.join(", ")
|
64
|
+
|
65
|
+
"[#{content}]"
|
66
|
+
elsif runtime_type.is_a?(Hash)
|
67
|
+
content = runtime_type.map { |k, v|
|
68
|
+
unless k.is_a?(Symbol) || k.is_a?(String)
|
69
|
+
raise "shape key must be Symbol or String"
|
70
|
+
end
|
71
|
+
|
72
|
+
"#{k}: #{runtime_type_to_type_name(v)}"
|
73
|
+
}.join(", ")
|
74
|
+
|
75
|
+
"{ #{content} }"
|
76
|
+
else
|
77
|
+
runtime_type.to_s
|
78
|
+
end
|
79
|
+
end
|
50
80
|
end
|
51
81
|
end
|
52
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mangrove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.23.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kazuma Murata
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|