orthoses 0.9.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +12 -12
- data/README.md +13 -10
- data/examples/minitest/Rakefile +2 -2
- data/lib/orthoses/attribute.rb +0 -2
- data/lib/orthoses/autoload.rb +37 -0
- data/lib/orthoses/call_tracer/capturable.rb +42 -0
- data/lib/orthoses/call_tracer/lazy.rb +22 -0
- data/lib/orthoses/call_tracer.rb +9 -33
- data/lib/orthoses/constant.rb +1 -1
- data/lib/orthoses/content/duplication_checker.rb +15 -9
- data/lib/orthoses/content/header_builder.rb +1 -1
- data/lib/orthoses/content.rb +36 -6
- data/lib/orthoses/create_file_by_name.rb +12 -4
- data/lib/orthoses/filter.rb +7 -5
- data/lib/orthoses/lazy_trace_point.rb +103 -0
- data/lib/orthoses/load_rbs.rb +3 -1
- data/lib/orthoses/mixin.rb +2 -2
- data/lib/orthoses/object_space_all.rb +1 -3
- data/lib/orthoses/outputable/avoid_recursive_ancestor_error.rb +37 -0
- data/lib/orthoses/outputable.rb +21 -0
- data/lib/orthoses/path_helper.rb +38 -0
- data/lib/orthoses/rbs_prototype_runtime.rb +32 -0
- data/lib/orthoses/utils.rb +2 -1
- data/lib/orthoses/version.rb +1 -1
- data/lib/orthoses/writer.rb +2 -0
- data/lib/orthoses.rb +10 -1
- data/sig/orthoses/attribute/hook.rbs +0 -3
- data/sig/orthoses/autoload/hook.rbs +5 -0
- data/sig/orthoses/autoload.rbs +6 -0
- data/sig/orthoses/builder.rbs +0 -1
- data/sig/orthoses/call_tracer/capturable.rbs +7 -0
- data/sig/orthoses/call_tracer/lazy.rbs +6 -0
- data/sig/orthoses/call_tracer.rbs +0 -1
- data/sig/orthoses/constant.rbs +1 -1
- data/sig/orthoses/content/array_io.rbs +7 -0
- data/sig/orthoses/content/duplication_checker.rbs +2 -3
- data/sig/orthoses/content/environment.rbs +0 -1
- data/sig/orthoses/content.rbs +4 -2
- data/sig/orthoses/filter.rbs +2 -1
- data/sig/orthoses/lazy_trace_point.rbs +15 -0
- data/sig/orthoses/load_rbs.rbs +3 -2
- data/sig/orthoses/mixin/hook.rbs +0 -2
- data/sig/orthoses/{avoid_recursive_ancestor_error.rbs → outputable/avoid_recursive_ancestor_error.rbs} +2 -2
- data/sig/orthoses/outputable.rbs +5 -0
- data/sig/orthoses/path_helper.rbs +9 -0
- data/sig/orthoses/rbs_prototype_runtime.rbs +6 -0
- data/sig/orthoses/utils.rbs +1 -13
- data/sig/orthoses.rbs +3 -3
- metadata +21 -5
- data/lib/orthoses/avoid_recursive_ancestor_error.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b99546cf07198d891673d96f57a8cd22602db3442fc8526377e113dc82716351
|
4
|
+
data.tar.gz: 45d4d49fd66765eac0429d90718ae7b4bc3f66181f67efd97c9f4a5b4e970955
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4d4ebe91a584ab50850ccdf60a489e37fe1c4da99fd8bc9ed2f8aa255b2e35f5b60b0b3ab5f2662833d34f8514f87be84018b17a97dcda76db4e57e1f52a834
|
7
|
+
data.tar.gz: 78696a4162f7e469c52e059cf4fdc09160926f354ab5b3343db681d7ba78360c1406889da81830c585dda30a95921d9753fced392ad92f72324f27a8d0ad3747
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orthoses (0.
|
4
|
+
orthoses (1.0.0)
|
5
5
|
rbs (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
activesupport (7.0.3)
|
10
|
+
activesupport (7.0.3.1)
|
11
11
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
12
12
|
i18n (>= 1.6, < 2)
|
13
13
|
minitest (>= 5.1)
|
@@ -15,45 +15,45 @@ GEM
|
|
15
15
|
ast (2.4.2)
|
16
16
|
concurrent-ruby (1.1.10)
|
17
17
|
ffi (1.15.5)
|
18
|
-
i18n (1.
|
18
|
+
i18n (1.12.0)
|
19
19
|
concurrent-ruby (~> 1.0)
|
20
|
-
language_server-protocol (3.
|
20
|
+
language_server-protocol (3.17.0.0)
|
21
21
|
listen (3.7.1)
|
22
22
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
23
23
|
rb-inotify (~> 0.9, >= 0.9.10)
|
24
|
-
minitest (5.
|
24
|
+
minitest (5.16.3)
|
25
25
|
parallel (1.22.1)
|
26
|
-
parser (3.1.2.
|
26
|
+
parser (3.1.2.1)
|
27
27
|
ast (~> 2.4.1)
|
28
28
|
rainbow (3.1.1)
|
29
29
|
rake (13.0.6)
|
30
30
|
rb-fsevent (0.11.1)
|
31
31
|
rb-inotify (0.10.1)
|
32
32
|
ffi (~> 1.0)
|
33
|
-
rbs (2.
|
33
|
+
rbs (2.6.0)
|
34
34
|
rgot (1.1.0)
|
35
|
-
steep (1.
|
35
|
+
steep (1.1.1)
|
36
36
|
activesupport (>= 5.1)
|
37
37
|
language_server-protocol (>= 3.15, < 4.0)
|
38
38
|
listen (~> 3.0)
|
39
39
|
parallel (>= 1.0.0)
|
40
|
-
parser (>= 3.
|
40
|
+
parser (>= 3.1)
|
41
41
|
rainbow (>= 2.2.2, < 4.0)
|
42
42
|
rbs (>= 2.3.2)
|
43
43
|
terminal-table (>= 2, < 4)
|
44
44
|
terminal-table (3.0.2)
|
45
45
|
unicode-display_width (>= 1.1.1, < 3)
|
46
|
-
tzinfo (2.0.
|
46
|
+
tzinfo (2.0.5)
|
47
47
|
concurrent-ruby (~> 1.0)
|
48
|
-
unicode-display_width (2.
|
48
|
+
unicode-display_width (2.2.0)
|
49
49
|
|
50
50
|
PLATFORMS
|
51
51
|
ruby
|
52
52
|
|
53
53
|
DEPENDENCIES
|
54
|
-
activesupport
|
55
54
|
orthoses!
|
56
55
|
rake (~> 13.0)
|
56
|
+
rbs
|
57
57
|
rgot (~> 1.1)
|
58
58
|
steep
|
59
59
|
|
data/README.md
CHANGED
@@ -24,12 +24,11 @@ Orthoses::Builder.new do
|
|
24
24
|
use Orthoses::CreateFileByName
|
25
25
|
base_dir: Rails.root.join("sig/out"),
|
26
26
|
header: "# !!! GENERATED CODE !!!"
|
27
|
-
use Orthoses::Filter,
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
}
|
27
|
+
use Orthoses::Filter do |name, _content|
|
28
|
+
path, _lineno = Object.const_source_location(name)
|
29
|
+
return false unless path
|
30
|
+
%r{app/models}.match?(path)
|
31
|
+
end
|
33
32
|
use YourCustom::Middleware
|
34
33
|
use Orthoses::Mixin
|
35
34
|
use Orthoses::Constant
|
@@ -45,10 +44,6 @@ end.call
|
|
45
44
|
|
46
45
|
`Orthoses::Utils` is a collection of useful methods.
|
47
46
|
|
48
|
-
### Orthoses::Utils.unautoload!
|
49
|
-
|
50
|
-
Load all const by recursive.
|
51
|
-
|
52
47
|
### Orthoses::Utils.each_const_recursive
|
53
48
|
|
54
49
|
Yield const by recursive.
|
@@ -151,11 +146,19 @@ Run `rbs prototype rb` command process to `paths` option files.
|
|
151
146
|
`content_filter` option could filter with content decl.
|
152
147
|
`mixin_filter` option could filter with mixin(include, extend, prepend) decl.
|
153
148
|
|
149
|
+
### Orthoses::RBSPrototypeRuntime
|
150
|
+
|
151
|
+
Run `rbs prototype runtime` command process with `patterns` option string.
|
152
|
+
|
154
153
|
### Orthoses::AvoidRecursiveAncestorError
|
155
154
|
|
156
155
|
Mixin a module into an Object class raises `RBS::RecursiveAncestorError` when validation.
|
157
156
|
Please add this middleware then.
|
158
157
|
|
158
|
+
### Orthoses::Autoload
|
159
|
+
|
160
|
+
Force load const defined by `autoload`.
|
161
|
+
|
159
162
|
## Development
|
160
163
|
|
161
164
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/examples/minitest/Rakefile
CHANGED
@@ -13,9 +13,9 @@ task :minitest => :src do
|
|
13
13
|
Orthoses::Builder.new do
|
14
14
|
use Orthoses::CreateFileByName,
|
15
15
|
base_dir: out.to_s
|
16
|
-
use Orthoses::Filter
|
16
|
+
use Orthoses::Filter do |name, content|
|
17
17
|
name.start_with?("Minitest") || name == "Kernel"
|
18
|
-
|
18
|
+
end
|
19
19
|
use Orthoses::Constant,
|
20
20
|
strict: false,
|
21
21
|
if: ->(current, const, val, rbs){
|
data/lib/orthoses/attribute.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
class Autoload
|
5
|
+
module Hook
|
6
|
+
def autoload(name, path)
|
7
|
+
super
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(loader)
|
12
|
+
@loader = loader
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
::Module.prepend(Hook)
|
17
|
+
|
18
|
+
autoload = CallTracer.new
|
19
|
+
|
20
|
+
store = autoload.trace(Hook.instance_method(:autoload)) do
|
21
|
+
@loader.call
|
22
|
+
end
|
23
|
+
|
24
|
+
autoload.captures.each do |capture|
|
25
|
+
base_mod = capture.method.receiver
|
26
|
+
name = capture.argument[:name]
|
27
|
+
begin
|
28
|
+
base_mod.const_get(name)
|
29
|
+
rescue NameError, LoadError, ArgumentError => e
|
30
|
+
Orthoses.logger.warn("[Orthoses::Autoload] raise `#{e.message} (#{e.class})` when try to unautoload `#{base_mod}::#{name}`")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
store
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
class CallTracer
|
5
|
+
module Capturable
|
6
|
+
def build_capture(tp)
|
7
|
+
Capture.new(
|
8
|
+
method: build_method(tp),
|
9
|
+
argument: build_argument(tp),
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def build_method(tp)
|
16
|
+
METHOD_METHOD.bind(tp.self).call(tp.method_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def build_argument(tp)
|
20
|
+
tp.parameters.each_with_object({}) do |op_name, hash|
|
21
|
+
name = op_name[1]
|
22
|
+
case name
|
23
|
+
when :*, :**, :&, nil
|
24
|
+
# skip
|
25
|
+
else
|
26
|
+
hash[name] = tp.binding.local_variable_get(name).then do |var|
|
27
|
+
case var
|
28
|
+
when Module, Thread::Backtrace::Location
|
29
|
+
var
|
30
|
+
else
|
31
|
+
var.dup
|
32
|
+
end
|
33
|
+
rescue => err
|
34
|
+
warn("#dup fail (#{err.class}) #{err.message}")
|
35
|
+
var
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
class CallTracer
|
5
|
+
class Lazy
|
6
|
+
include Capturable
|
7
|
+
|
8
|
+
attr_reader :captures
|
9
|
+
|
10
|
+
def initialize
|
11
|
+
@captures = []
|
12
|
+
@lazy_trace_point = LazyTracePoint.new(:call) do |tp|
|
13
|
+
@captures << build_capture(tp)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def trace(name, &block)
|
18
|
+
@lazy_trace_point.enable(target: name, &block)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/orthoses/call_tracer.rb
CHANGED
@@ -16,46 +16,22 @@ module Orthoses
|
|
16
16
|
class Capture < Struct.new(:method, :argument, keyword_init: true)
|
17
17
|
end
|
18
18
|
|
19
|
+
autoload :Lazy, 'orthoses/call_tracer/lazy'
|
20
|
+
require_relative 'call_tracer/capturable'
|
21
|
+
|
22
|
+
include Capturable
|
23
|
+
|
19
24
|
attr_accessor :captures
|
20
25
|
|
21
26
|
def initialize
|
22
27
|
@captures = []
|
28
|
+
@target_tp = TracePoint.new(:call) do |tp|
|
29
|
+
@captures << build_capture(tp)
|
30
|
+
end
|
23
31
|
end
|
24
32
|
|
25
33
|
def trace(target, &block)
|
26
|
-
|
27
|
-
called_method = tp.self.method(tp.method_id)
|
28
|
-
argument = tp.parameters.each_with_object({}) do |op_name, hash|
|
29
|
-
name = op_name[1]
|
30
|
-
case name
|
31
|
-
when :*, :**, :&, nil
|
32
|
-
# skip
|
33
|
-
else
|
34
|
-
hash[name] = tp.binding.local_variable_get(name).then do |var|
|
35
|
-
case var
|
36
|
-
when Module
|
37
|
-
var # avoid missing name
|
38
|
-
else
|
39
|
-
var.dup
|
40
|
-
end
|
41
|
-
rescue => err
|
42
|
-
case var
|
43
|
-
when Thread::Backtrace::Location
|
44
|
-
# known
|
45
|
-
else
|
46
|
-
warn("#dup fail (#{err.class}) #{err.message}")
|
47
|
-
end
|
48
|
-
var
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
@captures << Capture.new(
|
54
|
-
method: called_method,
|
55
|
-
argument: argument,
|
56
|
-
)
|
57
|
-
end
|
58
|
-
t.enable(target: target, &block)
|
34
|
+
@target_tp.enable(target: target, &block)
|
59
35
|
end
|
60
36
|
end
|
61
37
|
end
|
data/lib/orthoses/constant.rb
CHANGED
@@ -2,18 +2,20 @@ module Orthoses
|
|
2
2
|
class Content
|
3
3
|
# Check and drop duplication method, const etc...
|
4
4
|
class DuplicationChecker
|
5
|
-
def initialize(decl)
|
5
|
+
def initialize(decl, env: nil)
|
6
6
|
@decl = decl
|
7
|
+
@env = env || Utils.rbs_environment(collection: true)
|
7
8
|
end
|
8
9
|
|
9
10
|
def update_decl
|
11
|
+
return unless @decl.respond_to?(:members)
|
10
12
|
uniq_map = {}
|
11
13
|
@decl.members.each do |member|
|
12
14
|
key = member_key(member)
|
13
15
|
drop_member = uniq_map[key]
|
14
16
|
uniq_map[key] = member
|
15
17
|
if drop_member
|
16
|
-
Orthoses.logger.
|
18
|
+
Orthoses.logger.info("#{@decl.name} \"#{member.location.source}\" was droped since duplication")
|
17
19
|
end
|
18
20
|
end
|
19
21
|
drop_known_method_definition(uniq_map)
|
@@ -23,20 +25,24 @@ module Orthoses
|
|
23
25
|
private
|
24
26
|
|
25
27
|
def drop_known_method_definition(uniq_map)
|
26
|
-
|
27
|
-
if m_entry = env.class_decls[
|
28
|
+
decl_name = @decl.name.absolute!
|
29
|
+
if m_entry = @env.class_decls[decl_name]
|
28
30
|
m_entry.decls.each do |d|
|
29
31
|
d.decl.members.grep_v(RBS::AST::Members::LocationOnly).each do |member|
|
30
32
|
uniq_map.delete(member_key(member))
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
34
|
-
end
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
constants_in_uniq_map = uniq_map.select do |key, value|
|
38
|
+
value.kind_of?(RBS::AST::Declarations::Constant)
|
39
|
+
end
|
40
|
+
constants_in_uniq_map.each do |key, value|
|
41
|
+
type_name = decl_name + value.name
|
42
|
+
if @env.constant_decls[type_name]
|
43
|
+
uniq_map.delete(key)
|
44
|
+
end
|
45
|
+
end
|
40
46
|
end
|
41
47
|
|
42
48
|
def member_key(member)
|
@@ -43,7 +43,7 @@ module Orthoses
|
|
43
43
|
end
|
44
44
|
|
45
45
|
def build_super_class(primary)
|
46
|
-
return nil if primary.decl.super_class.then { |s| s.nil? || s.name.relative!.to_s.then { |n| n == "Object" || n == "Random::Base" } }
|
46
|
+
return nil if primary.decl.super_class.then { |s| s.nil? || s.name.relative!.to_s.then { |n| n == "Object" || n == "Random::Base" || n.start_with?("RBS::Unnamed") } }
|
47
47
|
|
48
48
|
context = build_context(entry: primary)
|
49
49
|
super_class_name = @resolver.resolve(primary.decl.super_class.name, context: context) || primary.decl.super_class.name
|
data/lib/orthoses/content.rb
CHANGED
@@ -35,6 +35,14 @@ module Orthoses
|
|
35
35
|
@body.concat(other)
|
36
36
|
end
|
37
37
|
|
38
|
+
def empty?
|
39
|
+
@body.empty?
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete(val)
|
43
|
+
@body.delete(val)
|
44
|
+
end
|
45
|
+
|
38
46
|
def to_rbs
|
39
47
|
auto_header
|
40
48
|
uniqed_body_string
|
@@ -45,14 +53,36 @@ module Orthoses
|
|
45
53
|
uniqed_body_decl
|
46
54
|
end
|
47
55
|
|
48
|
-
|
56
|
+
def uniq!
|
57
|
+
out = ArrayIO.new
|
58
|
+
writer = RBS::Writer.new(out: out)
|
59
|
+
to_decl.members.each do |member|
|
60
|
+
writer.write_member(member)
|
61
|
+
end
|
62
|
+
@body.replace(out.to_a)
|
63
|
+
end
|
49
64
|
|
50
65
|
def original_rbs
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
66
|
+
a = [@header]
|
67
|
+
a << " #{@body.join("\n ")}" if @body.length > 0
|
68
|
+
a << "end"
|
69
|
+
a.join("\n")
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
class ArrayIO
|
75
|
+
def initialize
|
76
|
+
@outs = []
|
77
|
+
end
|
78
|
+
|
79
|
+
def puts(line)
|
80
|
+
@outs << line
|
81
|
+
end
|
82
|
+
|
83
|
+
def to_a
|
84
|
+
@outs
|
85
|
+
end
|
56
86
|
end
|
57
87
|
|
58
88
|
def uniqed_body_string
|
@@ -1,11 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'orthoses/outputable'
|
4
|
+
|
3
5
|
module Orthoses
|
4
6
|
class CreateFileByName
|
5
|
-
|
7
|
+
prepend Outputable
|
8
|
+
|
9
|
+
def initialize(loader, base_dir:, header: nil, if: nil)
|
6
10
|
@loader = loader
|
7
11
|
@base_dir = base_dir
|
8
12
|
@header = header
|
13
|
+
@if = binding.local_variable_get(:if)
|
9
14
|
end
|
10
15
|
|
11
16
|
using(Module.new {
|
@@ -28,12 +33,15 @@ module Orthoses
|
|
28
33
|
store = @loader.call
|
29
34
|
|
30
35
|
store.each do |name, content|
|
31
|
-
|
32
|
-
content.
|
36
|
+
begin
|
37
|
+
content.uniq!
|
33
38
|
rescue NameError, LoadError => err
|
34
39
|
Orthoses.logger.error(err.inspect)
|
35
40
|
next
|
36
41
|
end
|
42
|
+
|
43
|
+
next unless @if.nil? || @if.call(name, content)
|
44
|
+
|
37
45
|
file_path = Pathname("#{@base_dir}/#{name.to_s.split('::').map(&:underscore).join('/')}.rbs")
|
38
46
|
file_path.dirname.mkpath
|
39
47
|
file_path.open('w+') do |out|
|
@@ -41,7 +49,7 @@ module Orthoses
|
|
41
49
|
out.puts @header
|
42
50
|
out.puts
|
43
51
|
end
|
44
|
-
out.puts
|
52
|
+
out.puts content.original_rbs
|
45
53
|
end
|
46
54
|
Orthoses.logger.info("Generate file to #{file_path.to_s}")
|
47
55
|
end
|
data/lib/orthoses/filter.rb
CHANGED
@@ -2,19 +2,21 @@
|
|
2
2
|
|
3
3
|
module Orthoses
|
4
4
|
# Filter current store.
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# filter stored key and value if proc return true
|
6
|
+
# use Orthoses::Filter do |name, content|
|
7
|
+
# Orthoses.rbs_defined_class?(name)
|
8
|
+
# end
|
8
9
|
class Filter
|
9
|
-
def initialize(loader, if:)
|
10
|
+
def initialize(loader, if: nil, &block)
|
10
11
|
@loader = loader
|
11
12
|
@if = binding.local_variable_get(:if)
|
13
|
+
@block = block || @if || raise(ArgumentError, "should give a block")
|
12
14
|
end
|
13
15
|
|
14
16
|
def call
|
15
17
|
@loader.call.tap do |store|
|
16
18
|
store.filter! do |name, content|
|
17
|
-
@
|
19
|
+
@block.call(name, content).tap do
|
18
20
|
Orthoses.logger.debug("Filter pass [#{name}]")
|
19
21
|
end
|
20
22
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
# TracePoint wrapper that allows setting hooks
|
5
|
+
# even if the target is undefined
|
6
|
+
# LazyTracePoint.new(:call) do |tp|
|
7
|
+
# ...
|
8
|
+
# end.enable(target: 'Class#class_attribute') do
|
9
|
+
# require 'active_support/core_ext/class/attribute'
|
10
|
+
# ...
|
11
|
+
# end
|
12
|
+
class LazyTracePoint < TracePoint
|
13
|
+
# for TracePoint target
|
14
|
+
::Module.prepend(Module.new{
|
15
|
+
def method_added(id)
|
16
|
+
super
|
17
|
+
end
|
18
|
+
})
|
19
|
+
::BasicObject.prepend(Module.new{
|
20
|
+
def singleton_method_added(id)
|
21
|
+
super
|
22
|
+
end
|
23
|
+
})
|
24
|
+
|
25
|
+
METHOD_METHOD = ::Kernel.instance_method(:method)
|
26
|
+
INSTANCE_METHOD_METHOD = ::Module.instance_method(:instance_method)
|
27
|
+
UNBOUND_NAME_METHOD = ::Module.instance_method(:name)
|
28
|
+
METHOD_ADDED_METHOD = ::Module.instance_method(:method_added)
|
29
|
+
SINGLETON_METHOD_ADDED_METHOD = ::BasicObject.instance_method(:singleton_method_added)
|
30
|
+
|
31
|
+
def initialize(*events, &block)
|
32
|
+
@mod_name = nil
|
33
|
+
@instance_method_id = nil
|
34
|
+
@singleton_method_id = nil
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
def enable(target: nil, target_line: nil, target_thread: nil, &block)
|
39
|
+
return super unless target.kind_of?(String)
|
40
|
+
|
41
|
+
case
|
42
|
+
when target.include?('#')
|
43
|
+
@mod_name, instance_method_id = target.split('#', 2)
|
44
|
+
@instance_method_id = instance_method_id.to_sym
|
45
|
+
@singleton_method_id = nil
|
46
|
+
|
47
|
+
trace_instance_method(&block)
|
48
|
+
when target.include?('.')
|
49
|
+
@mod_name, singleton_method_id = target.split('.', 2)
|
50
|
+
@singleton_method_id = singleton_method_id.to_sym
|
51
|
+
@instance_method_id = nil
|
52
|
+
|
53
|
+
trace_singleton_method(&block)
|
54
|
+
else
|
55
|
+
raise ArgumentError, "argument shuold be 'Foo#foo' or 'Foo.foo' format"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def trace_instance_method(&block)
|
62
|
+
# try to load
|
63
|
+
target = Object.const_get(@mod_name).instance_method(@instance_method_id)
|
64
|
+
enable(target: target, &block)
|
65
|
+
rescue NameError
|
66
|
+
TracePoint.new(:call) do |tp|
|
67
|
+
id = tp.binding.local_variable_get(:id)
|
68
|
+
next unless id == @instance_method_id
|
69
|
+
|
70
|
+
mod_name = UNBOUND_NAME_METHOD.bind(tp.self).call
|
71
|
+
|
72
|
+
next unless mod_name
|
73
|
+
next unless mod_name == @mod_name
|
74
|
+
|
75
|
+
enable(target: INSTANCE_METHOD_METHOD.bind(tp.self).call(id))
|
76
|
+
tp.disable
|
77
|
+
end.enable(target: METHOD_ADDED_METHOD, &block)
|
78
|
+
ensure
|
79
|
+
disable
|
80
|
+
end
|
81
|
+
|
82
|
+
def trace_singleton_method(&block)
|
83
|
+
# try to load
|
84
|
+
target = Object.const_get(@mod_name).method(@singleton_method_id)
|
85
|
+
enable(target: target, &block)
|
86
|
+
rescue NameError
|
87
|
+
TracePoint.new(:call) do |tp|
|
88
|
+
id = tp.binding.local_variable_get(:id)
|
89
|
+
next unless id == @singleton_method_id
|
90
|
+
|
91
|
+
mod_name = UNBOUND_NAME_METHOD.bind(tp.self).call
|
92
|
+
|
93
|
+
next unless mod_name
|
94
|
+
next unless mod_name == @mod_name
|
95
|
+
|
96
|
+
enable(target: METHOD_METHOD.bind(tp.self).call(id))
|
97
|
+
tp.disable
|
98
|
+
end.enable(target: SINGLETON_METHOD_ADDED_METHOD, &block)
|
99
|
+
ensure
|
100
|
+
disable
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/orthoses/load_rbs.rb
CHANGED
@@ -11,7 +11,9 @@ module Orthoses
|
|
11
11
|
|
12
12
|
def call
|
13
13
|
@loader.call.tap do |store|
|
14
|
-
|
14
|
+
paths = @paths
|
15
|
+
paths = paths.call if paths.instance_of?(Proc)
|
16
|
+
env = Content::Environment.load_from_paths(paths.to_a)
|
15
17
|
env.write_to(store: store)
|
16
18
|
end
|
17
19
|
end
|
data/lib/orthoses/mixin.rb
CHANGED
@@ -34,8 +34,6 @@ module Orthoses
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
-
store["Module"].body.delete("prepend Orthoses::Mixin::Hook")
|
38
|
-
|
39
37
|
collect_definitions(store, include, :include)
|
40
38
|
collect_definitions(store, extend, :extend)
|
41
39
|
collect_definitions(store, prepend, :prepend)
|
@@ -58,6 +56,8 @@ module Orthoses
|
|
58
56
|
mod_name = Utils.module_name(mod)
|
59
57
|
next unless mod_name
|
60
58
|
|
59
|
+
next if mod_name.start_with?("Orthoses")
|
60
|
+
|
61
61
|
known_type_params = Utils.known_type_params(mod)
|
62
62
|
next unless known_type_params.nil? || known_type_params.empty?
|
63
63
|
|
@@ -2,9 +2,8 @@
|
|
2
2
|
|
3
3
|
module Orthoses
|
4
4
|
class ObjectSpaceAll
|
5
|
-
def initialize(loader
|
5
|
+
def initialize(loader)
|
6
6
|
@loader = loader
|
7
|
-
@if = binding.local_variable_get(:if)
|
8
7
|
end
|
9
8
|
|
10
9
|
def call
|
@@ -14,7 +13,6 @@ module Orthoses
|
|
14
13
|
after_modules.each do |mod|
|
15
14
|
mod_name = Utils.module_name(mod)
|
16
15
|
next if mod_name.nil?
|
17
|
-
next unless @if.nil? || @if.call(mod)
|
18
16
|
|
19
17
|
store[mod_name]
|
20
18
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Orthoses
|
4
|
+
module Outputable
|
5
|
+
# AvoidRecursiveAncestorError is an internal middleware
|
6
|
+
# It's using on orthoses/outputable.rb
|
7
|
+
class AvoidRecursiveAncestorError
|
8
|
+
def initialize(loader)
|
9
|
+
@loader = loader
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
@loader.call.tap do |store|
|
14
|
+
object_mixins = {}
|
15
|
+
collect_mixin_recursive(store, "Object", object_mixins)
|
16
|
+
|
17
|
+
object_mixins.each_key do |object_mixin|
|
18
|
+
store[object_mixin].header = "module #{object_mixin} : BasicObject"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def collect_mixin_recursive(store, name, mixins)
|
26
|
+
store[name].to_decl.members.each do |member|
|
27
|
+
case member
|
28
|
+
when RBS::AST::Members::Mixin
|
29
|
+
member_name = member.name.relative!.to_s
|
30
|
+
mixins[member_name] = true
|
31
|
+
collect_mixin_recursive(store, member_name, mixins)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'orthoses/outputable/avoid_recursive_ancestor_error'
|
4
|
+
|
5
|
+
module Orthoses
|
6
|
+
# Module for output middleware.
|
7
|
+
# Call internal some middleware on output phase.
|
8
|
+
# class Sample
|
9
|
+
# prepend Outputable
|
10
|
+
#
|
11
|
+
# def initialize(loader)
|
12
|
+
# ...
|
13
|
+
# def call
|
14
|
+
# ...
|
15
|
+
module Outputable
|
16
|
+
def call
|
17
|
+
@loader = AvoidRecursiveAncestorError.new(@loader)
|
18
|
+
super
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Helper for find best version dir.
|
4
|
+
# Orthoses::PathHelper.best_version_paths(
|
5
|
+
# ::ActiveSupport::VERSION::STRING,
|
6
|
+
# "known_sig/activesupport")
|
7
|
+
module Orthoses
|
8
|
+
class PathHelper
|
9
|
+
class << self
|
10
|
+
def best_version_paths(current, base_dir)
|
11
|
+
new(current, base_dir).best_version_paths
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize(current, base_dir)
|
16
|
+
@current = current
|
17
|
+
@base_dir = base_dir
|
18
|
+
end
|
19
|
+
|
20
|
+
def best_version_paths
|
21
|
+
best_version = find_best_version
|
22
|
+
Dir.glob("#{@base_dir}/#{best_version}/**/*.rbs")
|
23
|
+
end
|
24
|
+
|
25
|
+
def find_best_version
|
26
|
+
current_v = Gem::Version.new(@current)
|
27
|
+
versions = version_dir
|
28
|
+
versions.reverse.bsearch { |v| v <= current_v } || versions.first
|
29
|
+
end
|
30
|
+
|
31
|
+
def version_dir
|
32
|
+
Dir.glob("#{@base_dir}/*")
|
33
|
+
.map(&File.method(:basename))
|
34
|
+
.map(&Gem::Version.method(:new))
|
35
|
+
.sort
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Orthoses
|
2
|
+
# Call `rbs prototype runtime` and add to store
|
3
|
+
# use Orthoses::RBSPrototypeRuntime,
|
4
|
+
# patterns: ['Foo::*']
|
5
|
+
class RBSPrototypeRuntime
|
6
|
+
def initialize(loader, patterns:)
|
7
|
+
@loader = loader
|
8
|
+
@patterns = patterns
|
9
|
+
end
|
10
|
+
|
11
|
+
def call
|
12
|
+
@loader.call.tap do |store|
|
13
|
+
content_env = Orthoses::Content::Environment.new
|
14
|
+
|
15
|
+
patterns = @patterns
|
16
|
+
env = RBS::Environment.new
|
17
|
+
merge = true
|
18
|
+
owners_included = []
|
19
|
+
RBS::Prototype::Runtime.new(
|
20
|
+
patterns: patterns,
|
21
|
+
env: env,
|
22
|
+
merge: merge,
|
23
|
+
owners_included: owners_included,
|
24
|
+
).decls.each do |decl|
|
25
|
+
content_env << decl
|
26
|
+
end
|
27
|
+
|
28
|
+
content_env.write_to(store: store)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/orthoses/utils.rb
CHANGED
@@ -3,13 +3,14 @@
|
|
3
3
|
module Orthoses
|
4
4
|
module Utils
|
5
5
|
def self.unautoload!
|
6
|
+
warn "`Orthoses::Utils.unautoload!` is deprecated. please use `Orthoses::Autoload` middleware instead."
|
6
7
|
ObjectSpace.each_object(Module) do |mod|
|
7
8
|
each_const_recursive(mod)
|
8
9
|
end
|
9
10
|
end
|
10
11
|
|
11
12
|
def self.each_const_recursive(root, cache: {}, on_error: nil, &block)
|
12
|
-
root.constants(false).each do |const|
|
13
|
+
root.constants(false).sort.each do |const|
|
13
14
|
val = root.const_get(const)
|
14
15
|
next if cache[const].equal?(val)
|
15
16
|
cache[const] = val
|
data/lib/orthoses/version.rb
CHANGED
data/lib/orthoses/writer.rb
CHANGED
data/lib/orthoses.rb
CHANGED
@@ -4,7 +4,6 @@ require 'rbs'
|
|
4
4
|
require 'pathname'
|
5
5
|
|
6
6
|
require_relative 'orthoses/attribute'
|
7
|
-
require_relative 'orthoses/avoid_recursive_ancestor_error'
|
8
7
|
require_relative 'orthoses/builder'
|
9
8
|
require_relative 'orthoses/call_tracer'
|
10
9
|
require_relative 'orthoses/constant'
|
@@ -15,16 +14,26 @@ require_relative 'orthoses/filter'
|
|
15
14
|
require_relative 'orthoses/mixin'
|
16
15
|
require_relative 'orthoses/load_rbs'
|
17
16
|
require_relative 'orthoses/object_space_all'
|
17
|
+
require_relative 'orthoses/outputable'
|
18
|
+
require_relative 'orthoses/path_helper'
|
18
19
|
require_relative 'orthoses/pp'
|
19
20
|
require_relative 'orthoses/rbs_prototype_rb'
|
21
|
+
require_relative 'orthoses/rbs_prototype_runtime'
|
20
22
|
require_relative 'orthoses/store'
|
21
23
|
require_relative 'orthoses/tap'
|
24
|
+
require_relative 'orthoses/autoload'
|
22
25
|
require_relative 'orthoses/utils'
|
23
26
|
require_relative 'orthoses/version'
|
24
27
|
require_relative 'orthoses/walk'
|
25
28
|
require_relative 'orthoses/writer'
|
26
29
|
|
27
30
|
module Orthoses
|
31
|
+
# Use autoload just in case there are side effects.
|
32
|
+
autoload :LazyTracePoint, 'orthoses/lazy_trace_point'
|
33
|
+
|
34
|
+
METHOD_METHOD = ::Kernel.instance_method(:method)
|
35
|
+
INSTANCE_METHOD_METHOD = ::Module.instance_method(:instance_method)
|
36
|
+
|
28
37
|
class ConstLoadError < StandardError
|
29
38
|
attr_reader :root
|
30
39
|
attr_reader :const
|
data/sig/orthoses/builder.rbs
CHANGED
data/sig/orthoses/constant.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Constant
|
4
|
-
def initialize: (Orthoses::_Call loader, strict: bool, ?if: ^(Module, Symbol, untyped) -> boolish, ?on_error: ^(Orthoses::ConstLoadError) -> void) -> void
|
4
|
+
def initialize: (Orthoses::_Call loader, ?strict: bool, ?if: ^(Module, Symbol, untyped) -> boolish | nil, ?on_error: ^(Orthoses::ConstLoadError) -> void | nil) -> void
|
5
5
|
def call: () -> Orthoses::store
|
6
6
|
@loader: Orthoses::_Call
|
7
7
|
@strict: bool
|
@@ -1,9 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Content::DuplicationChecker
|
4
|
-
def initialize: (untyped decl) -> void
|
5
|
-
def update_decl: () -> untyped
|
4
|
+
def initialize: (untyped decl, ?env: untyped?) -> void
|
5
|
+
def update_decl: () -> (nil | untyped)
|
6
6
|
private def drop_known_method_definition: (untyped uniq_map) -> untyped
|
7
|
-
private def member_to_s: (untyped member) -> untyped
|
8
7
|
private def member_key: (untyped member) -> untyped
|
9
8
|
end
|
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
class Orthoses::Content::Environment
|
4
4
|
def self.load_from_paths: (untyped paths) -> untyped
|
5
|
-
|
6
5
|
def initialize: (?constant_filter: constant_filter?, ?mixin_filter: mixin_filter?, ?attribute_filter: attribute_filter?) -> void
|
7
6
|
def <<: (RBS::AST::Declarations::t decl) -> RBS::Environment
|
8
7
|
def write_to: (store: Orthoses::store) -> void
|
data/sig/orthoses/content.rbs
CHANGED
@@ -4,10 +4,12 @@ class Orthoses::Content
|
|
4
4
|
def initialize: (name: String) -> void
|
5
5
|
def <<: (String) -> void
|
6
6
|
def concat: (Array[String]) -> void
|
7
|
+
def empty?: () -> untyped
|
8
|
+
def delete: (untyped val) -> untyped
|
7
9
|
def to_rbs: () -> String
|
8
10
|
def to_decl: () -> untyped
|
9
|
-
|
10
|
-
|
11
|
+
def uniq!: () -> untyped
|
12
|
+
def original_rbs: () -> untyped
|
11
13
|
private def uniqed_body_string: () -> String
|
12
14
|
private def uniqed_body_decl: () -> RBS::AST::Declarations::t
|
13
15
|
private def auto_header: () -> (nil | untyped)
|
data/sig/orthoses/filter.rbs
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Filter
|
4
|
-
def initialize: (Orthoses::_Call loader
|
4
|
+
def initialize: (Orthoses::_Call loader) { (String, Orthoses::Content) -> boolish } -> void
|
5
5
|
def call: () -> Orthoses::store
|
6
6
|
@loader: Orthoses::_Call
|
7
|
+
@block: ^(String, Orthoses::Content) -> boolish
|
7
8
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
|
+
|
3
|
+
class Orthoses::LazyTracePoint < ::TracePoint
|
4
|
+
def method_added: (untyped id) -> untyped
|
5
|
+
def singleton_method_added: (untyped id) -> untyped
|
6
|
+
def initialize: (*untyped events) ?{ () -> untyped } -> void
|
7
|
+
def enable: (?target: untyped?, ?target_line: untyped?, ?target_thread: untyped?) ?{ () -> untyped } -> untyped
|
8
|
+
private def trace_instance_method: () ?{ () -> untyped } -> untyped
|
9
|
+
private def trace_singleton_method: () ?{ () -> untyped } -> untyped
|
10
|
+
INSTANCE_METHOD_METHOD: UnboundMethod
|
11
|
+
METHOD_ADDED_METHOD: UnboundMethod
|
12
|
+
METHOD_METHOD: UnboundMethod
|
13
|
+
SINGLETON_METHOD_ADDED_METHOD: UnboundMethod
|
14
|
+
UNBOUND_NAME_METHOD: UnboundMethod
|
15
|
+
end
|
data/sig/orthoses/load_rbs.rbs
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::LoadRBS
|
4
|
-
def initialize: (Orthoses::_Call loader, paths:
|
4
|
+
def initialize: (Orthoses::_Call loader, paths: paths) -> void
|
5
5
|
def call: () -> Orthoses::store
|
6
|
+
type paths = Array[String] | ^() -> Array[String]
|
6
7
|
@loader: Orthoses::_Call
|
7
|
-
@paths:
|
8
|
+
@paths: paths
|
8
9
|
end
|
data/sig/orthoses/mixin/hook.rbs
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
|
-
class Orthoses::AvoidRecursiveAncestorError
|
3
|
+
class Orthoses::Outputable::AvoidRecursiveAncestorError
|
4
4
|
def initialize: (Orthoses::_Call loader) -> void
|
5
5
|
def call: () -> Orthoses::store
|
6
|
-
def
|
6
|
+
private def collect_mixin_recursive: (untyped store, untyped name, untyped mixins) -> untyped
|
7
7
|
@loader: Orthoses::_Call
|
8
8
|
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
|
+
|
3
|
+
class Orthoses::PathHelper
|
4
|
+
def self.best_version_paths: (untyped current, untyped base_dir) -> untyped
|
5
|
+
def initialize: (untyped current, untyped base_dir) -> void
|
6
|
+
def best_version_paths: () -> untyped
|
7
|
+
def find_best_version: () -> untyped
|
8
|
+
def version_dir: () -> untyped
|
9
|
+
end
|
data/sig/orthoses/utils.rbs
CHANGED
@@ -1,29 +1,17 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
module Orthoses::Utils
|
4
|
-
def self.unautoload!: () ->
|
5
|
-
|
4
|
+
def self.unautoload!: () -> untyped
|
6
5
|
def self.each_const_recursive: (Module root, ?cache: Hash[untyped, true], ?on_error: ^(Orthoses::ConstLoadError) -> void) ?{ (Module, Symbol, untyped) -> void } -> void
|
7
|
-
|
8
6
|
def self.rbs_defined_const?: (String name, ?library: (String | Array[String])?, ?collection: boolish) -> bool
|
9
|
-
|
10
7
|
def self.rbs_defined_class?: (String name, ?library: (String | Array[String])?, ?collection: boolish) -> bool
|
11
|
-
|
12
8
|
def self.rbs_type_name: (String) -> RBS::TypeName
|
13
|
-
|
14
9
|
def self.rbs_environment: (?library: String | Array[String] | nil, ?collection: boolish, ?cache: boolish) -> RBS::Environment
|
15
|
-
|
16
10
|
def self.object_to_rbs: (untyped object, strict: bool) -> String
|
17
|
-
|
18
11
|
def self.module_name: (Module mod) -> String?
|
19
|
-
|
20
12
|
def self.module_to_type_name: (Module) -> RBS::TypeName?
|
21
|
-
|
22
13
|
def self.known_type_params: (Module | String) -> Array[RBS::AST::TypeParam]?
|
23
|
-
|
24
14
|
def self.new_store: () -> Orthoses::store
|
25
|
-
|
26
15
|
UNBOUND_NAME_METHOD: UnboundMethod
|
27
|
-
|
28
16
|
attr_accessor self.rbs_collection_pathname: Pathname
|
29
17
|
end
|
data/sig/orthoses.rbs
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
module Orthoses
|
4
|
-
VERSION: "0.
|
5
|
-
|
4
|
+
VERSION: "1.0.0"
|
6
5
|
attr_accessor self.logger: ::Logger
|
7
|
-
|
8
6
|
type store = Hash[String, Orthoses::Content]
|
7
|
+
INSTANCE_METHOD_METHOD: UnboundMethod
|
8
|
+
METHOD_METHOD: UnboundMethod
|
9
9
|
end
|
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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ksss
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -41,9 +41,11 @@ files:
|
|
41
41
|
- examples/simple_middleware.rbs
|
42
42
|
- lib/orthoses.rb
|
43
43
|
- lib/orthoses/attribute.rb
|
44
|
-
- lib/orthoses/
|
44
|
+
- lib/orthoses/autoload.rb
|
45
45
|
- lib/orthoses/builder.rb
|
46
46
|
- lib/orthoses/call_tracer.rb
|
47
|
+
- lib/orthoses/call_tracer/capturable.rb
|
48
|
+
- lib/orthoses/call_tracer/lazy.rb
|
47
49
|
- lib/orthoses/constant.rb
|
48
50
|
- lib/orthoses/content.rb
|
49
51
|
- lib/orthoses/content/duplication_checker.rb
|
@@ -52,11 +54,16 @@ files:
|
|
52
54
|
- lib/orthoses/create_file_by_name.rb
|
53
55
|
- lib/orthoses/delegate_class.rb
|
54
56
|
- lib/orthoses/filter.rb
|
57
|
+
- lib/orthoses/lazy_trace_point.rb
|
55
58
|
- lib/orthoses/load_rbs.rb
|
56
59
|
- lib/orthoses/mixin.rb
|
57
60
|
- lib/orthoses/object_space_all.rb
|
61
|
+
- lib/orthoses/outputable.rb
|
62
|
+
- lib/orthoses/outputable/avoid_recursive_ancestor_error.rb
|
63
|
+
- lib/orthoses/path_helper.rb
|
58
64
|
- lib/orthoses/pp.rb
|
59
65
|
- lib/orthoses/rbs_prototype_rb.rb
|
66
|
+
- lib/orthoses/rbs_prototype_runtime.rb
|
60
67
|
- lib/orthoses/store.rb
|
61
68
|
- lib/orthoses/tap.rb
|
62
69
|
- lib/orthoses/utils.rb
|
@@ -69,14 +76,18 @@ files:
|
|
69
76
|
- sig/orthoses/_middle_ware.rbs
|
70
77
|
- sig/orthoses/attribute.rbs
|
71
78
|
- sig/orthoses/attribute/hook.rbs
|
72
|
-
- sig/orthoses/
|
79
|
+
- sig/orthoses/autoload.rbs
|
80
|
+
- sig/orthoses/autoload/hook.rbs
|
73
81
|
- sig/orthoses/builder.rbs
|
74
82
|
- sig/orthoses/builder/call_logable.rbs
|
75
83
|
- sig/orthoses/call_tracer.rbs
|
84
|
+
- sig/orthoses/call_tracer/capturable.rbs
|
76
85
|
- sig/orthoses/call_tracer/capture.rbs
|
86
|
+
- sig/orthoses/call_tracer/lazy.rbs
|
77
87
|
- sig/orthoses/const_load_error.rbs
|
78
88
|
- sig/orthoses/constant.rbs
|
79
89
|
- sig/orthoses/content.rbs
|
90
|
+
- sig/orthoses/content/array_io.rbs
|
80
91
|
- sig/orthoses/content/duplication_checker.rbs
|
81
92
|
- sig/orthoses/content/environment.rbs
|
82
93
|
- sig/orthoses/content/header_builder.rbs
|
@@ -84,13 +95,18 @@ files:
|
|
84
95
|
- sig/orthoses/delegate_class.rbs
|
85
96
|
- sig/orthoses/delegate_class/hook.rbs
|
86
97
|
- sig/orthoses/filter.rbs
|
98
|
+
- sig/orthoses/lazy_trace_point.rbs
|
87
99
|
- sig/orthoses/load_rbs.rbs
|
88
100
|
- sig/orthoses/mixin.rbs
|
89
101
|
- sig/orthoses/mixin/hook.rbs
|
90
102
|
- sig/orthoses/name_space_error.rbs
|
91
103
|
- sig/orthoses/object_space_all.rbs
|
104
|
+
- sig/orthoses/outputable.rbs
|
105
|
+
- sig/orthoses/outputable/avoid_recursive_ancestor_error.rbs
|
106
|
+
- sig/orthoses/path_helper.rbs
|
92
107
|
- sig/orthoses/pp.rbs
|
93
108
|
- sig/orthoses/rbs_prototype_rb.rbs
|
109
|
+
- sig/orthoses/rbs_prototype_runtime.rbs
|
94
110
|
- sig/orthoses/store.rbs
|
95
111
|
- sig/orthoses/tap.rbs
|
96
112
|
- sig/orthoses/utils.rbs
|
@@ -117,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
133
|
- !ruby/object:Gem::Version
|
118
134
|
version: '0'
|
119
135
|
requirements: []
|
120
|
-
rubygems_version: 3.
|
136
|
+
rubygems_version: 3.4.0.dev
|
121
137
|
signing_key:
|
122
138
|
specification_version: 4
|
123
139
|
summary: Framework for Generate RBS
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Orthoses
|
2
|
-
class AvoidRecursiveAncestorError
|
3
|
-
def initialize(loader)
|
4
|
-
@loader = loader
|
5
|
-
end
|
6
|
-
|
7
|
-
def call
|
8
|
-
@loader.call.tap do |store|
|
9
|
-
object_mixins = {}
|
10
|
-
set_object_mixins_recursive(store, "Object", object_mixins)
|
11
|
-
|
12
|
-
object_mixins.each_key do |object_mixin|
|
13
|
-
store[object_mixin].header = "module #{object_mixin} : BasicObject"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def set_object_mixins_recursive(store, name, object_mixins)
|
19
|
-
store[name].to_decl.members.each do |member|
|
20
|
-
case member
|
21
|
-
when RBS::AST::Members::Mixin
|
22
|
-
member_name = member.name.relative!.to_s
|
23
|
-
object_mixins[member_name] = true
|
24
|
-
set_object_mixins_recursive(store, member_name, object_mixins)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|