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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a6942bb06928e29ae619e8dfd3f92ac603bda3d0feda99dafd309c4eb493327
4
- data.tar.gz: 6affe9ebc4d0b1a3ec31c9192e271ee6a2b35765ad6c753c58fc2310fb6155ae
3
+ metadata.gz: b4cab7a047064bc63f7fdab6b3644e019dc397cb6bc17670b4acf0d18227b949
4
+ data.tar.gz: 7cdf8af9f9cea0302b88095be8bd8ce98ccdc64c72cad37634de54fb3591c86d
5
5
  SHA512:
6
- metadata.gz: 7e5f33fe35dc796660ea45096401a2157ec32ac19ead7af5ead38d4ab96fb40e28a4c266726bf4c0d6769cd8cfa0d6064501c18e99bbcceb1bdb2b929f610eb1
7
- data.tar.gz: 8adf74dc954206d5e517cf6d0151cf50500375c9363ede9305c90a0989724f61d956b07daf6a17ebe8f1018912245474e10fa944ba4ecbbda4c927a6253eb0ff
6
+ metadata.gz: 4d58a223aa21d7dc8db739a329c9037f7158aa41ddb30c500e30636730d21fe2bfba4492d9ffea1eeebd990e593028b009df0a8f74a938c15b93ef8267090eb3
7
+ data.tar.gz: 253a53938a1b1e20217e45dea9cf102ec5dfd1bb60be6b79b034da451cdd6b5f976d3c5cf5adc360201f676664bface13f3f26a0ab8d2bc780bbc0e6e78e92e8
@@ -191,9 +191,9 @@ module Orthoses
191
191
 
192
192
  def escaped_rbs
193
193
  rbs = original_rbs
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}" }
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
 
@@ -32,7 +32,7 @@ module Orthoses
32
32
  )
33
33
 
34
34
  patterns = @patterns || store.keys
35
- env = RBS::Environment.new
35
+ env = Utils.rbs_environment
36
36
  merge = false
37
37
  owners_included = []
38
38
  RBS::Prototype::Runtime.new(
@@ -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.map do |type|
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 << ::RBS::Types::Bases::Bool.new(location: nil)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthoses
4
- VERSION = "1.11.0"
4
+ VERSION = "1.12.0"
5
5
  end
@@ -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.11.0
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-02 00:00:00.000000000 Z
11
+ date: 2023-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs