orthoses 1.14.0 → 1.15.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/duplication_checker.rb +3 -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: '0555497d665f5573dfa6a86e454c165195f0e33ae82842fa83c2cff54b7d360d'
|
4
|
+
data.tar.gz: c760feb2cecc92c04f0eecedf9790d7ac9be2dd5a7aed5850d009d51e49594dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3febe9350d66db369d8d8b24bd3ef6e3a1885b0207a5bef263a048e4eab732604f48d0fe27900ae1318f29ea87cc1f018a06f9b62a544aae8a402d0312674d1
|
7
|
+
data.tar.gz: e90e69dcd746b3a83984e3234e51666f9cc9102670a71f09676ce97c664c79ff9f68b84ed3da4d7d43a4aa5213b091f05e6455ca6c4709ee54a13dfeab91de23
|
@@ -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.15.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-25 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
|