orthoses 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 843da9ba9bba3cf5c84ec56041836cb9469ad5faffd188f8edc13a3920ca499e
4
- data.tar.gz: 791b0d87a885b327a41fff090f9dadce9b377712e9d7d51bd52fbaa997c98242
3
+ metadata.gz: 0bde1745c71d6d30b7b45ce7f956a1c02f0d44353932c3743211aa1c05f58d39
4
+ data.tar.gz: bbe5b95a7665d39faab82b5f53e18cffd22962df1913f1c52698ea51c6045e2c
5
5
  SHA512:
6
- metadata.gz: 81438b5d94ce56d7164cdc781eaaa2c526cbba21cab147fc91d4e1b0c9b7992e31259d9bda2f5e2441a3dc59e3f7ec940c910e1cf63bbec6ef84ca4b046af0ee
7
- data.tar.gz: ec0049000f94a194747974233adaa1c51a7759c0d78fb84a11e543877ee15d01f212b59ed63c5cadbd221701de4bfa9c84c0f6fcc5feffdab0f954b1fd63e2d0
6
+ metadata.gz: 496d255f99751ac854e5b05ecac69b1e0dc7dbb5fca53bf99d6d622e2dbb154af643de7bf8de8190dca15ff1933fac35c17735da9285532a8a3246d7002836cd
7
+ data.tar.gz: 56c77cf9074eeb75547c1be3868e9843b0d5337400d2248592879f76fd6cc14f99660d8dbbf593c1d66bac1152e1dafbaa4820ea45a49f5f47945027ce45d53a
data/Gemfile CHANGED
@@ -8,4 +8,8 @@ gemspec
8
8
  gem "rbs"
9
9
  gem "rake", "~> 13.0"
10
10
  gem "rgot", "~> 1.1"
11
- gem "steep"
11
+ gem "activesupport"
12
+
13
+ group :steep do
14
+ gem "steep", "1.4.0.dev.2"
15
+ end
data/Gemfile.lock CHANGED
@@ -1,43 +1,44 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- orthoses (1.5.0)
5
- rbs (~> 2.0)
4
+ orthoses (1.6.0)
5
+ rbs (~> 3.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4)
10
+ activesupport (7.0.4.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  ast (2.4.2)
16
- concurrent-ruby (1.1.10)
16
+ concurrent-ruby (1.2.2)
17
17
  csv (3.2.6)
18
18
  ffi (1.15.5)
19
19
  fileutils (1.7.0)
20
20
  i18n (1.12.0)
21
21
  concurrent-ruby (~> 1.0)
22
22
  json (2.6.3)
23
- language_server-protocol (3.17.0.2)
24
- listen (3.7.1)
23
+ language_server-protocol (3.17.0.3)
24
+ listen (3.8.0)
25
25
  rb-fsevent (~> 0.10, >= 0.10.3)
26
26
  rb-inotify (~> 0.9, >= 0.9.10)
27
- logger (1.5.2)
28
- minitest (5.16.3)
27
+ logger (1.5.3)
28
+ minitest (5.18.0)
29
29
  parallel (1.22.1)
30
- parser (3.1.3.0)
30
+ parser (3.2.1.1)
31
31
  ast (~> 2.4.1)
32
+ pathname (0.2.1)
32
33
  rainbow (3.1.1)
33
34
  rake (13.0.6)
34
35
  rb-fsevent (0.11.2)
35
36
  rb-inotify (0.10.1)
36
37
  ffi (~> 1.0)
37
- rbs (2.8.1)
38
- rgot (1.1.0)
39
- securerandom (0.2.1)
40
- steep (1.3.0)
38
+ rbs (3.0.4)
39
+ rgot (1.3.0)
40
+ securerandom (0.2.2)
41
+ steep (1.4.0.dev.2)
41
42
  activesupport (>= 5.1)
42
43
  csv (>= 3.0.9)
43
44
  fileutils (>= 1.1.0)
@@ -47,27 +48,29 @@ GEM
47
48
  logger (>= 1.3.0)
48
49
  parallel (>= 1.0.0)
49
50
  parser (>= 3.1)
51
+ pathname (>= 0.2.1)
50
52
  rainbow (>= 2.2.2, < 4.0)
51
53
  rbs (>= 2.8.0)
52
54
  securerandom (>= 0.1)
53
55
  strscan (>= 1.0.0)
54
56
  terminal-table (>= 2, < 4)
55
- strscan (3.0.5)
57
+ strscan (3.0.6)
56
58
  terminal-table (3.0.2)
57
59
  unicode-display_width (>= 1.1.1, < 3)
58
- tzinfo (2.0.5)
60
+ tzinfo (2.0.6)
59
61
  concurrent-ruby (~> 1.0)
60
- unicode-display_width (2.3.0)
62
+ unicode-display_width (2.4.2)
61
63
 
62
64
  PLATFORMS
63
65
  ruby
64
66
 
65
67
  DEPENDENCIES
68
+ activesupport
66
69
  orthoses!
67
70
  rake (~> 13.0)
68
71
  rbs
69
72
  rgot (~> 1.1)
70
- steep
73
+ steep (= 1.4.0.dev.2)
71
74
 
72
75
  BUNDLED WITH
73
- 2.3.9
76
+ 2.4.8
@@ -2,6 +2,18 @@
2
2
 
3
3
  module Orthoses
4
4
  class CallTracer
5
+ # CallTracer::Lazy is possible to perform a trace
6
+ # equivalent to CallTracer before method is defined.
7
+ # scope = CallTracerLazy.new
8
+ # scope.trace("ActiveRecord::Base#scope") do
9
+ # require 'active_record/all'
10
+ # @loader.call
11
+ # end
12
+ # scope.captures.each do |capture|
13
+ # capture.argument[:name]
14
+ # capture.argument[:body]
15
+ # capture.argument[:block]
16
+ # end
5
17
  class Lazy
6
18
  include Capturable
7
19
 
@@ -11,7 +11,7 @@ module Orthoses
11
11
  return unless @decl.respond_to?(:members)
12
12
  uniq_map = {}
13
13
  @decl.members.each do |member|
14
- if member.instance_of?(RBS::AST::Members::MethodDefinition) && member.overload
14
+ if member.instance_of?(RBS::AST::Members::MethodDefinition) && member.overloading?
15
15
  # avoid to duplicate and keep order
16
16
  uniq_map[Object.new] = member
17
17
  else
@@ -7,7 +7,8 @@ module Orthoses
7
7
  paths.each do |path|
8
8
  Orthoses.logger.debug("Load #{path}")
9
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|
10
+ _, _, decls = RBS::Parser.parse_signature(buffer)
11
+ decls.each do |decl|
11
12
  env << decl
12
13
  end
13
14
  end
@@ -3,7 +3,7 @@ module Orthoses
3
3
  class HeaderBuilder
4
4
  def initialize(env:)
5
5
  @env = env
6
- @resolver = RBS::TypeNameResolver.from_env(env)
6
+ @resolver = RBS::Resolver::TypeNameResolver.new(env)
7
7
  end
8
8
 
9
9
  def build(entry:, name_hint: nil)
@@ -66,11 +66,10 @@ module Orthoses
66
66
  "interface #{name_and_params(resolved_name.relative!, entry.decl.type_params)}"
67
67
  end
68
68
 
69
+ include RBS::Environment::ContextUtil
70
+
69
71
  def build_context(entry:)
70
- context = entry.outer.length.times.map do |i|
71
- entry.outer[0, i + 1].map(&:name).inject(:+).to_namespace.absolute!
72
- end
73
- context.push(RBS::Namespace.root)
72
+ calculate_context(entry.outer + [entry.decl])
74
73
  end
75
74
 
76
75
  def name_and_params(name, params)
@@ -119,7 +119,7 @@ module Orthoses
119
119
  name: "orthoses/content.rb",
120
120
  content: original_rbs
121
121
  )
122
- parsed_decls = RBS::Parser.parse_signature(buffer)
122
+ _, _, parsed_decls = RBS::Parser.parse_signature(buffer)
123
123
  unless parsed_decls.length == 1
124
124
  raise "expect decls.length == 1, but got #{parsed_decls.length}"
125
125
  end
@@ -169,8 +169,13 @@ module Orthoses
169
169
  kind: kind,
170
170
  location: nil,
171
171
  name: method_id,
172
- overload: false,
173
- types: types,
172
+ overloading: false,
173
+ overloads: types.map { |type|
174
+ RBS::AST::Members::MethodDefinition::Overload.new(
175
+ annotations: [],
176
+ method_type: type
177
+ )
178
+ },
174
179
  visibility: visibility
175
180
  )
176
181
  ]
@@ -50,28 +50,6 @@ module Orthoses
50
50
  RBS::Namespace.parse(name).to_type_name
51
51
  end
52
52
 
53
- class << self
54
- # Generated scripts are not always located in the root.
55
- # By default, it follows the upper level directory from the current directory
56
- # to find the rbs_collection.yaml file and set it to `rbs_collection_pathname`.
57
- # It can be reconfigured if necessary.
58
- attr_accessor :rbs_collection_pathname
59
- end
60
- # set default
61
- self.rbs_collection_pathname = ->() {
62
- begin
63
- start = here = Dir.pwd
64
- until ok = RBS::Collection::Config::PATH.exist?
65
- Dir.chdir("..")
66
- return nil if Dir.pwd == here
67
- here = Dir.pwd
68
- end
69
- Pathname(here) + RBS::Collection::Config::PATH
70
- ensure
71
- Dir.chdir(start)
72
- end
73
- }.call
74
-
75
53
  def self.rbs_environment(library: nil, collection: true, cache: true)
76
54
  @env_cache ||= {}
77
55
  if cache && hit = @env_cache[[library, collection]]
@@ -80,9 +58,15 @@ module Orthoses
80
58
 
81
59
  loader = RBS::EnvironmentLoader.new
82
60
 
83
- if collection && rbs_collection_pathname
84
- config = RBS::Collection::Config.lockfile_of(rbs_collection_pathname) or raise
85
- loader.add_collection(config)
61
+ if collection
62
+ config_path = RBS::Collection::Config.find_config_path || RBS::Collection::Config::PATH || raise("needs rbs_collection.yaml")
63
+ lock_path = RBS::Collection::Config.to_lockfile_path(config_path)
64
+ raise "needs rbs_collection.yaml file" unless lock_path.file?
65
+ lock = RBS::Collection::Config::Lockfile.from_lockfile(
66
+ lockfile_path: lock_path,
67
+ data: YAML.load_file(lock_path.to_s)
68
+ )
69
+ loader.add_collection(lock)
86
70
  end
87
71
 
88
72
  case library
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orthoses
4
- VERSION = "1.5.0"
4
+ VERSION = "1.6.0"
5
5
  end
data/orthoses.gemspec CHANGED
@@ -32,5 +32,5 @@ Gem::Specification.new do |spec|
32
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
33
  spec.require_paths = ["lib"]
34
34
 
35
- spec.add_dependency "rbs", "~> 2.0"
35
+ spec.add_dependency "rbs", "~> 3.0"
36
36
  end
@@ -2,5 +2,6 @@
2
2
 
3
3
  class Orthoses::CallTracer::Lazy
4
4
  def initialize: () -> void
5
- def trace: (untyped name) ?{ () -> untyped } -> untyped
5
+ def trace: (String name) ?{ () -> untyped } -> untyped
6
+ attr_reader captures: Array[untyped]
6
7
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Orthoses::CallTracer
4
4
  def initialize: () -> void
5
- def trace: [T] (Method | UnboundMethod) ?{ () -> T } -> T
5
+ def trace: (Method | UnboundMethod) ?{ () -> untyped } -> untyped
6
6
  attr_accessor captures: Array[Capture]
7
7
  end
@@ -10,4 +10,5 @@ class Orthoses::Content::HeaderBuilder
10
10
  private def build_context: (entry: untyped) -> untyped
11
11
  private def name_and_params: (untyped name, untyped params) -> ::String
12
12
  private def name_and_args: (untyped name, untyped args) -> (::String | nil)
13
+ include RBS::Environment::ContextUtil
13
14
  end
@@ -3,7 +3,7 @@
3
3
  class Orthoses::LazyTracePoint < ::TracePoint
4
4
  def method_added: (untyped id) -> untyped
5
5
  def singleton_method_added: (untyped id) -> untyped
6
- def initialize: (*untyped events) ?{ () -> untyped } -> void
6
+ def initialize: (*untyped events) { () -> untyped } -> void
7
7
  def enable: (?target: untyped?, ?target_line: untyped?, ?target_thread: untyped?) ?{ () -> untyped } -> untyped
8
8
  private def trace_instance_method: () ?{ () -> untyped } -> untyped
9
9
  private def trace_singleton_method: () ?{ () -> untyped } -> untyped
@@ -24,6 +24,4 @@ module Orthoses::Utils
24
24
  def self.new_store: () -> Orthoses::store
25
25
 
26
26
  UNBOUND_NAME_METHOD: UnboundMethod
27
-
28
- attr_accessor self.rbs_collection_pathname: Pathname
29
27
  end
data/sig/orthoses.rbs CHANGED
@@ -1,7 +1,7 @@
1
1
  # THIS IS GENERATED CODE from `$ rake generate_self_sig`
2
2
 
3
3
  module Orthoses
4
- VERSION: "1.5.0"
4
+ VERSION: "1.6.0"
5
5
 
6
6
  attr_accessor self.logger: ::Logger
7
7
 
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.5.0
4
+ version: 1.6.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-03-13 00:00:00.000000000 Z
11
+ date: 2023-03-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbs
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '3.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '3.0'
27
27
  description: Build RBS by Rack base architecture
28
28
  email:
29
29
  - co000ri@gmail.com
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  - !ruby/object:Gem::Version
157
157
  version: '0'
158
158
  requirements: []
159
- rubygems_version: 3.4.3
159
+ rubygems_version: 3.4.8
160
160
  signing_key:
161
161
  specification_version: 4
162
162
  summary: Framework for Generate RBS