orthoses 0.4.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/examples/minitest/Rakefile +9 -1
- data/lib/orthoses/attribute.rb +98 -0
- data/lib/orthoses/avoid_recursive_ancestor_error.rb +13 -6
- data/lib/orthoses/builder.rb +1 -0
- data/lib/orthoses/constant.rb +10 -2
- data/lib/orthoses/content/duplication_checker.rb +15 -11
- data/lib/orthoses/content/environment.rb +41 -7
- data/lib/orthoses/content/header_builder.rb +2 -1
- data/lib/orthoses/load_rbs.rb +1 -8
- data/lib/orthoses/rbs_prototype_rb.rb +3 -1
- data/lib/orthoses/utils.rb +33 -7
- data/lib/orthoses/version.rb +1 -1
- data/lib/orthoses.rb +1 -0
- data/sig/orthoses/_call.rbs +1 -1
- data/sig/orthoses/attribute/hook.rbs +11 -0
- data/sig/orthoses/attribute.rbs +9 -0
- data/sig/orthoses/avoid_recursive_ancestor_error.rbs +3 -2
- data/sig/orthoses/builder/call_logable.rbs +1 -0
- data/sig/orthoses/builder.rbs +5 -0
- data/sig/orthoses/call_tracer.rbs +3 -1
- data/sig/orthoses/const_load_error.rbs +3 -2
- data/sig/orthoses/constant.rbs +5 -2
- data/sig/orthoses/content/duplication_checker.rbs +6 -0
- data/sig/orthoses/content/environment.rbs +14 -4
- data/sig/orthoses/content/header_builder.rbs +13 -0
- data/sig/orthoses/content.rbs +10 -3
- data/sig/orthoses/create_file_by_name.rbs +2 -2
- data/sig/orthoses/delegate_class.rbs +3 -2
- data/sig/orthoses/filter.rbs +2 -2
- data/sig/orthoses/load_rbs.rbs +2 -2
- data/sig/orthoses/mixin.rbs +2 -0
- data/sig/orthoses/name_space_error.rbs +1 -1
- data/sig/orthoses/object_space_all.rbs +2 -2
- data/sig/orthoses/pp.rbs +2 -0
- data/sig/orthoses/rbs_prototype_rb.rbs +3 -2
- data/sig/orthoses/store.rbs +2 -0
- data/sig/orthoses/tap.rbs +2 -2
- data/sig/orthoses/utils.rbs +6 -4
- data/sig/orthoses/walk.rbs +2 -2
- data/sig/orthoses/writer.rbs +2 -2
- data/sig/orthoses.rbs +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 894390a9b9736bc6c773da2d8522b76a47a4f345f1eb48c847b4dc2cf691cfe4
|
4
|
+
data.tar.gz: 9189fdd9d19a953227093f99cd04e8a20f258e231e40b40ed5e7582cd5ac107c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90d06b917b9fb9aa88a18bae14bd792fe85520a8d8cf9f75c8d422f080cfe992036f3b1d2b9e115f1a6ff315478899a2b275d6ae99bdd6c5598bdcc21e3ddf56
|
7
|
+
data.tar.gz: 4d134a532af9973901e87fa48d1e96d9ca1469b46fa266d548476d252f8651dce94b40ee3de799dd7aa10f5d961e06d330048b5c833af88eee536965779dd131
|
data/Gemfile.lock
CHANGED
data/examples/minitest/Rakefile
CHANGED
@@ -22,10 +22,12 @@ task :minitest => :src do
|
|
22
22
|
!Orthoses::Utils.rbs_defined_const?("#{current}::#{const}")
|
23
23
|
}
|
24
24
|
use Orthoses::Mixin
|
25
|
+
use Orthoses::Attribute
|
25
26
|
use Orthoses::RBSPrototypeRB,
|
26
27
|
paths: Dir.glob('src/lib/minitest{.rb,/*.rb}'),
|
27
28
|
constant_filter: ->(_) { false },
|
28
|
-
mixin_filter: ->(_) { false }
|
29
|
+
mixin_filter: ->(_) { false },
|
30
|
+
attribute_filter: ->(_) { false }
|
29
31
|
run ->(){
|
30
32
|
require_relative 'src/lib/minitest'
|
31
33
|
require_relative 'src/lib/minitest/test'
|
@@ -43,6 +45,12 @@ task :minitest => :src do
|
|
43
45
|
dependencies:
|
44
46
|
- name: mutex_m
|
45
47
|
YAML
|
48
|
+
tmp = out.join("kernel.rbs").read
|
49
|
+
out.join("kernel.rbs").open("w") do |f|
|
50
|
+
f.puts "%a{annotate:rdoc:skip}"
|
51
|
+
f.write tmp
|
52
|
+
end
|
53
|
+
sh "rbs annotate --gems out"
|
46
54
|
end
|
47
55
|
|
48
56
|
task default: :minitest
|
@@ -0,0 +1,98 @@
|
|
1
|
+
module Orthoses
|
2
|
+
class Attribute
|
3
|
+
module Hook
|
4
|
+
def attr(*names)
|
5
|
+
super
|
6
|
+
end
|
7
|
+
|
8
|
+
def attr_accessor(*names)
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
def attr_reader(*names)
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def attr_writer(*names)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(loader)
|
22
|
+
@loader = loader
|
23
|
+
end
|
24
|
+
|
25
|
+
def call
|
26
|
+
Module.prepend(Hook)
|
27
|
+
|
28
|
+
attr = CallTracer.new
|
29
|
+
attr_accessor = CallTracer.new
|
30
|
+
attr_reader = CallTracer.new
|
31
|
+
attr_writer = CallTracer.new
|
32
|
+
|
33
|
+
store = attr.trace(Hook.method(:attr)) do
|
34
|
+
attr_accessor.trace(Hook.method(:attr_accessor)) do
|
35
|
+
attr_reader.trace(Hook.method(:attr_reader)) do
|
36
|
+
attr_writer.trace(Hook.method(:attr_writer)) do
|
37
|
+
@loader.call
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
store["Module"].body.delete("prepend Orthoses::Attribute::Hook")
|
44
|
+
|
45
|
+
attr.result.each do |method, argument|
|
46
|
+
m = method.receiver.to_s.match(/#<Class:([\w:]+)>/)
|
47
|
+
if m && m[1]
|
48
|
+
receiver_name = m[1]
|
49
|
+
prefix = "self."
|
50
|
+
else
|
51
|
+
receiver_name = Utils.module_name(method.receiver) or next
|
52
|
+
prefix = nil
|
53
|
+
end
|
54
|
+
content = store[receiver_name]
|
55
|
+
if argument[:names][1].equal?(true)
|
56
|
+
content << "attr_accessor #{prefix}#{argument[:names][0]}: untyped"
|
57
|
+
elsif argument[:names][1].equal?(false)
|
58
|
+
content << "attr_reader #{prefix}#{argument[:names][0]}: untyped"
|
59
|
+
else
|
60
|
+
argument[:names].each do |name|
|
61
|
+
content << "attr_reader #{prefix}#{name}: untyped"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
each_definition(attr_accessor) do |receiver_name, name|
|
67
|
+
store[receiver_name] << "attr_accessor #{name}: untyped"
|
68
|
+
end
|
69
|
+
each_definition(attr_reader) do |receiver_name, name|
|
70
|
+
store[receiver_name] << "attr_reader #{name}: untyped"
|
71
|
+
end
|
72
|
+
each_definition(attr_writer) do |receiver_name, name|
|
73
|
+
store[receiver_name] << "attr_writer #{name}: untyped"
|
74
|
+
end
|
75
|
+
|
76
|
+
store
|
77
|
+
end
|
78
|
+
|
79
|
+
private
|
80
|
+
|
81
|
+
def each_definition(call_tracer)
|
82
|
+
call_tracer.result.each do |method, argument|
|
83
|
+
m = method.receiver.to_s.match(/#<Class:([\w:]+)>/)
|
84
|
+
if m && m[1]
|
85
|
+
receiver_name = m[1]
|
86
|
+
argument[:names].each do |name|
|
87
|
+
yield [receiver_name, "self.#{name}"]
|
88
|
+
end
|
89
|
+
else
|
90
|
+
receiver_name = Utils.module_name(method.receiver) or next
|
91
|
+
argument[:names].each do |name|
|
92
|
+
yield [receiver_name, name]
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -7,16 +7,23 @@ module Orthoses
|
|
7
7
|
def call
|
8
8
|
@loader.call.tap do |store|
|
9
9
|
object_mixins = {}
|
10
|
-
store
|
11
|
-
|
12
|
-
when RBS::AST::Members::Mixin
|
13
|
-
object_mixins[member.name.relative!.to_s] = true
|
14
|
-
end
|
15
|
-
end
|
10
|
+
set_object_mixins_recursive(store, "Object", object_mixins)
|
11
|
+
|
16
12
|
object_mixins.each_key do |object_mixin|
|
17
13
|
store[object_mixin].header = "module #{object_mixin} : BasicObject"
|
18
14
|
end
|
19
15
|
end
|
20
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
|
21
28
|
end
|
22
29
|
end
|
data/lib/orthoses/builder.rb
CHANGED
data/lib/orthoses/constant.rb
CHANGED
@@ -27,10 +27,14 @@ module Orthoses
|
|
27
27
|
Orthoses::Utils.each_const_recursive(base, on_error: @on_error) do |current, const, val|
|
28
28
|
next if current.singleton_class?
|
29
29
|
next if Utils.module_name(current).nil?
|
30
|
-
next if val.kind_of?(Module)
|
31
30
|
next if cache[[current, const]]
|
32
31
|
cache[[current, const]] = true
|
33
32
|
|
33
|
+
if val.kind_of?(Module)
|
34
|
+
will_add_key_and_content << [Utils.module_name(val), nil]
|
35
|
+
next
|
36
|
+
end
|
37
|
+
|
34
38
|
rbs = Orthoses::Utils.object_to_rbs(val, strict: @strict)
|
35
39
|
next unless rbs
|
36
40
|
next unless @if.nil? || @if.call(current, const, val, rbs)
|
@@ -38,8 +42,12 @@ module Orthoses
|
|
38
42
|
will_add_key_and_content << [Utils.module_name(current), "#{const}: #{rbs}"]
|
39
43
|
end
|
40
44
|
end
|
45
|
+
|
41
46
|
will_add_key_and_content.each do |name, line|
|
42
|
-
|
47
|
+
next unless name
|
48
|
+
content = store[name]
|
49
|
+
next unless line
|
50
|
+
content << line
|
43
51
|
end
|
44
52
|
end
|
45
53
|
end
|
@@ -8,16 +8,16 @@ module Orthoses
|
|
8
8
|
|
9
9
|
def update_decl
|
10
10
|
uniq_map = {}
|
11
|
-
@decl.members.
|
11
|
+
@decl.members.each do |member|
|
12
12
|
key = member_key(member)
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
drop_member = uniq_map[key]
|
14
|
+
uniq_map[key] = member
|
15
|
+
if drop_member
|
16
|
+
Orthoses.logger.warn("#{@decl.name}::#{drop_member} was droped since duplication")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
drop_known_method_definition(uniq_map)
|
20
|
-
@decl.members.replace(uniq_map.values
|
20
|
+
@decl.members.replace(uniq_map.values)
|
21
21
|
end
|
22
22
|
|
23
23
|
private
|
@@ -26,11 +26,8 @@ module Orthoses
|
|
26
26
|
env = Utils.rbs_environment(collection: true)
|
27
27
|
if m_entry = env.class_decls[@decl.name.absolute!]
|
28
28
|
m_entry.decls.each do |d|
|
29
|
-
d.decl.members.each do |member|
|
30
|
-
|
31
|
-
when RBS::AST::Members::MethodDefinition, RBS::AST::Members::Alias
|
32
|
-
uniq_map.delete(member_key(member))
|
33
|
-
end
|
29
|
+
d.decl.members.grep_v(RBS::AST::Members::LocationOnly).each do |member|
|
30
|
+
uniq_map.delete(member_key(member))
|
34
31
|
end
|
35
32
|
end
|
36
33
|
end
|
@@ -51,6 +48,13 @@ module Orthoses
|
|
51
48
|
[member.class]
|
52
49
|
when RBS::AST::Members::Alias
|
53
50
|
[RBS::AST::Members::MethodDefinition, member.new_name, member.kind]
|
51
|
+
when RBS::AST::Members::AttrAccessor
|
52
|
+
# FIXME: how to check "#{member.name}=" ?
|
53
|
+
[RBS::AST::Members::MethodDefinition, member.name, member.kind]
|
54
|
+
when RBS::AST::Members::AttrReader
|
55
|
+
[RBS::AST::Members::MethodDefinition, member.name, member.kind]
|
56
|
+
when RBS::AST::Members::AttrWriter
|
57
|
+
[RBS::AST::Members::MethodDefinition, "#{member.name}=", member.kind]
|
54
58
|
else
|
55
59
|
[member.class, member.name]
|
56
60
|
end
|
@@ -1,18 +1,31 @@
|
|
1
1
|
module Orthoses
|
2
2
|
class Content
|
3
3
|
class Environment
|
4
|
-
|
4
|
+
class << self
|
5
|
+
def load_from_paths(paths)
|
6
|
+
new.tap do |env|
|
7
|
+
paths.each do |path|
|
8
|
+
Orthoses.logger.debug("Load #{path}")
|
9
|
+
buffer = RBS::Buffer.new(name: path.to_s, content: File.read(path.to_s, encoding: "UTF-8"))
|
10
|
+
RBS::Parser.parse_signature(buffer).each do |decl|
|
11
|
+
env << decl
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize(constant_filter: nil, mixin_filter: nil, attribute_filter: nil)
|
5
19
|
@load_env = RBS::Environment.new
|
6
|
-
@known_env = Utils.rbs_environment(collection: true)
|
20
|
+
@known_env = Utils.rbs_environment(collection: true, cache: false)
|
7
21
|
@constant_filter = constant_filter
|
8
22
|
@mixin_filter = mixin_filter
|
23
|
+
@attribute_filter = attribute_filter
|
9
24
|
end
|
10
25
|
|
11
26
|
def <<(decl)
|
12
|
-
if known_class_entry = @known_env.class_decls[decl.name.absolute!]
|
13
|
-
decl.type_params.replace(known_class_entry.primary.decl.type_params)
|
14
|
-
end
|
15
27
|
@load_env << decl
|
28
|
+
@known_env << decl
|
16
29
|
rescue RBS::DuplicatedDeclarationError => err
|
17
30
|
Orthoses.logger.warn(err.inspect)
|
18
31
|
end
|
@@ -20,13 +33,15 @@ module Orthoses
|
|
20
33
|
def write_to(store:)
|
21
34
|
each do |add_content|
|
22
35
|
content = store[add_content.name]
|
23
|
-
content.header
|
36
|
+
content.header = add_content.header
|
24
37
|
content.concat(add_content.body)
|
25
38
|
end
|
26
39
|
end
|
27
40
|
|
28
41
|
def each
|
29
|
-
|
42
|
+
avoid_generic_parameter_mismatch_error
|
43
|
+
|
44
|
+
header_builder = HeaderBuilder.new(env: @known_env)
|
30
45
|
|
31
46
|
@load_env.class_decls.each do |type_name, m_entry|
|
32
47
|
name = type_name.relative!.to_s
|
@@ -49,6 +64,23 @@ module Orthoses
|
|
49
64
|
end
|
50
65
|
end
|
51
66
|
|
67
|
+
private
|
68
|
+
|
69
|
+
# Avoid `RBS::GenericParameterMismatchError` from like rbs_prototype_rb
|
70
|
+
# class Array # <= RBS::GenericParameterMismatchError
|
71
|
+
# end
|
72
|
+
def avoid_generic_parameter_mismatch_error
|
73
|
+
@known_env.class_decls.each do |type_name, m_entry|
|
74
|
+
tmp_primary_d = m_entry.decls.find { |d| !d.decl.type_params.empty? }
|
75
|
+
next unless tmp_primary_d
|
76
|
+
m_entry.decls.each do |d|
|
77
|
+
if d.decl.type_params.empty?
|
78
|
+
d.decl.type_params.replace(tmp_primary_d.decl.type_params)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
52
84
|
def decls_to_lines(decls)
|
53
85
|
out = StringIO.new
|
54
86
|
writer = RBS::Writer.new(out: out)
|
@@ -61,6 +93,8 @@ module Orthoses
|
|
61
93
|
next unless @constant_filter.nil? || @constant_filter.call(member)
|
62
94
|
when RBS::AST::Members::Mixin
|
63
95
|
next unless @mixin_filter.nil? || @mixin_filter.call(member)
|
96
|
+
when RBS::AST::Members::Attribute
|
97
|
+
next unless @attribute_filter.nil? || @attribute_filter.call(member)
|
64
98
|
end
|
65
99
|
writer.write_member(member)
|
66
100
|
end
|
@@ -48,10 +48,11 @@ module Orthoses
|
|
48
48
|
context = primary.outer.length.times.map do |i|
|
49
49
|
primary.outer[0, i + 1].map(&:name).inject(:+).to_namespace.absolute!
|
50
50
|
end
|
51
|
+
context.push(RBS::Namespace.root)
|
51
52
|
|
52
53
|
super_class_name = @resolver.resolve(primary.decl.super_class.name, context: context) || primary.decl.super_class.name
|
53
54
|
if primary.decl.super_class.args.empty?
|
54
|
-
if super_class_entry = @env.class_decls[super_class_name
|
55
|
+
if super_class_entry = @env.class_decls[super_class_name]
|
55
56
|
super_primary = super_class_entry.primary
|
56
57
|
" < #{name_and_args(super_class_name, super_primary.decl.type_params.map { :untyped })}"
|
57
58
|
else
|
data/lib/orthoses/load_rbs.rb
CHANGED
@@ -11,14 +11,7 @@ module Orthoses
|
|
11
11
|
|
12
12
|
def call
|
13
13
|
@loader.call.tap do |store|
|
14
|
-
env = Content::Environment.
|
15
|
-
@paths.each do |path|
|
16
|
-
Orthoses.logger.debug("Load #{path}")
|
17
|
-
buffer = RBS::Buffer.new(name: path.to_s, content: File.read(path.to_s, encoding: "UTF-8"))
|
18
|
-
RBS::Parser.parse_signature(buffer).each do |decl|
|
19
|
-
env << decl
|
20
|
-
end
|
21
|
-
end
|
14
|
+
env = Content::Environment.load_from_paths(@paths)
|
22
15
|
env.write_to(store: store)
|
23
16
|
end
|
24
17
|
end
|
@@ -3,11 +3,12 @@ module Orthoses
|
|
3
3
|
# use Orthoses::RBSPrototypeRB,
|
4
4
|
# paths: Dir.glob("lib/**/*.rb")
|
5
5
|
class RBSPrototypeRB
|
6
|
-
def initialize(loader, paths:, constant_filter: nil, mixin_filter: nil)
|
6
|
+
def initialize(loader, paths:, constant_filter: nil, mixin_filter: nil, attribute_filter: nil)
|
7
7
|
@loader = loader
|
8
8
|
@paths = paths
|
9
9
|
@constant_filter = constant_filter
|
10
10
|
@mixin_filter = mixin_filter
|
11
|
+
@attribute_filter = attribute_filter
|
11
12
|
end
|
12
13
|
|
13
14
|
def call
|
@@ -24,6 +25,7 @@ module Orthoses
|
|
24
25
|
env = Orthoses::Content::Environment.new(
|
25
26
|
constant_filter: @constant_filter,
|
26
27
|
mixin_filter: @mixin_filter,
|
28
|
+
attribute_filter: @attribute_filter,
|
27
29
|
)
|
28
30
|
parser.decls.each do |decl|
|
29
31
|
env << decl
|
data/lib/orthoses/utils.rb
CHANGED
@@ -46,17 +46,39 @@ module Orthoses
|
|
46
46
|
RBS::Namespace.parse(name).to_type_name
|
47
47
|
end
|
48
48
|
|
49
|
-
|
49
|
+
class << self
|
50
|
+
# Generated scripts are not always located in the root.
|
51
|
+
# By default, it follows the upper level directory from the current directory
|
52
|
+
# to find the rbs_collection.yaml file and set it to `rbs_collection_pathname`.
|
53
|
+
# It can be reconfigured if necessary.
|
54
|
+
attr_accessor :rbs_collection_pathname
|
55
|
+
end
|
56
|
+
# set default
|
57
|
+
self.rbs_collection_pathname = ->() {
|
58
|
+
begin
|
59
|
+
start = here = Dir.pwd
|
60
|
+
until ok = RBS::Collection::Config::PATH.exist?
|
61
|
+
Dir.chdir("..")
|
62
|
+
return nil if Dir.pwd == here
|
63
|
+
here = Dir.pwd
|
64
|
+
end
|
65
|
+
Pathname(here) + RBS::Collection::Config::PATH
|
66
|
+
ensure
|
67
|
+
Dir.chdir(start)
|
68
|
+
end
|
69
|
+
}.call
|
70
|
+
|
71
|
+
def self.rbs_environment(library: nil, collection: false, cache: true)
|
50
72
|
@env_cache ||= {}
|
51
|
-
if hit = @env_cache[[library, collection]]
|
73
|
+
if cache && hit = @env_cache[[library, collection]]
|
52
74
|
return hit
|
53
75
|
end
|
54
76
|
|
55
77
|
loader = RBS::EnvironmentLoader.new
|
56
78
|
|
57
|
-
if collection
|
58
|
-
|
59
|
-
loader.add_collection(
|
79
|
+
if collection && rbs_collection_pathname
|
80
|
+
config = RBS::Collection::Config.lockfile_of(rbs_collection_pathname) or raise
|
81
|
+
loader.add_collection(config)
|
60
82
|
end
|
61
83
|
|
62
84
|
case library
|
@@ -71,8 +93,9 @@ module Orthoses
|
|
71
93
|
end
|
72
94
|
end
|
73
95
|
|
74
|
-
|
75
|
-
|
96
|
+
RBS::Environment.from_loader(loader).resolve_type_names.tap do |env|
|
97
|
+
@env_cache[[library, collection]] = env if cache
|
98
|
+
end
|
76
99
|
end
|
77
100
|
|
78
101
|
def self.object_to_rbs(object, strict:)
|
@@ -121,6 +144,9 @@ module Orthoses
|
|
121
144
|
"Hash[#{keys.join(' | ')}, #{values.join(' | ')}]"
|
122
145
|
end
|
123
146
|
end
|
147
|
+
when Range
|
148
|
+
type = object_to_rbs(object.begin || object.end, strict: false)
|
149
|
+
"Range[#{type}]"
|
124
150
|
when ARGF
|
125
151
|
# see also https://github.com/ruby/rbs/pull/975
|
126
152
|
'untyped'
|
data/lib/orthoses/version.rb
CHANGED
data/lib/orthoses.rb
CHANGED
data/sig/orthoses/_call.rbs
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
|
+
|
3
|
+
module Orthoses::Attribute::Hook
|
4
|
+
def attr: (*untyped names) -> untyped
|
5
|
+
|
6
|
+
def attr_accessor: (*untyped names) -> untyped
|
7
|
+
|
8
|
+
def attr_reader: (*untyped names) -> untyped
|
9
|
+
|
10
|
+
def attr_writer: (*untyped names) -> untyped
|
11
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
|
+
|
3
|
+
class Orthoses::Attribute
|
4
|
+
def initialize: (Orthoses::_Call loader) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
private
|
7
|
+
def each_definition: (untyped call_tracer) { (untyped) -> untyped } -> untyped
|
8
|
+
@loader: Orthoses::_Call
|
9
|
+
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::AvoidRecursiveAncestorError
|
4
|
-
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
4
|
def initialize: (Orthoses::_Call loader) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
def set_object_mixins_recursive: (untyped store, untyped name, untyped object_mixins) -> untyped
|
7
|
+
@loader: Orthoses::_Call
|
7
8
|
end
|
data/sig/orthoses/builder.rbs
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Builder
|
4
|
+
def initialize: () { () -> untyped } -> void
|
5
|
+
def use: (untyped middleware, *untyped args, **untyped key) { () -> untyped } -> untyped
|
6
|
+
def run: (untyped loader) -> untyped
|
7
|
+
def to_loader: () -> untyped
|
8
|
+
|
4
9
|
def call: () { () -> void } -> Orthoses::store
|
5
10
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::CallTracer
|
4
|
-
|
4
|
+
def initialize: () -> void
|
5
|
+
|
5
6
|
def trace: [T] (Method | UnboundMethod) ?{ () -> T } -> T
|
7
|
+
attr_accessor result: Array[[ Method, Hash[Symbol, untyped] ]]
|
6
8
|
end
|
@@ -1,8 +1,9 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
|
-
class Orthoses::ConstLoadError < StandardError
|
3
|
+
class Orthoses::ConstLoadError < ::StandardError
|
4
|
+
def initialize: (root: Module, const: Symbol, error: untyped) -> void
|
5
|
+
def message: () -> ::String
|
4
6
|
attr_reader root: Module
|
5
7
|
attr_reader const: Symbol
|
6
8
|
attr_reader error: untyped
|
7
|
-
def initialize: (root: Module, const: Symbol, error: untyped) -> void
|
8
9
|
end
|
data/sig/orthoses/constant.rbs
CHANGED
@@ -1,7 +1,10 @@
|
|
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
|
5
|
+
def call: () -> Orthoses::store
|
4
6
|
@loader: Orthoses::_Call
|
5
|
-
|
6
|
-
|
7
|
+
@strict: bool
|
8
|
+
@if: ^(Module mod, Symbol const, untyped val, String rbs) -> boolish?
|
9
|
+
@on_error: ^(Orthoses::ConstLoadError) -> void | nil
|
7
10
|
end
|
@@ -1,4 +1,10 @@
|
|
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
|
6
|
+
private
|
7
|
+
def drop_known_method_definition: (untyped uniq_map) -> untyped
|
8
|
+
def member_to_s: (untyped member) -> untyped
|
9
|
+
def member_key: (untyped member) -> untyped
|
4
10
|
end
|
@@ -1,13 +1,23 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Content::Environment
|
4
|
+
def self.load_from_paths: (untyped paths) -> untyped
|
5
|
+
|
6
|
+
def initialize: (?constant_filter: constant_filter?, ?mixin_filter: mixin_filter?, ?attribute_filter: attribute_filter?) -> void
|
7
|
+
def <<: (RBS::AST::Declarations::t decl) -> RBS::Environment
|
8
|
+
def write_to: (store: Orthoses::store) -> void
|
9
|
+
def each: () { (Orthoses::Content) -> void } -> void
|
10
|
+
private
|
11
|
+
# Avoid `RBS::GenericParameterMismatchError` from like rbs_prototype_rb
|
12
|
+
# class Array # <= RBS::GenericParameterMismatchError
|
13
|
+
# end
|
14
|
+
def avoid_generic_parameter_mismatch_error: () -> untyped
|
15
|
+
def decls_to_lines: (untyped decls) -> untyped
|
4
16
|
type constant_filter = ^(RBS::AST::Declarations::Constant) -> boolish
|
5
17
|
type mixin_filter = ^(RBS::AST::Members::Mixin) -> boolish
|
18
|
+
type attribute_filter = ^(RBS::AST::Members::Attribute) -> boolish
|
6
19
|
@env: RBS::Environment
|
7
20
|
@constant_filter: constant_filter?
|
8
21
|
@mixin_filter: mixin_filter?
|
9
|
-
|
10
|
-
def <<: (RBS::AST::Declarations::t decl) -> RBS::Environment
|
11
|
-
def write_to: (store: Orthoses::store) -> void
|
12
|
-
def each: () { (Orthoses::Content) -> void } -> void
|
22
|
+
@attribute_filter: attribute_filter?
|
13
23
|
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
|
+
|
3
|
+
class Orthoses::Content::HeaderBuilder
|
4
|
+
def initialize: (env: untyped) -> void
|
5
|
+
def build: (entry: untyped, ?name_hint: untyped?) -> untyped
|
6
|
+
private
|
7
|
+
def build_module: (entry: untyped, ?name_hint: untyped?) -> ::String
|
8
|
+
def build_class: (entry: untyped, ?name_hint: untyped?) -> ::String
|
9
|
+
def build_super_class: (untyped primary) -> (nil | untyped)
|
10
|
+
def build_interface: (entry: untyped, ?name_hint: untyped?) -> ::String
|
11
|
+
def name_and_params: (untyped name, untyped params) -> ::String
|
12
|
+
def name_and_args: (untyped name, untyped args) -> (::String | nil)
|
13
|
+
end
|
data/sig/orthoses/content.rbs
CHANGED
@@ -1,14 +1,21 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Content
|
4
|
-
attr_reader name: String
|
5
|
-
attr_reader body: Array[String]
|
6
|
-
attr_accessor header: String?
|
7
4
|
def initialize: (name: String) -> void
|
8
5
|
def <<: (String) -> void
|
9
6
|
def concat: (Array[String]) -> void
|
10
7
|
def to_rbs: () -> String
|
8
|
+
def to_decl: () -> untyped
|
9
|
+
|
11
10
|
private
|
11
|
+
def original_rbs: () -> ::String
|
12
|
+
|
12
13
|
def uniqed_body_string: () -> String
|
13
14
|
def uniqed_body_decl: () -> RBS::AST::Declarations::t
|
15
|
+
def auto_header: () -> (nil | untyped)
|
16
|
+
def temporary_type_params: (untyped name) -> untyped
|
17
|
+
def type_params: (untyped name) -> untyped
|
18
|
+
attr_reader name: String
|
19
|
+
attr_reader body: Array[String]
|
20
|
+
attr_accessor header: String?
|
14
21
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::CreateFileByName
|
4
|
-
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
4
|
def initialize: (Orthoses::_Call loader, base_dir: String, ?header: String?) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
@loader: Orthoses::_Call
|
7
7
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::DelegateClass
|
4
|
-
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
4
|
def initialize: (Orthoses::_Call loader) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
def temporary_type_params: (untyped name) -> untyped
|
7
|
+
@loader: Orthoses::_Call
|
7
8
|
end
|
data/sig/orthoses/filter.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Filter
|
4
|
-
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
4
|
def initialize: (Orthoses::_Call loader, if: ^(String, Orthoses::Content) -> boolish) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
@loader: Orthoses::_Call
|
7
7
|
end
|
data/sig/orthoses/load_rbs.rbs
CHANGED
@@ -1,8 +1,8 @@
|
|
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: Array[_ToS]) -> void
|
5
|
+
def call: () -> Orthoses::store
|
4
6
|
@loader: Orthoses::_Call
|
5
7
|
@paths: Array[_ToS]
|
6
|
-
include Orthoses::_MiddleWare
|
7
|
-
def initialize: (Orthoses::_Call loader, paths: Array[_ToS]) -> void
|
8
8
|
end
|
data/sig/orthoses/mixin.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::ObjectSpaceAll
|
4
|
-
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
4
|
def initialize: (Orthoses::_Call loader, ?if: ^(Module) -> boolish) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
@loader: Orthoses::_Call
|
7
7
|
end
|
data/sig/orthoses/pp.rbs
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::RBSPrototypeRB
|
4
|
+
def initialize: (Orthoses::_Call loader, paths: Array[_ToS], ?constant_filter: Orthoses::Content::Environment::constant_filter?, ?mixin_filter: Orthoses::Content::Environment::mixin_filter?, ?attribute_filter: Orthoses::Content::Environment::attribute_filter?) -> void
|
5
|
+
def call: () -> Orthoses::store
|
4
6
|
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
|
-
def initialize: (Orthoses::_Call loader, paths: Array[_ToS], ?constant_filter: Orthoses::Content::Environment::constant_filter?, ?mixin_filter: Orthoses::Content::Environment::mixin_filter?) -> void
|
7
7
|
@paths: Array[_ToS]
|
8
8
|
@constant_filter: Orthoses::Content::Environment::constant_filter?
|
9
9
|
@mixin_filter: Orthoses::Content::Environment::mixin_filter?
|
10
|
+
@attribute_filter: Orthoses::Content::Environment::mixin_filter?
|
10
11
|
end
|
data/sig/orthoses/store.rbs
CHANGED
data/sig/orthoses/tap.rbs
CHANGED
data/sig/orthoses/utils.rbs
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
module Orthoses::Utils
|
4
|
-
UNBOUND_NAME_METHOD: UnboundMethod
|
5
|
-
|
6
4
|
def self.unautoload!: () -> void
|
7
5
|
|
8
|
-
def self.each_const_recursive: (Module root, ?cache: Hash[untyped, true], ?on_error: ^(Orthoses::ConstLoadError) -> void
|
6
|
+
def self.each_const_recursive: (Module root, ?cache: Hash[untyped, true], ?on_error: ^(Orthoses::ConstLoadError) -> void) ?{ (Module, Symbol, untyped) -> void } -> void
|
9
7
|
|
10
8
|
def self.rbs_defined_const?: (String name, ?library: (String | Array[String])?, ?collection: boolish) -> bool
|
11
9
|
|
@@ -13,7 +11,7 @@ module Orthoses::Utils
|
|
13
11
|
|
14
12
|
def self.rbs_type_name: (String) -> RBS::TypeName
|
15
13
|
|
16
|
-
def self.rbs_environment: (?library: String | Array[String] | nil, ?collection: boolish) -> RBS::Environment
|
14
|
+
def self.rbs_environment: (?library: String | Array[String] | nil, ?collection: boolish, ?cache: boolish) -> RBS::Environment
|
17
15
|
|
18
16
|
def self.object_to_rbs: (untyped object, strict: bool) -> String
|
19
17
|
|
@@ -24,4 +22,8 @@ module Orthoses::Utils
|
|
24
22
|
def self.known_type_params: (Module | String) -> Array[RBS::AST::TypeParam]
|
25
23
|
|
26
24
|
def self.new_store: () -> Orthoses::store
|
25
|
+
|
26
|
+
UNBOUND_NAME_METHOD: UnboundMethod
|
27
|
+
|
28
|
+
attr_accessor self.rbs_collection_pathname: Pathname
|
27
29
|
end
|
data/sig/orthoses/walk.rbs
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Walk
|
4
|
+
def initialize: (Orthoses::_Call loader, root: Module | String) -> void
|
5
|
+
def call: () -> Orthoses::store
|
4
6
|
@loader: Orthoses::_Call
|
5
7
|
@root: Module | String
|
6
|
-
include Orthoses::_MiddleWare
|
7
|
-
def initialize: (Orthoses::_Call loader, root: Module | String) -> void
|
8
8
|
end
|
data/sig/orthoses/writer.rbs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
class Orthoses::Writer
|
4
|
-
@loader: Orthoses::_Call
|
5
|
-
include Orthoses::_MiddleWare
|
6
4
|
def initialize: (Orthoses::_Call loader, io: _Writer) -> void
|
5
|
+
def call: () -> Orthoses::store
|
6
|
+
@loader: Orthoses::_Call
|
7
7
|
end
|
data/sig/orthoses.rbs
CHANGED
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: 0.7.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-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -40,6 +40,7 @@ files:
|
|
40
40
|
- examples/simple_middleware.rb
|
41
41
|
- examples/simple_middleware.rbs
|
42
42
|
- lib/orthoses.rb
|
43
|
+
- lib/orthoses/attribute.rb
|
43
44
|
- lib/orthoses/avoid_recursive_ancestor_error.rb
|
44
45
|
- lib/orthoses/builder.rb
|
45
46
|
- lib/orthoses/call_tracer.rb
|
@@ -66,6 +67,8 @@ files:
|
|
66
67
|
- sig/orthoses.rbs
|
67
68
|
- sig/orthoses/_call.rbs
|
68
69
|
- sig/orthoses/_middle_ware.rbs
|
70
|
+
- sig/orthoses/attribute.rbs
|
71
|
+
- sig/orthoses/attribute/hook.rbs
|
69
72
|
- sig/orthoses/avoid_recursive_ancestor_error.rbs
|
70
73
|
- sig/orthoses/builder.rbs
|
71
74
|
- sig/orthoses/builder/call_logable.rbs
|
@@ -75,6 +78,7 @@ files:
|
|
75
78
|
- sig/orthoses/content.rbs
|
76
79
|
- sig/orthoses/content/duplication_checker.rbs
|
77
80
|
- sig/orthoses/content/environment.rbs
|
81
|
+
- sig/orthoses/content/header_builder.rbs
|
78
82
|
- sig/orthoses/create_file_by_name.rbs
|
79
83
|
- sig/orthoses/delegate_class.rbs
|
80
84
|
- sig/orthoses/filter.rbs
|