orthoses 1.12.0 → 1.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +7 -2
  3. data/lib/orthoses/call_tracer/capturable.rb +19 -1
  4. data/lib/orthoses/content.rb +2 -2
  5. data/lib/orthoses/create_file_by_name.rb +25 -2
  6. data/lib/orthoses/descendants.rb +40 -0
  7. data/lib/orthoses/exclude_rbs.rb +36 -0
  8. data/lib/orthoses/rbs_prototype_runtime.rb +14 -1
  9. data/lib/orthoses/utils.rb +3 -1
  10. data/lib/orthoses/version.rb +1 -1
  11. data/lib/orthoses.rb +2 -0
  12. data/sig/orthoses/attribute.rbs +10 -0
  13. data/sig/orthoses/autoload.rbs +4 -0
  14. data/sig/orthoses/builder.rbs +4 -0
  15. data/sig/orthoses/call_tracer.rbs +37 -0
  16. data/sig/orthoses/constant.rbs +1 -1
  17. data/sig/orthoses/content.rbs +65 -0
  18. data/sig/orthoses/create_file_by_name.rbs +7 -1
  19. data/sig/orthoses/delegate_class.rbs +4 -0
  20. data/sig/orthoses/descendants.rbs +10 -0
  21. data/sig/orthoses/exclude_rbs.rbs +13 -0
  22. data/sig/orthoses/lazy_trace_point.rbs +5 -0
  23. data/sig/orthoses/missing_name.rbs +14 -0
  24. data/sig/orthoses/mixin.rbs +8 -0
  25. data/sig/orthoses/outputable.rbs +25 -0
  26. data/sig/orthoses/rbs_prototype_runtime.rbs +6 -2
  27. data/sig/orthoses/trace.rbs +42 -0
  28. data/sig/orthoses/utils.rbs +16 -0
  29. metadata +8 -29
  30. data/sig/orthoses/attribute/hook.rbs +0 -11
  31. data/sig/orthoses/autoload/hook.rbs +0 -5
  32. data/sig/orthoses/builder/call_logable.rbs +0 -5
  33. data/sig/orthoses/call_tracer/capturable.rbs +0 -9
  34. data/sig/orthoses/call_tracer/capture.rbs +0 -6
  35. data/sig/orthoses/call_tracer/lazy.rbs +0 -21
  36. data/sig/orthoses/content/array_io.rbs +0 -8
  37. data/sig/orthoses/content/duplication_checker.rbs +0 -18
  38. data/sig/orthoses/content/environment.rbs +0 -27
  39. data/sig/orthoses/content/header_builder.rbs +0 -16
  40. data/sig/orthoses/delegate_class/hook.rbs +0 -5
  41. data/sig/orthoses/lazy_trace_point/method_added_hook.rbs +0 -6
  42. data/sig/orthoses/missing_name/missing_class.rbs +0 -8
  43. data/sig/orthoses/missing_name/missing_module.rbs +0 -8
  44. data/sig/orthoses/mixin/hook.rbs +0 -9
  45. data/sig/orthoses/outputable/avoid_recursive_ancestor_error.rbs +0 -10
  46. data/sig/orthoses/outputable/constantizable_filter.rbs +0 -9
  47. data/sig/orthoses/outputable/uniq_content_body.rbs +0 -9
  48. data/sig/orthoses/trace/attribute/hook.rbs +0 -11
  49. data/sig/orthoses/trace/attribute.rbs +0 -11
  50. data/sig/orthoses/trace/method/info.rbs +0 -4
  51. data/sig/orthoses/trace/method.rbs +0 -16
  52. data/sig/orthoses/trace/targetable.rbs +0 -5
  53. data/sig/orthoses/utils/type_list.rbs +0 -14
  54. data/sig/orthoses/utils/underscore.rbs +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4cab7a047064bc63f7fdab6b3644e019dc397cb6bc17670b4acf0d18227b949
4
- data.tar.gz: 7cdf8af9f9cea0302b88095be8bd8ce98ccdc64c72cad37634de54fb3591c86d
3
+ metadata.gz: ccd997f8aa90c6f1d49fdebe0a58c2de59d0df1e7146efa5c69d7d3614927c1b
4
+ data.tar.gz: 2f02a44951ad7b654e48d21c3b4100955997f102d616c494461bbbfeefdc7cc1
5
5
  SHA512:
6
- metadata.gz: 4d58a223aa21d7dc8db739a329c9037f7158aa41ddb30c500e30636730d21fe2bfba4492d9ffea1eeebd990e593028b009df0a8f74a938c15b93ef8267090eb3
7
- data.tar.gz: 253a53938a1b1e20217e45dea9cf102ec5dfd1bb60be6b79b034da451cdd6b5f976d3c5cf5adc360201f676664bface13f3f26a0ab8d2bc780bbc0e6e78e92e8
6
+ metadata.gz: 2023496aaf266db6a0d5945a288891967fb3b61bf0b2851e270e56fc6e87398abd7bc761db2dd35dde313bd8f0c66cbfc9ede859d0b008356d4275bd9efa36fb
7
+ data.tar.gz: 622b6a3bd44b197620c5221998316d334bf47f5332a9e561df87226a8480fb4ebee1ab0ab50f7f7f5bed97fb24cc137ee5f427000004b469caadccc9987f40bb
data/README.md CHANGED
@@ -175,15 +175,20 @@ Force load const defined by `autoload`.
175
175
 
176
176
  Sort signatures by class/module.
177
177
 
178
- ## Orthoses::Trace
178
+ ### Orthoses::Trace
179
179
 
180
180
  Trace the argument and return value objects when the method is actually called and determine the type.
181
181
 
182
- ## Orthoses::MissingName
182
+ ### Orthoses::MissingName
183
183
 
184
184
  Completes undefined class/module names.
185
185
  If it is unknown whether it is a class or a module, it is defined as an empty module, and if it is a superclass, it is defined as an empty class.
186
186
 
187
+ ### Orthoses::ExcludeRBS
188
+
189
+ You can specify that the specified RBS should not be intentionally generated.
190
+ This is useful when you want to exclude handwritten RBS.
191
+
187
192
  ## Development
188
193
 
189
194
  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.
@@ -3,6 +3,17 @@
3
3
  module Orthoses
4
4
  class CallTracer
5
5
  module Capturable
6
+ module ExtractRestParameters
7
+ def __extract_rest_parameters__(*rest, **kw_rest, &block)
8
+ {
9
+ :* => rest,
10
+ :** => kw_rest,
11
+ :& => block,
12
+ :"..." => [rest, kw_rest, block]
13
+ }
14
+ end
15
+ end
16
+
6
17
  def build_capture(tp)
7
18
  Capture.new(
8
19
  method: build_method(tp),
@@ -17,11 +28,12 @@ module Orthoses
17
28
  end
18
29
 
19
30
  def build_argument(tp)
31
+ has_unnamed_parameters = false
20
32
  tp.parameters.each_with_object({}) do |op_name, hash|
21
33
  name = op_name[1]
22
34
  case name
23
35
  when :*, :**, :&, nil
24
- # skip
36
+ has_unnamed_parameters = true
25
37
  else
26
38
  hash[name] = tp.binding.local_variable_get(name).then do |var|
27
39
  case var
@@ -35,6 +47,12 @@ module Orthoses
35
47
  var
36
48
  end
37
49
  end
50
+ end.tap do |hash|
51
+ if has_unnamed_parameters
52
+ tp.binding.eval("extend ::Orthoses::CallTracer::Capturable::ExtractRestParameters")
53
+ unnamed_parameters = tp.binding.eval("__extract_rest_parameters__(...)")
54
+ hash.merge!(unnamed_parameters)
55
+ end
38
56
  end
39
57
  end
40
58
  end
@@ -136,8 +136,8 @@ module Orthoses
136
136
  @outs = []
137
137
  end
138
138
 
139
- def puts(line)
140
- @outs << line
139
+ def puts(line = nil)
140
+ @outs << (line || '')
141
141
  end
142
142
 
143
143
  def to_a
@@ -3,6 +3,11 @@
3
3
  require 'orthoses/outputable'
4
4
 
5
5
  module Orthoses
6
+ # @param to [String, nil]
7
+ # @param header [String, nil]
8
+ # @param if [Proc, nil]
9
+ # @param depth [Integer, Hash{String => Integer}, nil]
10
+ # @param rmtree [Boolean]
6
11
  class CreateFileByName
7
12
  prepend Outputable
8
13
 
@@ -43,8 +48,7 @@ module Orthoses
43
48
  @if.nil? || @if.call(name, content)
44
49
  end
45
50
  grouped = store.group_by do |name, _|
46
- splitted = name.to_s.split('::')
47
- (@depth ? splitted[0, @depth] : splitted).join('::')
51
+ extract(name)
48
52
  end
49
53
 
50
54
  grouped.each do |group_name, group|
@@ -64,5 +68,24 @@ module Orthoses
64
68
  end
65
69
  end
66
70
  end
71
+
72
+ def extract(name)
73
+ case @depth
74
+ when nil
75
+ name.to_s
76
+ when Integer
77
+ name.split('::')[0, @depth].join('::')
78
+ when Hash
79
+ found_key, found_index = @depth.find do |n, _|
80
+ name.start_with?(n)
81
+ end
82
+ case found_index
83
+ when nil
84
+ name.to_s
85
+ else
86
+ name.split('::')[0, found_index].join('::')
87
+ end
88
+ end
89
+ end
67
90
  end
68
91
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ # use Orthoses::Descendants, of: 'ApplicationJob'
5
+ class Descendants
6
+ def initialize(loader, of:)
7
+ @loader = loader
8
+ @of = of
9
+ end
10
+
11
+ def call
12
+ @loader.call.tap do |store|
13
+ super_class =
14
+ case @of
15
+ when String
16
+ Object.const_get(@of)
17
+ else
18
+ @of
19
+ end
20
+
21
+ unless super_class.kind_of?(Class)
22
+ raise "`of` option should be String or Class"
23
+ end
24
+
25
+ descendants_of(super_class).each do |descendant|
26
+ base_name = Orthoses::Utils.module_name(descendant) or next
27
+ store[base_name]
28
+ end
29
+ end
30
+ end
31
+
32
+ private
33
+
34
+ def descendants_of(klass)
35
+ ObjectSpace.each_object(klass.singleton_class).reject do |k|
36
+ k.singleton_class? || k == klass
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orthoses
4
+ # Exclude RBS from output.
5
+ # @example
6
+ # use Orthoses::ExcludeRBS, paths: Dir['sig/hand-written/**/*.rbs']
7
+ class ExcludeRBS
8
+ def initialize(loader, paths: nil, rbs: nil)
9
+ raise ArgumentError, ':paths or :rbs keyword is required' if paths.nil? && rbs.nil?
10
+
11
+ @loader = loader
12
+ @paths = paths
13
+ @rbs = rbs
14
+ end
15
+
16
+ def call
17
+ case
18
+ when @paths
19
+ @paths.each do |path|
20
+ add_signature_to_known_env(File.read(path.to_s))
21
+ end
22
+ when @rbs
23
+ add_signature_to_known_env(@rbs)
24
+ else
25
+ raise "bug"
26
+ end
27
+
28
+ @loader.call
29
+ end
30
+
31
+ def add_signature_to_known_env(rbs)
32
+ buffer, directives, decls = ::RBS::Parser.parse_signature(rbs)
33
+ Utils.rbs_environment.add_signature(buffer: buffer, directives: directives, decls: decls)
34
+ end
35
+ end
36
+ end
@@ -31,7 +31,20 @@ module Orthoses
31
31
  attribute_filter: @attribute_filter,
32
32
  )
33
33
 
34
- patterns = @patterns || store.keys
34
+ patterns = @patterns
35
+
36
+ patterns =
37
+ if patterns
38
+ patterns.flat_map do |pattern|
39
+ if pattern.respond_to?(:call)
40
+ pattern.call
41
+ else
42
+ pattern
43
+ end
44
+ end
45
+ else
46
+ store.keys
47
+ end
35
48
  env = Utils.rbs_environment
36
49
  merge = false
37
50
  owners_included = []
@@ -178,8 +178,10 @@ module Orthoses
178
178
  TypeName(name).absolute!
179
179
  when Module
180
180
  module_to_type_name(name).absolute!
181
+ when RBS::TypeName
182
+ name.absolute!
181
183
  else
182
- raise TypeError
184
+ raise TypeError, "#{name.class} is not supported yet"
183
185
  end
184
186
  rbs_environment.class_decls[type_name]&.then do |entry|
185
187
  entry.type_params
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthoses
4
- VERSION = "1.12.0"
4
+ VERSION = "1.14.0"
5
5
  end
data/lib/orthoses.rb CHANGED
@@ -13,6 +13,8 @@ module Orthoses
13
13
  autoload :Content, 'orthoses/content'
14
14
  autoload :CreateFileByName, 'orthoses/create_file_by_name'
15
15
  autoload :DelegateClass, 'orthoses/delegate_class'
16
+ autoload :Descendants, 'orthoses/descendants'
17
+ autoload :ExcludeRBS, 'orthoses/exclude_rbs'
16
18
  autoload :Filter, 'orthoses/filter'
17
19
  autoload :Mixin, 'orthoses/mixin'
18
20
  autoload :LazyTracePoint, 'orthoses/lazy_trace_point'
@@ -6,3 +6,13 @@ class Orthoses::Attribute
6
6
  def call: () -> Orthoses::store
7
7
  CALL_GRAPH: Hash[untyped, untyped]
8
8
  end
9
+
10
+ module Orthoses::Attribute::Hook
11
+ def attr: (*untyped names) -> untyped
12
+
13
+ def attr_accessor: (*untyped names) -> untyped
14
+
15
+ def attr_reader: (*untyped names) -> untyped
16
+
17
+ def attr_writer: (*untyped names) -> untyped
18
+ end
@@ -5,3 +5,7 @@ class Orthoses::Autoload
5
5
  def initialize: (untyped loader) -> void
6
6
  def call: () -> untyped
7
7
  end
8
+
9
+ module Orthoses::Autoload::Hook
10
+ def autoload: (untyped name, untyped path) -> untyped
11
+ end
@@ -19,3 +19,7 @@ class Orthoses::Builder
19
19
  def to_loader: () -> untyped
20
20
  def call: () -> Orthoses::store
21
21
  end
22
+
23
+ module Orthoses::Builder::CallLogable
24
+ def call: () -> untyped
25
+ end
@@ -7,3 +7,40 @@ class Orthoses::CallTracer
7
7
  def trace: (Method | UnboundMethod) ?{ () -> untyped } -> untyped
8
8
  attr_accessor captures: Array[Capture]
9
9
  end
10
+
11
+ module Orthoses::CallTracer::Capturable
12
+ def build_capture: (untyped tp) -> untyped
13
+
14
+ private def build_method: (untyped tp) -> untyped
15
+
16
+ private def build_argument: (untyped tp) -> untyped
17
+ end
18
+
19
+ module Orthoses::CallTracer::Capturable::ExtractRestParameters
20
+ def __extract_rest_parameters__: (*untyped rest, **untyped kw_rest) { (*untyped, **untyped) -> untyped } -> untyped
21
+ end
22
+
23
+ class Orthoses::CallTracer::Capture < ::Struct[untyped]
24
+ def method: () -> Method
25
+ def argument: () -> Hash[Symbol, untyped]
26
+ end
27
+
28
+ # CallTracer::Lazy is possible to perform a trace
29
+ # equivalent to CallTracer before method is defined.
30
+ # scope = CallTracerLazy.new
31
+ # scope.trace("ActiveRecord::Base#scope") do
32
+ # require 'active_record/all'
33
+ # @loader.call
34
+ # end
35
+ # scope.captures.each do |capture|
36
+ # capture.argument[:name]
37
+ # capture.argument[:body]
38
+ # capture.argument[:block]
39
+ # end
40
+ class Orthoses::CallTracer::Lazy
41
+ @captures: untyped
42
+ @lazy_trace_point: untyped
43
+ def initialize: () -> void
44
+ def trace: (String name) ?{ () -> untyped } -> untyped
45
+ attr_reader captures: Array[Orthoses::CallTracer::Capture]
46
+ end
@@ -3,7 +3,7 @@
3
3
  class Orthoses::Constant
4
4
  @loader: Orthoses::_Call
5
5
  @strict: bool
6
- @if: ^(Module mod, Symbol const, untyped val, String rbs) -> boolish?
6
+ @if: (^(Module mod, Symbol const, untyped val, String rbs) -> boolish)?
7
7
  @on_error: ^(Orthoses::ConstLoadError) -> void | nil
8
8
  def initialize: (Orthoses::_Call loader, ?strict: bool, ?if: ^(Module, Symbol, untyped) -> boolish | nil, ?on_error: ^(Orthoses::ConstLoadError) -> void | nil) -> void
9
9
  def call: () -> Orthoses::store
@@ -30,3 +30,68 @@ class Orthoses::Content
30
30
  attr_accessor header: String?
31
31
  attr_accessor comment: String?
32
32
  end
33
+
34
+ class Orthoses::Content::ArrayIO
35
+ @outs: untyped
36
+ def initialize: () -> void
37
+ def puts: (?untyped? line) -> untyped
38
+ def to_a: () -> untyped
39
+ end
40
+
41
+ # Check and drop duplication method, const etc...
42
+ class Orthoses::Content::DuplicationChecker
43
+ @decl: untyped
44
+ @known_env: untyped
45
+ @builder: untyped
46
+ @uniq_map: untyped
47
+ def initialize: (untyped decl, ?env: untyped?) -> void
48
+ def update_decl: () -> (nil | untyped)
49
+ private def uniq_members: () -> untyped
50
+ private def drop_by_singleton_instance: () -> untyped
51
+ private def drop_set_method_definition: () -> untyped
52
+ private def drop_known_method_definition: () -> untyped
53
+ private def drop_known_method_definition_recur: (untyped d) -> untyped
54
+ private def drop_known_const_definition: () -> untyped
55
+ private def member_key: (untyped member) -> untyped
56
+ end
57
+
58
+ class Orthoses::Content::Environment
59
+ @load_env: RBS::Environment
60
+ @known_env: RBS::Environment
61
+ @method_definition_filter: method_definition_filter?
62
+ @alias_filter: alias_filter?
63
+ @constant_filter: constant_filter?
64
+ @mixin_filter: mixin_filter?
65
+ @attribute_filter: attribute_filter?
66
+ def self.load_from_paths: (untyped paths) -> untyped
67
+ def initialize: (?method_definition_filter: method_definition_filter?, ?alias_filter: alias_filter?, ?constant_filter: constant_filter?, ?mixin_filter: mixin_filter?, ?attribute_filter: attribute_filter?) -> void
68
+ def <<: (RBS::AST::Declarations::t decl) -> self
69
+ def write_to: (store: Orthoses::store) -> void
70
+ def each: () { (Orthoses::Content) -> void } -> void
71
+ # Avoid `RBS::GenericParameterMismatchError` from like rbs_prototype_rb
72
+ # class Array # <= RBS::GenericParameterMismatchError
73
+ # end
74
+ private def avoid_generic_parameter_mismatch_error: () -> untyped
75
+ private def detect_mixin_and_build_content: (untyped decls) -> untyped
76
+ private def decls_to_lines: (untyped decls) -> untyped
77
+ type method_definition_filter = ^(RBS::AST::Members::MethodDefinition) -> boolish
78
+ type alias_filter = ^(RBS::AST::Members::Alias) -> boolish
79
+ type constant_filter = ^(RBS::AST::Declarations::Constant) -> boolish
80
+ type mixin_filter = ^(RBS::AST::Members::Mixin) -> boolish
81
+ type attribute_filter = ^(RBS::AST::Members::Attribute) -> boolish
82
+ end
83
+
84
+ class Orthoses::Content::HeaderBuilder
85
+ @env: untyped
86
+ @resolver: untyped
87
+ def initialize: (env: untyped) -> void
88
+ def build: (entry: untyped, ?name_hint: untyped?) -> untyped
89
+ private def build_module: (entry: untyped, ?name_hint: untyped?) -> ::String
90
+ private def build_class: (entry: untyped, ?name_hint: untyped?) -> ::String
91
+ private def build_super_class: (untyped primary) -> (nil | untyped)
92
+ private def build_interface: (entry: untyped, ?name_hint: untyped?) -> ::String
93
+ private def build_context: (entry: untyped) -> untyped
94
+ private def name_and_params: (untyped name, untyped params) -> ::String
95
+ private def name_and_args: (untyped name, untyped args) -> (::String | nil)
96
+ include RBS::Environment::ContextUtil
97
+ end
@@ -1,5 +1,10 @@
1
1
  # THIS IS GENERATED CODE from `$ rake sig`
2
2
 
3
+ # @param to [String, nil]
4
+ # @param header [String, nil]
5
+ # @param if [Proc, nil]
6
+ # @param depth [Integer, Hash{String => Integer}, nil]
7
+ # @param rmtree [Boolean]
3
8
  class Orthoses::CreateFileByName
4
9
  @loader: Orthoses::_Call
5
10
  @to: untyped
@@ -7,6 +12,7 @@ class Orthoses::CreateFileByName
7
12
  @depth: untyped
8
13
  @rmtree: untyped
9
14
  @if: untyped
10
- def initialize: (Orthoses::_Call loader, to: String, ?header: String?, ?depth: Integer?, ?rmtree: boolish) -> void
15
+ def initialize: (Orthoses::_Call loader, to: String, ?header: String?, ?depth: Integer | Hash[String, Integer] | nil, ?rmtree: boolish) -> void
11
16
  def call: () -> Orthoses::store
17
+ def extract: (untyped name) -> untyped
12
18
  end
@@ -6,3 +6,7 @@ class Orthoses::DelegateClass
6
6
  def call: () -> Orthoses::store
7
7
  def temporary_type_params: (untyped name) -> untyped
8
8
  end
9
+
10
+ module Orthoses::DelegateClass::Hook
11
+ def inherited: (untyped subclass) -> untyped
12
+ end
@@ -0,0 +1,10 @@
1
+ # THIS IS GENERATED CODE from `$ rake sig`
2
+
3
+ # use Orthoses::Descendants, of: 'ApplicationJob'
4
+ class Orthoses::Descendants
5
+ @loader: untyped
6
+ @of: untyped
7
+ def initialize: (untyped loader, of: untyped) -> void
8
+ def call: () -> untyped
9
+ private def descendants_of: (untyped klass) -> untyped
10
+ end
@@ -0,0 +1,13 @@
1
+ # THIS IS GENERATED CODE from `$ rake sig`
2
+
3
+ # Exclude RBS from output.
4
+ # @example
5
+ # use Orthoses::ExcludeRBS, paths: Dir['sig/hand-written/**/*.rbs']
6
+ class Orthoses::ExcludeRBS
7
+ @loader: untyped
8
+ @paths: untyped
9
+ @rbs: untyped
10
+ def initialize: (untyped loader, ?paths: untyped?, ?rbs: untyped?) -> void
11
+ def call: () -> untyped
12
+ def add_signature_to_known_env: (untyped rbs) -> untyped
13
+ end
@@ -21,3 +21,8 @@ class Orthoses::LazyTracePoint < ::TracePoint
21
21
  SINGLETON_METHOD_ADDED_HOOKS: Hash[untyped, untyped]
22
22
  UNBOUND_NAME_METHOD: UnboundMethod
23
23
  end
24
+
25
+ # for TracePoint target
26
+ module Orthoses::LazyTracePoint::MethodAddedHook
27
+ def method_added: (untyped id) -> untyped
28
+ end
@@ -5,3 +5,17 @@ class Orthoses::MissingName
5
5
  def initialize: (untyped loader) -> void
6
6
  def call: () -> untyped
7
7
  end
8
+
9
+ class Orthoses::MissingName::MissingClass
10
+ @store: untyped
11
+ def initialize: (untyped store) -> void
12
+ def call: () -> untyped
13
+ private def recur: (untyped content) -> untyped
14
+ end
15
+
16
+ class Orthoses::MissingName::MissingModule
17
+ @store: untyped
18
+ def initialize: (untyped store) -> void
19
+ def call: () -> untyped
20
+ private def split_name: (untyped key_name) -> untyped
21
+ end
@@ -8,3 +8,11 @@ class Orthoses::Mixin
8
8
  private def type_params_sig: (untyped mod) -> String
9
9
  CALL_GRAPH: Hash[untyped, [ :include | :extend | :prepend, untyped ]]
10
10
  end
11
+
12
+ module Orthoses::Mixin::Hook : Module
13
+ def include: (*untyped modules) -> untyped
14
+
15
+ def extend: (*untyped modules) -> untyped
16
+
17
+ def prepend: (*untyped modules) -> untyped
18
+ end
@@ -5,3 +5,28 @@ module Orthoses::Outputable
5
5
 
6
6
  def call: () -> untyped
7
7
  end
8
+
9
+ # AvoidRecursiveAncestorError is an internal middleware
10
+ # It's using on orthoses/outputable.rb
11
+ class Orthoses::Outputable::AvoidRecursiveAncestorError
12
+ @loader: Orthoses::_Call
13
+ def initialize: (Orthoses::_Call loader) -> void
14
+ def call: () -> Orthoses::store
15
+ private def collect_mixin_recursive: (untyped store, untyped name, untyped mixins) -> untyped
16
+ end
17
+
18
+ # Constantizable is an internal middleware
19
+ # It's using on orthoses/outputable.rb
20
+ class Orthoses::Outputable::ConstantizableFilter
21
+ @loader: untyped
22
+ def initialize: (untyped loader) -> void
23
+ def call: () -> untyped
24
+ end
25
+
26
+ # UniqContentBody is an internal middleware
27
+ # It's using on orthoses/outputable.rb
28
+ class Orthoses::Outputable::UniqContentBody
29
+ @loader: untyped
30
+ def initialize: (untyped loader) -> void
31
+ def call: () -> untyped
32
+ end
@@ -5,12 +5,16 @@
5
5
  # patterns: ['Foo::*']
6
6
  class Orthoses::RBSPrototypeRuntime
7
7
  @loader: Orthoses::_Call
8
- @patterns: Array[_ToS]?
8
+ @patterns: Array[_ToS & Object | _Call & Object]?
9
9
  @method_definition_filter: Orthoses::Content::Environment::method_definition_filter?
10
10
  @alias_filter: Orthoses::Content::Environment::alias_filter?
11
11
  @constant_filter: Orthoses::Content::Environment::constant_filter?
12
12
  @mixin_filter: Orthoses::Content::Environment::mixin_filter?
13
13
  @attribute_filter: Orthoses::Content::Environment::attribute_filter?
14
- def initialize: (Orthoses::_Call loader, ?patterns: Array[_ToS], ?method_definition_filter: Orthoses::Content::Environment::method_definition_filter?, ?alias_filter: Orthoses::Content::Environment::alias_filter?, ?constant_filter: Orthoses::Content::Environment::constant_filter?, ?mixin_filter: Orthoses::Content::Environment::mixin_filter?, ?attribute_filter: Orthoses::Content::Environment::attribute_filter?) -> void
14
+ def initialize: (Orthoses::_Call loader, ?patterns: Array[_ToS & Object | _Call & Object]?, ?method_definition_filter: Orthoses::Content::Environment::method_definition_filter?, ?alias_filter: Orthoses::Content::Environment::alias_filter?, ?constant_filter: Orthoses::Content::Environment::constant_filter?, ?mixin_filter: Orthoses::Content::Environment::mixin_filter?, ?attribute_filter: Orthoses::Content::Environment::attribute_filter?) -> void
15
15
  def call: () -> Orthoses::store
16
16
  end
17
+
18
+ interface Orthoses::RBSPrototypeRuntime::_Call
19
+ def call: () -> (Array[String] | String)
20
+ end
@@ -6,3 +6,45 @@ class Orthoses::Trace
6
6
  def initialize: (untyped loader, patterns: untyped) -> void
7
7
  def call: () -> untyped
8
8
  end
9
+
10
+ class Orthoses::Trace::Attribute
11
+ @loader: untyped
12
+ @patterns: untyped
13
+ @captured_dict: untyped
14
+ def initialize: (untyped loader, patterns: untyped) -> void
15
+ def call: () -> untyped
16
+ private def build_trace_hook: () -> untyped
17
+ include Orthoses::Trace::Targetable
18
+ end
19
+
20
+ module Orthoses::Trace::Attribute::Hook
21
+ def attr: (*untyped names) -> untyped
22
+
23
+ def attr_accessor: (*untyped names) -> untyped
24
+
25
+ def attr_reader: (*untyped names) -> untyped
26
+
27
+ def attr_writer: (*untyped names) -> untyped
28
+ end
29
+
30
+ class Orthoses::Trace::Method
31
+ @loader: untyped
32
+ @patterns: untyped
33
+ @stack: untyped
34
+ @args_return_map: untyped
35
+ @alias_map: untyped
36
+ def initialize: (untyped loader, patterns: untyped) -> void
37
+ def call: () -> untyped
38
+ private def build_trace_point: () -> untyped
39
+ private def build_members: () -> untyped
40
+ private def build_method_definitions: () -> untyped
41
+ private def build_aliases: () -> untyped
42
+ include Orthoses::Trace::Targetable
43
+ end
44
+
45
+ class Orthoses::Trace::Method::Info < ::Struct[untyped]
46
+ end
47
+
48
+ module Orthoses::Trace::Targetable
49
+ def target?: (untyped name) -> untyped
50
+ end
@@ -27,3 +27,19 @@ module Orthoses::Utils
27
27
 
28
28
  UNBOUND_NAME_METHOD: UnboundMethod
29
29
  end
30
+
31
+ # internal
32
+ class Orthoses::Utils::TypeList
33
+ @types: untyped
34
+ def initialize: (untyped types) -> void
35
+ def inject: () -> untyped
36
+ private def normalize: () -> self
37
+ BOOL_TYPE: RBS::Types::Bases::Bool
38
+ FALSE_TYPE: RBS::Types::Literal
39
+ NIL_TYPE: RBS::Types::Bases::Nil
40
+ TRUE_TYPE: RBS::Types::Literal
41
+ UNTYPED: RBS::Types::Bases::Any
42
+ end
43
+
44
+ module Orthoses::Utils::Underscore
45
+ 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: 1.12.0
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ksss
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-09-21 00:00:00.000000000 Z
11
+ date: 2024-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -48,6 +48,8 @@ files:
48
48
  - lib/orthoses/content/header_builder.rb
49
49
  - lib/orthoses/create_file_by_name.rb
50
50
  - lib/orthoses/delegate_class.rb
51
+ - lib/orthoses/descendants.rb
52
+ - lib/orthoses/exclude_rbs.rb
51
53
  - lib/orthoses/filter.rb
52
54
  - lib/orthoses/lazy_trace_point.rb
53
55
  - lib/orthoses/load_rbs.rb
@@ -79,40 +81,24 @@ files:
79
81
  - sig/orthoses/_call.rbs
80
82
  - sig/orthoses/_middle_ware.rbs
81
83
  - sig/orthoses/attribute.rbs
82
- - sig/orthoses/attribute/hook.rbs
83
84
  - sig/orthoses/autoload.rbs
84
- - sig/orthoses/autoload/hook.rbs
85
85
  - sig/orthoses/builder.rbs
86
- - sig/orthoses/builder/call_logable.rbs
87
86
  - sig/orthoses/call_tracer.rbs
88
- - sig/orthoses/call_tracer/capturable.rbs
89
- - sig/orthoses/call_tracer/capture.rbs
90
- - sig/orthoses/call_tracer/lazy.rbs
91
87
  - sig/orthoses/const_load_error.rbs
92
88
  - sig/orthoses/constant.rbs
93
89
  - sig/orthoses/content.rbs
94
- - sig/orthoses/content/array_io.rbs
95
- - sig/orthoses/content/duplication_checker.rbs
96
- - sig/orthoses/content/environment.rbs
97
- - sig/orthoses/content/header_builder.rbs
98
90
  - sig/orthoses/create_file_by_name.rbs
99
91
  - sig/orthoses/delegate_class.rbs
100
- - sig/orthoses/delegate_class/hook.rbs
92
+ - sig/orthoses/descendants.rbs
93
+ - sig/orthoses/exclude_rbs.rbs
101
94
  - sig/orthoses/filter.rbs
102
95
  - sig/orthoses/lazy_trace_point.rbs
103
- - sig/orthoses/lazy_trace_point/method_added_hook.rbs
104
96
  - sig/orthoses/load_rbs.rbs
105
97
  - sig/orthoses/missing_name.rbs
106
- - sig/orthoses/missing_name/missing_class.rbs
107
- - sig/orthoses/missing_name/missing_module.rbs
108
98
  - sig/orthoses/mixin.rbs
109
- - sig/orthoses/mixin/hook.rbs
110
99
  - sig/orthoses/name_space_error.rbs
111
100
  - sig/orthoses/object_space_all.rbs
112
101
  - sig/orthoses/outputable.rbs
113
- - sig/orthoses/outputable/avoid_recursive_ancestor_error.rbs
114
- - sig/orthoses/outputable/constantizable_filter.rbs
115
- - sig/orthoses/outputable/uniq_content_body.rbs
116
102
  - sig/orthoses/path_helper.rbs
117
103
  - sig/orthoses/pp.rbs
118
104
  - sig/orthoses/rbs_prototype_rb.rbs
@@ -121,14 +107,7 @@ files:
121
107
  - sig/orthoses/store.rbs
122
108
  - sig/orthoses/tap.rbs
123
109
  - sig/orthoses/trace.rbs
124
- - sig/orthoses/trace/attribute.rbs
125
- - sig/orthoses/trace/attribute/hook.rbs
126
- - sig/orthoses/trace/method.rbs
127
- - sig/orthoses/trace/method/info.rbs
128
- - sig/orthoses/trace/targetable.rbs
129
110
  - sig/orthoses/utils.rbs
130
- - sig/orthoses/utils/type_list.rbs
131
- - sig/orthoses/utils/underscore.rbs
132
111
  - sig/orthoses/walk.rbs
133
112
  - sig/orthoses/writer.rbs
134
113
  homepage: https://github.com/ksss/orthoses
@@ -145,14 +124,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
124
  requirements:
146
125
  - - ">="
147
126
  - !ruby/object:Gem::Version
148
- version: 2.6.0
127
+ version: 3.0.0
149
128
  required_rubygems_version: !ruby/object:Gem::Requirement
150
129
  requirements:
151
130
  - - ">="
152
131
  - !ruby/object:Gem::Version
153
132
  version: '0'
154
133
  requirements: []
155
- rubygems_version: 3.4.10
134
+ rubygems_version: 3.5.11
156
135
  signing_key:
157
136
  specification_version: 4
158
137
  summary: Framework for Generate RBS
@@ -1,11 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake 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
@@ -1,5 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Autoload::Hook
4
- def autoload: (untyped name, untyped path) -> untyped
5
- end
@@ -1,5 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Builder::CallLogable
4
- def call: () -> untyped
5
- end
@@ -1,9 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::CallTracer::Capturable
4
- def build_capture: (untyped tp) -> untyped
5
-
6
- private def build_method: (untyped tp) -> untyped
7
-
8
- private def build_argument: (untyped tp) -> untyped
9
- end
@@ -1,6 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::CallTracer::Capture < ::Struct[untyped]
4
- def method: () -> Method
5
- def argument: () -> Hash[Symbol, untyped]
6
- end
@@ -1,21 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # CallTracer::Lazy is possible to perform a trace
4
- # equivalent to CallTracer before method is defined.
5
- # scope = CallTracerLazy.new
6
- # scope.trace("ActiveRecord::Base#scope") do
7
- # require 'active_record/all'
8
- # @loader.call
9
- # end
10
- # scope.captures.each do |capture|
11
- # capture.argument[:name]
12
- # capture.argument[:body]
13
- # capture.argument[:block]
14
- # end
15
- class Orthoses::CallTracer::Lazy
16
- @captures: untyped
17
- @lazy_trace_point: untyped
18
- def initialize: () -> void
19
- def trace: (String name) ?{ () -> untyped } -> untyped
20
- attr_reader captures: Array[Orthoses::CallTracer::Capture]
21
- end
@@ -1,8 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::Content::ArrayIO
4
- @outs: untyped
5
- def initialize: () -> void
6
- def puts: (untyped line) -> untyped
7
- def to_a: () -> untyped
8
- end
@@ -1,18 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # Check and drop duplication method, const etc...
4
- class Orthoses::Content::DuplicationChecker
5
- @decl: untyped
6
- @known_env: untyped
7
- @builder: untyped
8
- @uniq_map: untyped
9
- def initialize: (untyped decl, ?env: untyped?) -> void
10
- def update_decl: () -> (nil | untyped)
11
- private def uniq_members: () -> untyped
12
- private def drop_by_singleton_instance: () -> untyped
13
- private def drop_set_method_definition: () -> untyped
14
- private def drop_known_method_definition: () -> untyped
15
- private def drop_known_method_definition_recur: (untyped d) -> untyped
16
- private def drop_known_const_definition: () -> untyped
17
- private def member_key: (untyped member) -> untyped
18
- end
@@ -1,27 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::Content::Environment
4
- @load_env: RBS::Environment
5
- @known_env: RBS::Environment
6
- @method_definition_filter: method_definition_filter?
7
- @alias_filter: alias_filter?
8
- @constant_filter: constant_filter?
9
- @mixin_filter: mixin_filter?
10
- @attribute_filter: attribute_filter?
11
- def self.load_from_paths: (untyped paths) -> untyped
12
- def initialize: (?method_definition_filter: method_definition_filter?, ?alias_filter: alias_filter?, ?constant_filter: constant_filter?, ?mixin_filter: mixin_filter?, ?attribute_filter: attribute_filter?) -> void
13
- def <<: (RBS::AST::Declarations::t decl) -> self
14
- def write_to: (store: Orthoses::store) -> void
15
- def each: () { (Orthoses::Content) -> void } -> void
16
- # Avoid `RBS::GenericParameterMismatchError` from like rbs_prototype_rb
17
- # class Array # <= RBS::GenericParameterMismatchError
18
- # end
19
- private def avoid_generic_parameter_mismatch_error: () -> untyped
20
- private def detect_mixin_and_build_content: (untyped decls) -> untyped
21
- private def decls_to_lines: (untyped decls) -> untyped
22
- type method_definition_filter = ^(RBS::AST::Members::MethodDefinition) -> boolish
23
- type alias_filter = ^(RBS::AST::Members::Alias) -> boolish
24
- type constant_filter = ^(RBS::AST::Declarations::Constant) -> boolish
25
- type mixin_filter = ^(RBS::AST::Members::Mixin) -> boolish
26
- type attribute_filter = ^(RBS::AST::Members::Attribute) -> boolish
27
- end
@@ -1,16 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::Content::HeaderBuilder
4
- @env: untyped
5
- @resolver: untyped
6
- def initialize: (env: untyped) -> void
7
- def build: (entry: untyped, ?name_hint: untyped?) -> untyped
8
- private def build_module: (entry: untyped, ?name_hint: untyped?) -> ::String
9
- private def build_class: (entry: untyped, ?name_hint: untyped?) -> ::String
10
- private def build_super_class: (untyped primary) -> (nil | untyped)
11
- private def build_interface: (entry: untyped, ?name_hint: untyped?) -> ::String
12
- private def build_context: (entry: untyped) -> untyped
13
- private def name_and_params: (untyped name, untyped params) -> ::String
14
- private def name_and_args: (untyped name, untyped args) -> (::String | nil)
15
- include RBS::Environment::ContextUtil
16
- end
@@ -1,5 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::DelegateClass::Hook
4
- def inherited: (untyped subclass) -> untyped
5
- end
@@ -1,6 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # for TracePoint target
4
- module Orthoses::LazyTracePoint::MethodAddedHook
5
- def method_added: (untyped id) -> untyped
6
- end
@@ -1,8 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::MissingName::MissingClass
4
- @store: untyped
5
- def initialize: (untyped store) -> void
6
- def call: () -> untyped
7
- private def recur: (untyped content) -> untyped
8
- end
@@ -1,8 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::MissingName::MissingModule
4
- @store: untyped
5
- def initialize: (untyped store) -> void
6
- def call: () -> untyped
7
- private def split_name: (untyped key_name) -> untyped
8
- end
@@ -1,9 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Mixin::Hook : Module
4
- def include: (*untyped modules) -> untyped
5
-
6
- def extend: (*untyped modules) -> untyped
7
-
8
- def prepend: (*untyped modules) -> untyped
9
- end
@@ -1,10 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # AvoidRecursiveAncestorError is an internal middleware
4
- # It's using on orthoses/outputable.rb
5
- class Orthoses::Outputable::AvoidRecursiveAncestorError
6
- @loader: Orthoses::_Call
7
- def initialize: (Orthoses::_Call loader) -> void
8
- def call: () -> Orthoses::store
9
- private def collect_mixin_recursive: (untyped store, untyped name, untyped mixins) -> untyped
10
- end
@@ -1,9 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # Constantizable is an internal middleware
4
- # It's using on orthoses/outputable.rb
5
- class Orthoses::Outputable::ConstantizableFilter
6
- @loader: untyped
7
- def initialize: (untyped loader) -> void
8
- def call: () -> untyped
9
- end
@@ -1,9 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # UniqContentBody is an internal middleware
4
- # It's using on orthoses/outputable.rb
5
- class Orthoses::Outputable::UniqContentBody
6
- @loader: untyped
7
- def initialize: (untyped loader) -> void
8
- def call: () -> untyped
9
- end
@@ -1,11 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Trace::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
@@ -1,11 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::Trace::Attribute
4
- @loader: untyped
5
- @patterns: untyped
6
- @captured_dict: untyped
7
- def initialize: (untyped loader, patterns: untyped) -> void
8
- def call: () -> untyped
9
- private def build_trace_hook: () -> untyped
10
- include Orthoses::Trace::Targetable
11
- end
@@ -1,4 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::Trace::Method::Info < ::Struct[untyped]
4
- end
@@ -1,16 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- class Orthoses::Trace::Method
4
- @loader: untyped
5
- @patterns: untyped
6
- @stack: untyped
7
- @args_return_map: untyped
8
- @alias_map: untyped
9
- def initialize: (untyped loader, patterns: untyped) -> void
10
- def call: () -> untyped
11
- private def build_trace_point: () -> untyped
12
- private def build_members: () -> untyped
13
- private def build_method_definitions: () -> untyped
14
- private def build_aliases: () -> untyped
15
- include Orthoses::Trace::Targetable
16
- end
@@ -1,5 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Trace::Targetable
4
- def target?: (untyped name) -> untyped
5
- end
@@ -1,14 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- # internal
4
- class Orthoses::Utils::TypeList
5
- @types: untyped
6
- def initialize: (untyped types) -> void
7
- def inject: () -> untyped
8
- private def normalize: () -> self
9
- BOOL_TYPE: RBS::Types::Bases::Bool
10
- FALSE_TYPE: RBS::Types::Literal
11
- NIL_TYPE: RBS::Types::Bases::Nil
12
- TRUE_TYPE: RBS::Types::Literal
13
- UNTYPED: RBS::Types::Bases::Any
14
- end
@@ -1,4 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Utils::Underscore
4
- end