orthoses 1.11.0 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/orthoses/content.rb +3 -3
- data/lib/orthoses/rbs_prototype_runtime.rb +1 -1
- data/lib/orthoses/utils/type_list.rb +36 -9
- data/lib/orthoses/version.rb +1 -1
- data/sig/orthoses/utils/type_list.rbs +2 -0
- 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: b4cab7a047064bc63f7fdab6b3644e019dc397cb6bc17670b4acf0d18227b949
|
4
|
+
data.tar.gz: 7cdf8af9f9cea0302b88095be8bd8ce98ccdc64c72cad37634de54fb3591c86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d58a223aa21d7dc8db739a329c9037f7158aa41ddb30c500e30636730d21fe2bfba4492d9ffea1eeebd990e593028b009df0a8f74a938c15b93ef8267090eb3
|
7
|
+
data.tar.gz: 253a53938a1b1e20217e45dea9cf102ec5dfd1bb60be6b79b034da451cdd6b5f976d3c5cf5adc360201f676664bface13f3f26a0ab8d2bc780bbc0e6e78e92e8
|
data/lib/orthoses/content.rb
CHANGED
@@ -191,9 +191,9 @@ module Orthoses
|
|
191
191
|
|
192
192
|
def escaped_rbs
|
193
193
|
rbs = original_rbs
|
194
|
-
rbs.gsub!(/def\s
|
195
|
-
rbs.gsub!(/alias\s
|
196
|
-
rbs.gsub!(/attr_(reader|writer|accessor)\s
|
194
|
+
rbs.gsub!(/def\s+(self\??\.)?(.+?):/) { "def #{$1}`#{$2}`:" }
|
195
|
+
rbs.gsub!(/alias\s+(self\.)?(.+?)\s+(self\.)?(.+)$/) { "alias #{$1}`#{$2}` #{$3}`#{$4}`" }
|
196
|
+
rbs.gsub!(/attr_(reader|writer|accessor)\s+(self\.)?(.+)\s*:\s*(.+)$/) { "attr_#{$1} #{$2}`#{$3}`: #{$4}" }
|
197
197
|
rbs
|
198
198
|
end
|
199
199
|
|
@@ -8,19 +8,15 @@ module Orthoses
|
|
8
8
|
NIL_TYPE = ::RBS::Types::Bases::Nil.new(location: nil)
|
9
9
|
TRUE_TYPE = ::RBS::Types::Literal.new(literal: true, location: nil)
|
10
10
|
FALSE_TYPE = ::RBS::Types::Literal.new(literal: false, location: nil)
|
11
|
+
BOOL_TYPE = ::RBS::Types::Bases::Bool.new(location: nil)
|
11
12
|
|
12
13
|
def initialize(types)
|
13
|
-
@types = types
|
14
|
-
case type
|
15
|
-
when String
|
16
|
-
::RBS::Parser.parse_type(type)
|
17
|
-
else
|
18
|
-
type
|
19
|
-
end
|
20
|
-
end
|
14
|
+
@types = types
|
21
15
|
end
|
22
16
|
|
23
17
|
def inject
|
18
|
+
normalize
|
19
|
+
|
24
20
|
uniqed = @types.uniq
|
25
21
|
|
26
22
|
return UNTYPED if uniqed.find { |t| t == UNTYPED }
|
@@ -28,7 +24,7 @@ module Orthoses
|
|
28
24
|
has_true = uniqed.delete(TRUE_TYPE)
|
29
25
|
has_false = uniqed.delete(FALSE_TYPE)
|
30
26
|
if has_true || has_false
|
31
|
-
uniqed <<
|
27
|
+
uniqed << BOOL_TYPE
|
32
28
|
end
|
33
29
|
|
34
30
|
return UNTYPED if uniqed.empty?
|
@@ -68,6 +64,37 @@ module Orthoses
|
|
68
64
|
|
69
65
|
injected
|
70
66
|
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def normalize
|
71
|
+
@types = @types.map do |type|
|
72
|
+
case type
|
73
|
+
when String
|
74
|
+
::RBS::Parser.parse_type(type)
|
75
|
+
else
|
76
|
+
type
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
@types = @types.map do |rbs_type|
|
81
|
+
case rbs_type
|
82
|
+
when ::RBS::Types::ClassInstance
|
83
|
+
case rbs_type.name.to_s
|
84
|
+
when 'TrueClass', '::TrueClass', 'FalseClass', '::FalseClass'
|
85
|
+
BOOL_TYPE
|
86
|
+
when 'NilClass', '::NilClass'
|
87
|
+
NIL_TYPE
|
88
|
+
else
|
89
|
+
rbs_type
|
90
|
+
end
|
91
|
+
else
|
92
|
+
rbs_type
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
self
|
97
|
+
end
|
71
98
|
end
|
72
99
|
end
|
73
100
|
end
|
data/lib/orthoses/version.rb
CHANGED
@@ -5,6 +5,8 @@ class Orthoses::Utils::TypeList
|
|
5
5
|
@types: untyped
|
6
6
|
def initialize: (untyped types) -> void
|
7
7
|
def inject: () -> untyped
|
8
|
+
private def normalize: () -> self
|
9
|
+
BOOL_TYPE: RBS::Types::Bases::Bool
|
8
10
|
FALSE_TYPE: RBS::Types::Literal
|
9
11
|
NIL_TYPE: RBS::Types::Bases::Nil
|
10
12
|
TRUE_TYPE: RBS::Types::Literal
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: orthoses
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|