orthoses 0.9.0 → 0.10.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/Gemfile +1 -0
- data/Gemfile.lock +6 -5
- data/README.md +8 -4
- data/lib/orthoses/attribute.rb +0 -2
- data/lib/orthoses/autoload.rb +37 -0
- data/lib/orthoses/content/header_builder.rb +1 -1
- data/lib/orthoses/load_rbs.rb +3 -1
- data/lib/orthoses/mixin.rb +2 -2
- 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.rb +3 -0
- data/sig/orthoses/autoload/hook.rbs +5 -0
- data/sig/orthoses/autoload.rbs +6 -0
- data/sig/orthoses/load_rbs.rbs +3 -2
- data/sig/orthoses/path_helper.rbs +9 -0
- data/sig/orthoses/rbs_prototype_runtime.rbs +6 -0
- data/sig/orthoses/utils.rbs +1 -1
- data/sig/orthoses.rbs +1 -1
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0818d6847c70769b9111a99016d92dff5d4b369485ec5df1752ac847895c077
|
4
|
+
data.tar.gz: d7b7866d290d31836a4fa860662b7abd44da2a4dd79ae0e8f0be4a3aa127cd86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae990a63a96d5d6e4c7a0053203695564451fb709fbcc139cce1d4c6dc8962a10c9bb7b78667be1eccf5dd8ccd69447da97cd011bb58beaa9cacf3dbb951e3ec
|
7
|
+
data.tar.gz: 137f461a5286b3dc9d30c9c71d91fc61f6d948d743f9151b5e9b150dd47cecbe43d6d10073eb29de633bd51f12b3d43afed8ffccf29d52278a035ecbb2757c33
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
orthoses (0.
|
4
|
+
orthoses (0.10.0)
|
5
5
|
rbs (~> 2.0)
|
6
6
|
|
7
7
|
GEM
|
@@ -21,7 +21,7 @@ GEM
|
|
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.1)
|
25
25
|
parallel (1.22.1)
|
26
26
|
parser (3.1.2.0)
|
27
27
|
ast (~> 2.4.1)
|
@@ -30,14 +30,14 @@ GEM
|
|
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.0.
|
35
|
+
steep (1.0.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)
|
@@ -54,6 +54,7 @@ DEPENDENCIES
|
|
54
54
|
activesupport
|
55
55
|
orthoses!
|
56
56
|
rake (~> 13.0)
|
57
|
+
rbs
|
57
58
|
rgot (~> 1.1)
|
58
59
|
steep
|
59
60
|
|
data/README.md
CHANGED
@@ -45,10 +45,6 @@ end.call
|
|
45
45
|
|
46
46
|
`Orthoses::Utils` is a collection of useful methods.
|
47
47
|
|
48
|
-
### Orthoses::Utils.unautoload!
|
49
|
-
|
50
|
-
Load all const by recursive.
|
51
|
-
|
52
48
|
### Orthoses::Utils.each_const_recursive
|
53
49
|
|
54
50
|
Yield const by recursive.
|
@@ -151,11 +147,19 @@ Run `rbs prototype rb` command process to `paths` option files.
|
|
151
147
|
`content_filter` option could filter with content decl.
|
152
148
|
`mixin_filter` option could filter with mixin(include, extend, prepend) decl.
|
153
149
|
|
150
|
+
### Orthoses::RBSPrototypeRuntime
|
151
|
+
|
152
|
+
Run `rbs prototype runtime` command process with `patterns` option string.
|
153
|
+
|
154
154
|
### Orthoses::AvoidRecursiveAncestorError
|
155
155
|
|
156
156
|
Mixin a module into an Object class raises `RBS::RecursiveAncestorError` when validation.
|
157
157
|
Please add this middleware then.
|
158
158
|
|
159
|
+
### Orthoses::Autoload
|
160
|
+
|
161
|
+
Force load const defined by `autoload`.
|
162
|
+
|
159
163
|
## Development
|
160
164
|
|
161
165
|
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/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
|
@@ -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/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
|
|
@@ -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.rb
CHANGED
@@ -15,10 +15,13 @@ require_relative 'orthoses/filter'
|
|
15
15
|
require_relative 'orthoses/mixin'
|
16
16
|
require_relative 'orthoses/load_rbs'
|
17
17
|
require_relative 'orthoses/object_space_all'
|
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'
|
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
|
@@ -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,7 +1,7 @@
|
|
1
1
|
# THIS IS GENERATED CODE from `$ rake generate_self_sig`
|
2
2
|
|
3
3
|
module Orthoses::Utils
|
4
|
-
def self.unautoload!: () ->
|
4
|
+
def self.unautoload!: () -> untyped
|
5
5
|
|
6
6
|
def self.each_const_recursive: (Module root, ?cache: Hash[untyped, true], ?on_error: ^(Orthoses::ConstLoadError) -> void) ?{ (Module, Symbol, untyped) -> void } -> void
|
7
7
|
|
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.10.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-06-
|
11
|
+
date: 2022-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -41,6 +41,7 @@ files:
|
|
41
41
|
- examples/simple_middleware.rbs
|
42
42
|
- lib/orthoses.rb
|
43
43
|
- lib/orthoses/attribute.rb
|
44
|
+
- lib/orthoses/autoload.rb
|
44
45
|
- lib/orthoses/avoid_recursive_ancestor_error.rb
|
45
46
|
- lib/orthoses/builder.rb
|
46
47
|
- lib/orthoses/call_tracer.rb
|
@@ -55,8 +56,10 @@ files:
|
|
55
56
|
- lib/orthoses/load_rbs.rb
|
56
57
|
- lib/orthoses/mixin.rb
|
57
58
|
- lib/orthoses/object_space_all.rb
|
59
|
+
- lib/orthoses/path_helper.rb
|
58
60
|
- lib/orthoses/pp.rb
|
59
61
|
- lib/orthoses/rbs_prototype_rb.rb
|
62
|
+
- lib/orthoses/rbs_prototype_runtime.rb
|
60
63
|
- lib/orthoses/store.rb
|
61
64
|
- lib/orthoses/tap.rb
|
62
65
|
- lib/orthoses/utils.rb
|
@@ -69,6 +72,8 @@ files:
|
|
69
72
|
- sig/orthoses/_middle_ware.rbs
|
70
73
|
- sig/orthoses/attribute.rbs
|
71
74
|
- sig/orthoses/attribute/hook.rbs
|
75
|
+
- sig/orthoses/autoload.rbs
|
76
|
+
- sig/orthoses/autoload/hook.rbs
|
72
77
|
- sig/orthoses/avoid_recursive_ancestor_error.rbs
|
73
78
|
- sig/orthoses/builder.rbs
|
74
79
|
- sig/orthoses/builder/call_logable.rbs
|
@@ -89,8 +94,10 @@ files:
|
|
89
94
|
- sig/orthoses/mixin/hook.rbs
|
90
95
|
- sig/orthoses/name_space_error.rbs
|
91
96
|
- sig/orthoses/object_space_all.rbs
|
97
|
+
- sig/orthoses/path_helper.rbs
|
92
98
|
- sig/orthoses/pp.rbs
|
93
99
|
- sig/orthoses/rbs_prototype_rb.rbs
|
100
|
+
- sig/orthoses/rbs_prototype_runtime.rbs
|
94
101
|
- sig/orthoses/store.rbs
|
95
102
|
- sig/orthoses/tap.rbs
|
96
103
|
- sig/orthoses/utils.rbs
|
@@ -117,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
124
|
- !ruby/object:Gem::Version
|
118
125
|
version: '0'
|
119
126
|
requirements: []
|
120
|
-
rubygems_version: 3.3.
|
127
|
+
rubygems_version: 3.3.16
|
121
128
|
signing_key:
|
122
129
|
specification_version: 4
|
123
130
|
summary: Framework for Generate RBS
|