rbs 2.1.0 → 2.2.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: 755ad70b4862c5ca3098711a5d7fb1a4ea4adf36fc9693b2eb458f2547106b32
4
- data.tar.gz: 763747b678f1fee16a4dda6f93dfb35ec6bc5621c14dd284e6e386bb8f31cffc
3
+ metadata.gz: f4afaa0d6ac4b7b74aae38aa7cd04679dad881ad073ca496aa06f272a7261cfe
4
+ data.tar.gz: 041f1bf758d156f9a968ae3cb460da45a99f80aacb2868513549687ee4e4ad76
5
5
  SHA512:
6
- metadata.gz: 18e5efe238216695ba6ee14f193faea51083aa36d70e73eb8503d38550c8b7bf071dd0fd26fc6aa8597326a7ae2bef8d4b22cfa13c5f05d9174af753f24db331
7
- data.tar.gz: 91b01eaed6476e11b2f51a9f10307c70099c69bf231191b00ab78cdbf0ec8a033b79c964752a03eee4fb1394ab13fc0c28f4f660843549a9ac99b4d999b3bcd3
6
+ metadata.gz: 8891199897e1ef1574b8009bc810c0d60a1a8fbe4a9f2d5d6658b703c75d515d6e89022e5246a6196657775d8f0ea2bd44db13718a425face5d16d3e5cff38dd
7
+ data.tar.gz: faa9199018c944a87de33fc99a4bf203e73f2f24d27960d79cd92fb82aaa6be2218cae07a2bb6887ad1dee2df96e8abc7b43ec818bf11d5a40dfabf3e782f1c2
@@ -0,0 +1,34 @@
1
+ name: RBS Comments
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request: {}
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: "ubuntu-latest"
12
+ container:
13
+ image: rubylang/ruby:3.1-focal
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: Install dependencies
17
+ run: |
18
+ apt-get update
19
+ apt-get install -y libdb-dev
20
+ - name: Update rubygems & bundler
21
+ run: |
22
+ ruby -v
23
+ gem update --system
24
+ - name: bundle config set with
25
+ run: |
26
+ echo "NO_MINITEST=true" >> $GITHUB_ENV
27
+ bundle config set --local without 'minitest'
28
+ if: "contains(matrix.container_tag, 'master-nightly')"
29
+ - name: bin/setup
30
+ run: |
31
+ bin/setup
32
+ - name: Run test
33
+ run: |
34
+ bundle exec rake annotate confirm_annotation
data/CHANGELOG.md CHANGED
@@ -2,6 +2,51 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 2.2.0 (2022-02-22)
6
+
7
+ RBS 2.2 ships with a new syntax to specify the visibility of a method per definition bases.
8
+
9
+ ```rbs
10
+ class Foo
11
+ private def hello: () -> void
12
+
13
+ private attr_accessor world: String
14
+ end
15
+ ```
16
+
17
+ It also changes the semantics of `self?` method.
18
+ It defines both _public_ singleton method and _private_ instance method, which is equivalent to `module_function`.
19
+
20
+ ## Signature updates
21
+
22
+ * `net-http` ([\#892](https://github.com/ruby/rbs/pull/892))
23
+ * `uri` ([\#864](https://github.com/ruby/rbs/pull/864))
24
+ * `Encoding` ([\#897](https://github.com/ruby/rbs/pull/897), [\#898](https://github.com/ruby/rbs/pull/898))
25
+ * `File::Stat` ([\#879](https://github.com/ruby/rbs/pull/879))
26
+ * `Kernel#sleep` ([\#893](https://github.com/ruby/rbs/pull/893))
27
+
28
+ ### Language updates
29
+
30
+ * Add public/private per member modifier ([\#911](https://github.com/ruby/rbs/pull/911))
31
+ * Let `self?.` be equivalent to `module_function` ([\#910](https://github.com/ruby/rbs/pull/910))
32
+
33
+ ### Library changes
34
+
35
+ * Add c99 flag for compiling on Ruby 2 ([\#895](https://github.com/ruby/rbs/pull/895))
36
+ * Fix incorrect URI reference in `schema/typeParam.json` ([\#891](https://github.com/ruby/rbs/pull/891))
37
+ * Allow scaffolding below namespace ([\#894](https://github.com/ruby/rbs/pull/894))
38
+ * Let `Writer` preserve format ([\#900](https://github.com/ruby/rbs/pull/900))
39
+ * Reduce memory usage of `RBS::Buffer` ([\#907](https://github.com/ruby/rbs/pull/907))
40
+ * Do not call `#class` from `#hash` to improve performance ([\#906](https://github.com/ruby/rbs/pull/906))
41
+ * Skip type variable validation if `unchcked` ([\#909](https://github.com/ruby/rbs/pull/909))
42
+
43
+ ### Miscellaneous
44
+
45
+ * Add `Thread::Backtrace` and `Thread::Backtrace::Location` test ([\#896](https://github.com/ruby/rbs/pull/896))
46
+ * Test annotations ([\#902](https://github.com/ruby/rbs/pull/902))
47
+ * Remove goodcheck rule for arglists section ([\#901](https://github.com/ruby/rbs/pull/901))
48
+ * Remove `CharScanner` due to no longer used ([\#905](https://github.com/ruby/rbs/pull/905))
49
+
5
50
  ## 2.1.0 (2022-02-02)
6
51
 
7
52
  RBS 2.1 is a release to deliver the types and documents of the new and updated methods of Ruby 3.1.
data/Rakefile CHANGED
@@ -34,6 +34,15 @@ rule ".c" => ".re" do |t|
34
34
  puts "⚠️⚠️⚠️ #{t.name} is older than #{t.source}. You may need to run `rake lexer` ⚠️⚠️⚠️"
35
35
  end
36
36
 
37
+ task :annotate do
38
+ sh "rbs annotate core stdlib"
39
+ end
40
+
41
+ task :confirm_annotation do
42
+ puts "Testing if RBS docs are updated with respect to RDoc"
43
+ sh "git diff --exit-code core stdlib"
44
+ end
45
+
37
46
  task :compile => "ext/rbs_extension/lexer.c"
38
47
 
39
48
  task :test_doc do
@@ -73,6 +82,7 @@ task :validate => :compile do
73
82
 
74
83
  if lib == ["net-http"]
75
84
  lib << "uri"
85
+ lib << "timeout"
76
86
  end
77
87
 
78
88
  if lib == ["resolv"]
@@ -106,17 +116,40 @@ namespace :generate do
106
116
  raise "Class name is necessary. e.g. rake 'generate:stdlib_test[String]'"
107
117
  end
108
118
 
109
- path = Pathname(ENV["RBS_GENERATE_TEST_PATH"] || "test/stdlib/#{klass}_test.rb")
110
- raise "#{path} already exists!" if path.exist?
111
-
112
119
  require "erb"
113
120
  require "rbs"
114
121
 
122
+ class TestTarget
123
+ def initialize(klass)
124
+ @type_name = RBS::Namespace.parse(klass).to_type_name
125
+ end
126
+
127
+ def path
128
+ Pathname(ENV['RBS_GENERATE_TEST_PATH'] || "test/stdlib/#{file_name}_test.rb")
129
+ end
130
+
131
+ def file_name
132
+ @type_name.to_s.gsub(/\A::/, '').gsub(/::/, '_')
133
+ end
134
+
135
+ def to_s
136
+ @type_name.to_s
137
+ end
138
+
139
+ def absolute_type_name
140
+ @absolute_type_name ||= @type_name.absolute!
141
+ end
142
+ end
143
+
144
+ target = TestTarget.new(klass)
145
+ path = target.path
146
+ raise "#{path} already exists!" if path.exist?
147
+
115
148
  class TestTemplateBuilder
116
- attr_reader :klass, :env
149
+ attr_reader :target, :env
117
150
 
118
- def initialize(klass)
119
- @klass = klass
151
+ def initialize(target)
152
+ @target = target
120
153
 
121
154
  loader = RBS::EnvironmentLoader.new
122
155
  Dir['stdlib/*'].each do |lib|
@@ -132,17 +165,17 @@ namespace :generate do
132
165
  require_relative "test_helper"
133
166
 
134
167
  <%- unless class_methods.empty? -%>
135
- class <%= klass %>SingletonTest < Test::Unit::TestCase
168
+ class <%= target %>SingletonTest < Test::Unit::TestCase
136
169
  include TypeAssertions
137
170
 
138
171
  # library "pathname", "set", "securerandom" # Declare library signatures to load
139
- testing "singleton(::<%= klass %>)"
172
+ testing "singleton(::<%= target %>)"
140
173
 
141
174
  <%- class_methods.each do |method_name, definition| %>
142
175
  def test_<%= test_name_for(method_name) %>
143
176
  <%- definition.method_types.each do |method_type| -%>
144
177
  assert_send_type "<%= method_type %>",
145
- <%= klass %>, :<%= method_name %>
178
+ <%= target %>, :<%= method_name %>
146
179
  <%- end -%>
147
180
  end
148
181
  <%- end -%>
@@ -150,17 +183,17 @@ namespace :generate do
150
183
  <%- end -%>
151
184
 
152
185
  <%- unless instance_methods.empty? -%>
153
- class <%= klass %>Test < Test::Unit::TestCase
186
+ class <%= target %>Test < Test::Unit::TestCase
154
187
  include TypeAssertions
155
188
 
156
189
  # library "pathname", "set", "securerandom" # Declare library signatures to load
157
- testing "::<%= klass %>"
190
+ testing "::<%= target %>"
158
191
 
159
192
  <%- instance_methods.each do |method_name, definition| %>
160
193
  def test_<%= test_name_for(method_name) %>
161
194
  <%- definition.method_types.each do |method_type| -%>
162
195
  assert_send_type "<%= method_type %>",
163
- <%= klass %>.new, :<%= method_name %>
196
+ <%= target %>.new, :<%= method_name %>
164
197
  <%- end -%>
165
198
  end
166
199
  <%- end -%>
@@ -200,24 +233,20 @@ namespace :generate do
200
233
  }.fetch(method_name, method_name)
201
234
  end
202
235
 
203
- def type_name
204
- @type_name ||= RBS::TypeName.new(name: klass.to_sym, namespace: RBS::Namespace.new(path: [], absolute: true))
205
- end
206
-
207
236
  def class_methods
208
- @class_methods ||= RBS::DefinitionBuilder.new(env: env).build_singleton(type_name).methods.select {|_, definition|
209
- definition.implemented_in == type_name
237
+ @class_methods ||= RBS::DefinitionBuilder.new(env: env).build_singleton(target.absolute_type_name).methods.select {|_, definition|
238
+ definition.implemented_in == target.absolute_type_name
210
239
  }
211
240
  end
212
241
 
213
242
  def instance_methods
214
- @instance_methods ||= RBS::DefinitionBuilder.new(env: env).build_instance(type_name).methods.select {|_, definition|
215
- definition.implemented_in == type_name
243
+ @instance_methods ||= RBS::DefinitionBuilder.new(env: env).build_instance(target.absolute_type_name).methods.select {|_, definition|
244
+ definition.implemented_in == target.absolute_type_name
216
245
  }
217
246
  end
218
247
  end
219
248
 
220
- path.write TestTemplateBuilder.new(klass).call
249
+ path.write TestTemplateBuilder.new(target).call
221
250
 
222
251
  puts "Created: #{path}"
223
252
  end
@@ -226,4 +255,6 @@ end
226
255
  task :test_generate_stdlib do
227
256
  sh "RBS_GENERATE_TEST_PATH=/tmp/Array_test.rb rake 'generate:stdlib_test[Array]'"
228
257
  sh "ruby -c /tmp/Array_test.rb"
258
+ sh "RBS_GENERATE_TEST_PATH=/tmp/Thread_Mutex_test.rb rake 'generate:stdlib_test[Thread::Mutex]'"
259
+ sh "ruby -c /tmp/Thread_Mutex_test.rb"
229
260
  end