orthoses 1.11.0 → 1.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/lib/orthoses/call_tracer/capturable.rb +19 -1
  3. data/lib/orthoses/content.rb +5 -5
  4. data/lib/orthoses/descendants.rb +40 -0
  5. data/lib/orthoses/rbs_prototype_runtime.rb +15 -2
  6. data/lib/orthoses/utils/type_list.rb +36 -9
  7. data/lib/orthoses/utils.rb +3 -1
  8. data/lib/orthoses/version.rb +1 -1
  9. data/lib/orthoses.rb +1 -0
  10. data/sig/orthoses/attribute.rbs +10 -0
  11. data/sig/orthoses/autoload.rbs +4 -0
  12. data/sig/orthoses/builder.rbs +4 -0
  13. data/sig/orthoses/call_tracer.rbs +37 -0
  14. data/sig/orthoses/content.rbs +65 -0
  15. data/sig/orthoses/delegate_class.rbs +4 -0
  16. data/sig/orthoses/descendants.rbs +10 -0
  17. data/sig/orthoses/lazy_trace_point.rbs +5 -0
  18. data/sig/orthoses/missing_name.rbs +14 -0
  19. data/sig/orthoses/mixin.rbs +8 -0
  20. data/sig/orthoses/outputable.rbs +25 -0
  21. data/sig/orthoses/rbs_prototype_runtime.rbs +6 -2
  22. data/sig/orthoses/trace.rbs +42 -0
  23. data/sig/orthoses/utils.rbs +16 -0
  24. metadata +5 -28
  25. data/sig/orthoses/attribute/hook.rbs +0 -11
  26. data/sig/orthoses/autoload/hook.rbs +0 -5
  27. data/sig/orthoses/builder/call_logable.rbs +0 -5
  28. data/sig/orthoses/call_tracer/capturable.rbs +0 -9
  29. data/sig/orthoses/call_tracer/capture.rbs +0 -6
  30. data/sig/orthoses/call_tracer/lazy.rbs +0 -21
  31. data/sig/orthoses/content/array_io.rbs +0 -8
  32. data/sig/orthoses/content/duplication_checker.rbs +0 -18
  33. data/sig/orthoses/content/environment.rbs +0 -27
  34. data/sig/orthoses/content/header_builder.rbs +0 -16
  35. data/sig/orthoses/delegate_class/hook.rbs +0 -5
  36. data/sig/orthoses/lazy_trace_point/method_added_hook.rbs +0 -6
  37. data/sig/orthoses/missing_name/missing_class.rbs +0 -8
  38. data/sig/orthoses/missing_name/missing_module.rbs +0 -8
  39. data/sig/orthoses/mixin/hook.rbs +0 -9
  40. data/sig/orthoses/outputable/avoid_recursive_ancestor_error.rbs +0 -10
  41. data/sig/orthoses/outputable/constantizable_filter.rbs +0 -9
  42. data/sig/orthoses/outputable/uniq_content_body.rbs +0 -9
  43. data/sig/orthoses/trace/attribute/hook.rbs +0 -11
  44. data/sig/orthoses/trace/attribute.rbs +0 -11
  45. data/sig/orthoses/trace/method/info.rbs +0 -4
  46. data/sig/orthoses/trace/method.rbs +0 -16
  47. data/sig/orthoses/trace/targetable.rbs +0 -5
  48. data/sig/orthoses/utils/type_list.rbs +0 -12
  49. data/sig/orthoses/utils/underscore.rbs +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a6942bb06928e29ae619e8dfd3f92ac603bda3d0feda99dafd309c4eb493327
4
- data.tar.gz: 6affe9ebc4d0b1a3ec31c9192e271ee6a2b35765ad6c753c58fc2310fb6155ae
3
+ metadata.gz: 23443bbc790318672ea55f35fa859be2850d01abacd34f4274944c3bdc0bffab
4
+ data.tar.gz: a92d9b0d889bb0fdbebfb643adf7471b62ff4b2f0f5faab7d4899f6f957df610
5
5
  SHA512:
6
- metadata.gz: 7e5f33fe35dc796660ea45096401a2157ec32ac19ead7af5ead38d4ab96fb40e28a4c266726bf4c0d6769cd8cfa0d6064501c18e99bbcceb1bdb2b929f610eb1
7
- data.tar.gz: 8adf74dc954206d5e517cf6d0151cf50500375c9363ede9305c90a0989724f61d956b07daf6a17ebe8f1018912245474e10fa944ba4ecbbda4c927a6253eb0ff
6
+ metadata.gz: 2efacfd0945ca2070f50373c2b8cae1f4a0cba220a2cf2a815636fe76ed4d17ddd39124a40a9227e842f0215f05f764aebf49cf8d2b4ba8254412baf82789062
7
+ data.tar.gz: 7a79c8c1515ac995d4a261776d68c01a684820aa9b00b635a93929e6561f8b5c431909f4ff158451e2f0daeddbf9948e6ef178c5123fc4b5bfdcbc30d294300f
@@ -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
@@ -191,9 +191,9 @@ module Orthoses
191
191
 
192
192
  def escaped_rbs
193
193
  rbs = original_rbs
194
- rbs.gsub!(/def\s*(self\??\.)?(.+?):/) { "def #{$1}`#{$2}`:" }
195
- rbs.gsub!(/alias\s*(self\.)?(.+?)\s+(self\.)?(.+)$/) { "alias #{$1}`#{$2}` #{$3}`#{$4}`" }
196
- rbs.gsub!(/attr_(reader|writer|accessor)\s*(self\.)?(.+)\s*:\s*(.+)$/) { "attr_#{$1} #{$2}`#{$3}`: #{$4}" }
194
+ rbs.gsub!(/def\s+(self\??\.)?(.+?):/) { "def #{$1}`#{$2}`:" }
195
+ rbs.gsub!(/alias\s+(self\.)?(.+?)\s+(self\.)?(.+)$/) { "alias #{$1}`#{$2}` #{$3}`#{$4}`" }
196
+ rbs.gsub!(/attr_(reader|writer|accessor)\s+(self\.)?(.+)\s*:\s*(.+)$/) { "attr_#{$1} #{$2}`#{$3}`: #{$4}" }
197
197
  rbs
198
198
  end
199
199
 
@@ -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
@@ -31,8 +31,21 @@ module Orthoses
31
31
  attribute_filter: @attribute_filter,
32
32
  )
33
33
 
34
- patterns = @patterns || store.keys
35
- env = RBS::Environment.new
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
48
+ env = Utils.rbs_environment
36
49
  merge = false
37
50
  owners_included = []
38
51
  RBS::Prototype::Runtime.new(
@@ -8,19 +8,15 @@ module Orthoses
8
8
  NIL_TYPE = ::RBS::Types::Bases::Nil.new(location: nil)
9
9
  TRUE_TYPE = ::RBS::Types::Literal.new(literal: true, location: nil)
10
10
  FALSE_TYPE = ::RBS::Types::Literal.new(literal: false, location: nil)
11
+ BOOL_TYPE = ::RBS::Types::Bases::Bool.new(location: nil)
11
12
 
12
13
  def initialize(types)
13
- @types = types.map do |type|
14
- case type
15
- when String
16
- ::RBS::Parser.parse_type(type)
17
- else
18
- type
19
- end
20
- end
14
+ @types = types
21
15
  end
22
16
 
23
17
  def inject
18
+ normalize
19
+
24
20
  uniqed = @types.uniq
25
21
 
26
22
  return UNTYPED if uniqed.find { |t| t == UNTYPED }
@@ -28,7 +24,7 @@ module Orthoses
28
24
  has_true = uniqed.delete(TRUE_TYPE)
29
25
  has_false = uniqed.delete(FALSE_TYPE)
30
26
  if has_true || has_false
31
- uniqed << ::RBS::Types::Bases::Bool.new(location: nil)
27
+ uniqed << BOOL_TYPE
32
28
  end
33
29
 
34
30
  return UNTYPED if uniqed.empty?
@@ -68,6 +64,37 @@ module Orthoses
68
64
 
69
65
  injected
70
66
  end
67
+
68
+ private
69
+
70
+ def normalize
71
+ @types = @types.map do |type|
72
+ case type
73
+ when String
74
+ ::RBS::Parser.parse_type(type)
75
+ else
76
+ type
77
+ end
78
+ end
79
+
80
+ @types = @types.map do |rbs_type|
81
+ case rbs_type
82
+ when ::RBS::Types::ClassInstance
83
+ case rbs_type.name.to_s
84
+ when 'TrueClass', '::TrueClass', 'FalseClass', '::FalseClass'
85
+ BOOL_TYPE
86
+ when 'NilClass', '::NilClass'
87
+ NIL_TYPE
88
+ else
89
+ rbs_type
90
+ end
91
+ else
92
+ rbs_type
93
+ end
94
+ end
95
+
96
+ self
97
+ end
71
98
  end
72
99
  end
73
100
  end
@@ -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.11.0"
4
+ VERSION = "1.13.0"
5
5
  end
data/lib/orthoses.rb CHANGED
@@ -13,6 +13,7 @@ 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'
16
17
  autoload :Filter, 'orthoses/filter'
17
18
  autoload :Mixin, 'orthoses/mixin'
18
19
  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, :"..." => ::Array[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
@@ -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
@@ -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
@@ -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.11.0
4
+ version: 1.13.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-02 00:00:00.000000000 Z
11
+ date: 2023-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -48,6 +48,7 @@ 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
51
52
  - lib/orthoses/filter.rb
52
53
  - lib/orthoses/lazy_trace_point.rb
53
54
  - lib/orthoses/load_rbs.rb
@@ -79,40 +80,23 @@ files:
79
80
  - sig/orthoses/_call.rbs
80
81
  - sig/orthoses/_middle_ware.rbs
81
82
  - sig/orthoses/attribute.rbs
82
- - sig/orthoses/attribute/hook.rbs
83
83
  - sig/orthoses/autoload.rbs
84
- - sig/orthoses/autoload/hook.rbs
85
84
  - sig/orthoses/builder.rbs
86
- - sig/orthoses/builder/call_logable.rbs
87
85
  - 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
86
  - sig/orthoses/const_load_error.rbs
92
87
  - sig/orthoses/constant.rbs
93
88
  - 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
89
  - sig/orthoses/create_file_by_name.rbs
99
90
  - sig/orthoses/delegate_class.rbs
100
- - sig/orthoses/delegate_class/hook.rbs
91
+ - sig/orthoses/descendants.rbs
101
92
  - sig/orthoses/filter.rbs
102
93
  - sig/orthoses/lazy_trace_point.rbs
103
- - sig/orthoses/lazy_trace_point/method_added_hook.rbs
104
94
  - sig/orthoses/load_rbs.rbs
105
95
  - sig/orthoses/missing_name.rbs
106
- - sig/orthoses/missing_name/missing_class.rbs
107
- - sig/orthoses/missing_name/missing_module.rbs
108
96
  - sig/orthoses/mixin.rbs
109
- - sig/orthoses/mixin/hook.rbs
110
97
  - sig/orthoses/name_space_error.rbs
111
98
  - sig/orthoses/object_space_all.rbs
112
99
  - 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
100
  - sig/orthoses/path_helper.rbs
117
101
  - sig/orthoses/pp.rbs
118
102
  - sig/orthoses/rbs_prototype_rb.rbs
@@ -121,14 +105,7 @@ files:
121
105
  - sig/orthoses/store.rbs
122
106
  - sig/orthoses/tap.rbs
123
107
  - 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
108
  - sig/orthoses/utils.rbs
130
- - sig/orthoses/utils/type_list.rbs
131
- - sig/orthoses/utils/underscore.rbs
132
109
  - sig/orthoses/walk.rbs
133
110
  - sig/orthoses/writer.rbs
134
111
  homepage: https://github.com/ksss/orthoses
@@ -145,7 +122,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
145
122
  requirements:
146
123
  - - ">="
147
124
  - !ruby/object:Gem::Version
148
- version: 2.6.0
125
+ version: 3.0.0
149
126
  required_rubygems_version: !ruby/object:Gem::Requirement
150
127
  requirements:
151
128
  - - ">="
@@ -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,12 +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
- FALSE_TYPE: RBS::Types::Literal
9
- NIL_TYPE: RBS::Types::Bases::Nil
10
- TRUE_TYPE: RBS::Types::Literal
11
- UNTYPED: RBS::Types::Bases::Any
12
- end
@@ -1,4 +0,0 @@
1
- # THIS IS GENERATED CODE from `$ rake sig`
2
-
3
- module Orthoses::Utils::Underscore
4
- end