orthoses 1.14.0 → 1.16.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: ccd997f8aa90c6f1d49fdebe0a58c2de59d0df1e7146efa5c69d7d3614927c1b
4
- data.tar.gz: 2f02a44951ad7b654e48d21c3b4100955997f102d616c494461bbbfeefdc7cc1
3
+ metadata.gz: d2799fba99407dbfe097d59c7fcd5238e5bc50b5e5c51bf6ac98402b0a67a8c0
4
+ data.tar.gz: 2c9f343a3d3aa78bbb00b72790105b3a54ec98a326b805ee08125033d2d60739
5
5
  SHA512:
6
- metadata.gz: 2023496aaf266db6a0d5945a288891967fb3b61bf0b2851e270e56fc6e87398abd7bc761db2dd35dde313bd8f0c66cbfc9ede859d0b008356d4275bd9efa36fb
7
- data.tar.gz: 622b6a3bd44b197620c5221998316d334bf47f5332a9e561df87226a8480fb4ebee1ab0ab50f7f7f5bed97fb24cc137ee5f427000004b469caadccc9987f40bb
6
+ metadata.gz: 4602f93d07de6f57cf37d48a26b37a9bcec04164a552fdb004e49255385b436d886718be415dda06ba4151fd68345e1cf48731cdbad2a5f1e0b676998cb7baa6
7
+ data.tar.gz: 7576d486cd86dd12674dfe97a71a2d64defbb289a5dca1fe762c4244a4e573f962c5d3f9585b1c469a8119a160e37cd7c8695e4e04e32cc51d7c2844fb6bf118
@@ -18,7 +18,9 @@ module Orthoses
18
18
  drop_known_method_definition
19
19
  drop_known_const_definition
20
20
 
21
- @decl.members.replace(@uniq_map.values)
21
+ # HACK
22
+ new_members = @uniq_map.values
23
+ @decl.instance_eval { @members = new_members }
22
24
 
23
25
  @uniq_map.clear
24
26
  end
@@ -68,7 +68,7 @@ module Orthoses
68
68
  require 'rbs/sorter'
69
69
  sorter = ::RBS::Sorter.new(nil, stdout: nil)
70
70
  decl = to_decl
71
- sorter.sort_decl!(decl)
71
+ decl = sorter.sort_decl(decl)
72
72
  lines = decl_to_lines(decl)
73
73
  @body.replace(lines)
74
74
  end
@@ -23,9 +23,10 @@ module Orthoses
23
23
 
24
24
  include Targetable
25
25
 
26
- def initialize(loader, patterns:)
26
+ def initialize(loader, patterns:, sort_union_types: true)
27
27
  @loader = loader
28
28
  @patterns = patterns
29
+ @sort_union_types = sort_union_types
29
30
 
30
31
  @captured_dict = Hash.new { |h, k| h[k] = Hash.new { |hh, kk| hh[kk] = [] } }
31
32
  end
@@ -45,6 +46,7 @@ module Orthoses
45
46
 
46
47
  @captured_dict.each do |mod_name, captures|
47
48
  captures.each do |(kind, prefix, name), types|
49
+ types.sort! if @sort_union_types
48
50
  injected = Utils::TypeList.new(types).inject
49
51
  store[mod_name] << "#{kind} #{prefix}#{name}: #{injected}"
50
52
  end
@@ -7,9 +7,10 @@ module Orthoses
7
7
  Info = Struct.new(:key, :op_name_types, :raised, keyword_init: true)
8
8
  include Targetable
9
9
 
10
- def initialize(loader, patterns:)
10
+ def initialize(loader, patterns:, sort_union_types: true)
11
11
  @loader = loader
12
12
  @patterns = patterns
13
+ @sort_union_types = sort_union_types
13
14
 
14
15
  @stack = []
15
16
  @args_return_map = Hash.new { |h, k| h[k] = [] }
@@ -36,9 +37,7 @@ module Orthoses
36
37
  case tp.event
37
38
  when :call
38
39
  if tp.defined_class.singleton_class?
39
- # e.g. `Minitest::Spec::DSL#to_s`` may return `nil` with `#to_s`
40
- m = tp.defined_class.to_s&.match(/#<Class:([\w:]+)>/) or next
41
- mod_name = m[1] or next
40
+ mod_name = Utils.attached_module_name(tp.defined_class) or next
42
41
  kind = :singleton
43
42
  else
44
43
  mod_name = Utils.module_name(tp.defined_class) or next
@@ -81,6 +80,7 @@ module Orthoses
81
80
 
82
81
  @args_return_map.map do |(mod_name, kind, visibility, method_id), type_samples|
83
82
  type_samples.uniq!
83
+ type_samples.sort! if @sort_union_types
84
84
  method_types = type_samples.map do |(op_name_types, return_type)|
85
85
  required_positionals = []
86
86
  optional_positionals = []
@@ -171,6 +171,17 @@ module Orthoses
171
171
  end
172
172
  end
173
173
 
174
+ def self.attached_module_name(mod)
175
+ if mod.respond_to?(:attached_object)
176
+ attached_object = mod.attached_object
177
+ (attached_object&.is_a?(Module) && attached_object.name) || nil
178
+ else
179
+ # e.g. `Minitest::Spec::DSL#to_s` may return `nil` with `#to_s`
180
+ m = mod.to_s&.match(/#<Class:([\w:]+)>/)
181
+ m && m[1]
182
+ end
183
+ end
184
+
174
185
  def self.known_type_params(name)
175
186
  type_name =
176
187
  case name
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthoses
4
- VERSION = "1.14.0"
4
+ VERSION = "1.16.0"
5
5
  end
@@ -10,9 +10,10 @@ end
10
10
  class Orthoses::Trace::Attribute
11
11
  @loader: untyped
12
12
  @patterns: untyped
13
+ @sort_union_types: untyped
13
14
  @captured_dict: untyped
14
- def initialize: (untyped loader, patterns: untyped) -> void
15
- def call: () -> untyped
15
+ def initialize: (Orthoses::_Call loader, patterns: Array[String], ?sort_union_types: bool?) -> void
16
+ def call: () -> Orthoses::store
16
17
  private def build_trace_hook: () -> untyped
17
18
  include Orthoses::Trace::Targetable
18
19
  end
@@ -30,11 +31,12 @@ end
30
31
  class Orthoses::Trace::Method
31
32
  @loader: untyped
32
33
  @patterns: untyped
34
+ @sort_union_types: untyped
33
35
  @stack: untyped
34
36
  @args_return_map: untyped
35
37
  @alias_map: untyped
36
- def initialize: (untyped loader, patterns: untyped) -> void
37
- def call: () -> untyped
38
+ def initialize: (Orthoses::_Call loader, patterns: Array[String], ?sort_union_types: bool?) -> void
39
+ def call: () -> Orthoses::store
38
40
  private def build_trace_point: () -> untyped
39
41
  private def build_members: () -> untyped
40
42
  private def build_method_definitions: () -> untyped
@@ -21,6 +21,8 @@ module Orthoses::Utils
21
21
 
22
22
  def self.module_to_type_name: (Module) -> RBS::TypeName?
23
23
 
24
+ def self.attached_module_name: (Module) -> String?
25
+
24
26
  def self.known_type_params: (Module | String) -> Array[RBS::AST::TypeParam]?
25
27
 
26
28
  def self.new_store: () -> Orthoses::store
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.14.0
4
+ version: 1.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-03 00:00:00.000000000 Z
11
+ date: 2024-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -124,14 +124,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
124
124
  requirements:
125
125
  - - ">="
126
126
  - !ruby/object:Gem::Version
127
- version: 3.0.0
127
+ version: 3.1.0
128
128
  required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - ">="
131
131
  - !ruby/object:Gem::Version
132
132
  version: '0'
133
133
  requirements: []
134
- rubygems_version: 3.5.11
134
+ rubygems_version: 3.5.16
135
135
  signing_key:
136
136
  specification_version: 4
137
137
  summary: Framework for Generate RBS