orthoses 1.14.0 → 1.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/orthoses/content/duplication_checker.rb +3 -1
- data/lib/orthoses/content.rb +1 -1
- data/lib/orthoses/trace/attribute.rb +3 -1
- data/lib/orthoses/trace/method.rb +4 -4
- data/lib/orthoses/utils.rb +11 -0
- data/lib/orthoses/version.rb +1 -1
- data/sig/orthoses/trace.rbs +6 -4
- data/sig/orthoses/utils.rbs +2 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2799fba99407dbfe097d59c7fcd5238e5bc50b5e5c51bf6ac98402b0a67a8c0
|
4
|
+
data.tar.gz: 2c9f343a3d3aa78bbb00b72790105b3a54ec98a326b805ee08125033d2d60739
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4602f93d07de6f57cf37d48a26b37a9bcec04164a552fdb004e49255385b436d886718be415dda06ba4151fd68345e1cf48731cdbad2a5f1e0b676998cb7baa6
|
7
|
+
data.tar.gz: 7576d486cd86dd12674dfe97a71a2d64defbb289a5dca1fe762c4244a4e573f962c5d3f9585b1c469a8119a160e37cd7c8695e4e04e32cc51d7c2844fb6bf118
|
data/lib/orthoses/content.rb
CHANGED
@@ -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
|
-
|
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 = []
|
data/lib/orthoses/utils.rb
CHANGED
@@ -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
|
data/lib/orthoses/version.rb
CHANGED
data/sig/orthoses/trace.rbs
CHANGED
@@ -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: (
|
15
|
-
def call: () ->
|
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: (
|
37
|
-
def call: () ->
|
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
|
data/sig/orthoses/utils.rbs
CHANGED
@@ -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.
|
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-
|
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.
|
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.
|
134
|
+
rubygems_version: 3.5.16
|
135
135
|
signing_key:
|
136
136
|
specification_version: 4
|
137
137
|
summary: Framework for Generate RBS
|