rbs 3.3.0.pre.2 → 3.3.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: 7dc5c4dc317f2e52f4626a4fec99d333422d69e6e18ec9fcad02d710bf17a212
4
- data.tar.gz: e9da32752089f0d923e82ee304e36751f28263adeb5893860d4f0f84f5b62caf
3
+ metadata.gz: 8e63ecace589850a190944136198f3d66e4265d7a2d49909e705043687492698
4
+ data.tar.gz: a6795431478b3d5300a8df0bd4168250c4b7124807a790e99788e05d280e7bdc
5
5
  SHA512:
6
- metadata.gz: eb722e98a22685907310de9465590da330bf86f4387fc40e65ce692a9fbbd6839d850a706ca7f489954048d40555d3040e83ffddb452494529febfcd98dbeff5
7
- data.tar.gz: 2ed8a1e9a4bbb28341f5c578903a94a23ea3b6bcc95721308dcfddce514f269755f0f7baaaf2cb0a4511c7895fc39992fe2cdfe95ad33e66f045971cb137587e
6
+ metadata.gz: 8ed98b066766f8350bdcd71878120a054a53e9246cf4c7766b4f3b4121a554af6bd94e881e59f0ffc03155e55abcaa6f864a8c763fde1dfa2b9d1930b49d9075
7
+ data.tar.gz: cc8391b0262bf39937f39f53e9e09e8acf860e32a4d1009e46870c9b9e674910aaf96fff2d9814e176f677fce7675a0d55c063969c8bd8c188512c1b6ef07735
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 3.3.0 (2023-11-09)
6
+
7
+ ### Library changes
8
+
9
+ * Stop exiting with error when syntax error detected during validation ([#1603](https://github.com/ruby/rbs/pull/1603))
10
+ * [rbs diff] Load dependencies from manifest.yaml ([#1602](https://github.com/ruby/rbs/pull/1602))
11
+ * [rbs diff] Resolve constants name ([#1601](https://github.com/ruby/rbs/pull/1601))
12
+
5
13
  ## 3.3.0.pre.2 (2023-11-02)
6
14
 
7
15
  ### Signature updates
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rbs (3.3.0.pre.2)
4
+ rbs (3.3.0)
5
5
  abbrev
6
6
 
7
7
  PATH
@@ -83,7 +83,7 @@ GEM
83
83
  stackprof (0.2.25)
84
84
  stringio (3.0.7)
85
85
  strong_json (2.1.2)
86
- tempfile (0.1.3)
86
+ tempfile (0.2.0)
87
87
  test-unit (3.6.1)
88
88
  power_assert
89
89
  timeout (0.4.0)
data/lib/rbs/cli.rb CHANGED
@@ -445,6 +445,7 @@ EOU
445
445
 
446
446
  def run_validate(args, options)
447
447
  stdout = stdout()
448
+ exit_error = false
448
449
 
449
450
  OptionParser.new do |opts|
450
451
  opts.banner = <<EOU
@@ -460,6 +461,9 @@ EOU
460
461
  opts.on("--silent") do
461
462
  stdout = StringIO.new
462
463
  end
464
+ opts.on("--[no-]exit-error-on-syntax-error", "exit(1) if syntax error is detected") {|bool|
465
+ exit_error = bool
466
+ }
463
467
  end.parse!(args)
464
468
 
465
469
  loader = options.loader()
@@ -632,7 +636,7 @@ EOU
632
636
  syntax_errors.each do |message|
633
637
  self.stdout.puts message
634
638
  end
635
- exit(1)
639
+ exit 1 if exit_error
636
640
  end
637
641
  end
638
642
 
data/lib/rbs/diff.rb CHANGED
@@ -12,13 +12,13 @@ module RBS
12
12
  def each_diff(&block)
13
13
  return to_enum(:each_diff) unless block
14
14
 
15
- before_instance_methods, before_singleton_methods, before_constant_decls = build_methods(@before_path)
16
- after_instance_methods, after_singleton_methods, after_constant_decls = build_methods(@after_path)
15
+ before_instance_methods, before_singleton_methods, before_constant_children = build_methods(@before_path)
16
+ after_instance_methods, after_singleton_methods, after_constant_children = build_methods(@after_path)
17
17
 
18
18
  each_diff_methods(:instance, before_instance_methods, after_instance_methods, &block)
19
19
  each_diff_methods(:singleton, before_singleton_methods, after_singleton_methods, &block)
20
20
 
21
- each_diff_constants(before_constant_decls, after_constant_decls, &block)
21
+ each_diff_constants(before_constant_children, after_constant_children, &block)
22
22
  end
23
23
 
24
24
  private
@@ -34,11 +34,11 @@ module RBS
34
34
  end
35
35
  end
36
36
 
37
- def each_diff_constants(before_constant_decls, after_constant_decls)
38
- all_keys = before_constant_decls.keys.to_set + after_constant_decls.keys.to_set
37
+ def each_diff_constants(before_constant_children, after_constant_children)
38
+ all_keys = before_constant_children.keys.to_set + after_constant_children.keys.to_set
39
39
  all_keys.each do |key|
40
- before = constant_to_s(key, before_constant_decls[key]) or next
41
- after = constant_to_s(key, after_constant_decls[key]) or next
40
+ before = constant_to_s(before_constant_children[key]) or next
41
+ after = constant_to_s(after_constant_children[key]) or next
42
42
  next if before == after
43
43
 
44
44
  yield before, after
@@ -52,25 +52,42 @@ module RBS
52
52
  instance_methods = begin
53
53
  builder.build_instance(@type_name).methods
54
54
  rescue => e
55
- RBS.logger.warn("#{path}: #{e.message}")
55
+ RBS.logger.warn("#{path}: (#{e.class}) #{e.message}")
56
56
  {}
57
57
  end
58
58
  singleton_methods = begin
59
59
  builder.build_singleton(@type_name).methods
60
60
  rescue => e
61
- RBS.logger.warn("#{path}: #{e.message}")
61
+ RBS.logger.warn("#{path}: (#{e.class}) #{e.message}")
62
62
  {}
63
63
  end
64
- type_name_to_s = @type_name.to_s
65
- constant_decls = env.constant_decls.select { |key| key.to_s.start_with?(type_name_to_s) }
66
64
 
67
- [ instance_methods, singleton_methods, constant_decls ]
65
+ constant_children = begin
66
+ constant_resolver = RBS::Resolver::ConstantResolver.new(builder: builder)
67
+ constant_resolver.children(@type_name)
68
+ rescue => e
69
+ RBS.logger.warn("#{path}: (#{e.class}) #{e.message}")
70
+ {}
71
+ end
72
+
73
+ [ instance_methods, singleton_methods, constant_children ]
68
74
  end
69
75
 
70
76
  def build_env(path)
71
77
  loader = @library_options.loader()
72
78
  path&.each do |dir|
73
- loader.add(path: Pathname(dir))
79
+ dir_pathname = Pathname(dir)
80
+ loader.add(path: dir_pathname)
81
+
82
+ manifest_pathname = dir_pathname / 'manifest.yaml'
83
+ if manifest_pathname.exist?
84
+ manifest = YAML.safe_load(manifest_pathname.read)
85
+ if manifest['dependencies']
86
+ manifest['dependencies'].each do |dependency|
87
+ loader.add(library: dependency['name'], version: nil)
88
+ end
89
+ end
90
+ end
74
91
  end
75
92
  Environment.from_loader(loader)
76
93
  end
@@ -93,9 +110,9 @@ module RBS
93
110
  end
94
111
  end
95
112
 
96
- def constant_to_s(key, constant)
113
+ def constant_to_s(constant)
97
114
  if constant
98
- "#{key}: #{constant.decl.type}"
115
+ "#{constant.name.name}: #{constant.type}"
99
116
  else
100
117
  +"-"
101
118
  end
@@ -22,7 +22,7 @@ module RBS
22
22
 
23
23
  unless name.namespace.empty?
24
24
  parent = name.namespace.to_type_name
25
- table = children_table[parent] or raise
25
+ table = children_table[parent] or raise "#{parent} not found by #{name}"
26
26
  else
27
27
  table = toplevel
28
28
  end
data/lib/rbs/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RBS
4
- VERSION = "3.3.0.pre.2"
4
+ VERSION = "3.3.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.3.0.pre.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-11-02 00:00:00.000000000 Z
11
+ date: 2023-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: abbrev
@@ -505,9 +505,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
505
505
  version: '3.0'
506
506
  required_rubygems_version: !ruby/object:Gem::Requirement
507
507
  requirements:
508
- - - ">"
508
+ - - ">="
509
509
  - !ruby/object:Gem::Version
510
- version: 1.3.1
510
+ version: '0'
511
511
  requirements: []
512
512
  rubygems_version: 3.4.10
513
513
  signing_key: