rbs 2.5.1 → 2.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +1 -1
- data/.github/workflows/ruby.yml +3 -3
- data/CHANGELOG.md +44 -0
- data/Gemfile.lock +5 -5
- data/Rakefile +6 -38
- data/Steepfile +6 -2
- data/core/constants.rbs +1 -1
- data/core/env.rbs +1 -1323
- data/core/global_variables.rbs +1 -1
- data/core/hash.rbs +3 -3
- data/core/kernel.rbs +2 -2
- data/core/random.rbs +5 -220
- data/core/rational.rbs +3 -3
- data/core/rbs/unnamed/argf.rbs +965 -0
- data/core/rbs/unnamed/env_class.rbs +1325 -0
- data/core/rbs/unnamed/random.rbs +270 -0
- data/core/regexp.rbs +2 -3
- data/docs/CONTRIBUTING.md +2 -2
- data/ext/rbs_extension/lexer.c +1343 -1353
- data/ext/rbs_extension/lexer.re +2 -2
- data/ext/rbs_extension/rbs_extension.h +1 -1
- data/ext/rbs_extension/unescape.c +17 -10
- data/lib/rbs/ast/members.rb +6 -3
- data/lib/rbs/cli.rb +2 -0
- data/lib/rbs/factory.rb +2 -0
- data/lib/rbs/prototype/helpers.rb +1 -5
- data/lib/rbs/prototype/rb.rb +105 -56
- data/lib/rbs/prototype/rbi.rb +65 -30
- data/lib/rbs/prototype/runtime.rb +4 -3
- data/lib/rbs/test/setup_helper.rb +6 -1
- data/lib/rbs/version.rb +1 -1
- data/schema/members.json +4 -1
- data/sig/collection/config.rbs +3 -0
- data/sig/factory.rbs +5 -0
- data/sig/prototype/helpers.rbs +23 -0
- data/sig/prototype/rb.rbs +84 -0
- data/sig/prototype/rbi.rbs +73 -0
- data/sig/shims/abstract_syntax_tree.rbs +25 -0
- data/sig/shims/enumerable.rbs +5 -0
- data/sig/shims/pp.rbs +3 -0
- data/sig/shims/ripper.rbs +8 -0
- data/stdlib/cgi/0/manifest.yaml +2 -0
- data/stdlib/date/0/time.rbs +26 -0
- data/stdlib/etc/0/etc.rbs +745 -0
- data/stdlib/minitest/0/kernel.rbs +42 -0
- data/stdlib/minitest/0/manifest.yaml +2 -0
- data/stdlib/minitest/0/minitest/abstract_reporter.rbs +49 -0
- data/stdlib/minitest/0/minitest/assertion.rbs +16 -0
- data/stdlib/minitest/0/minitest/assertions.rbs +545 -0
- data/stdlib/minitest/0/minitest/backtrace_filter.rbs +16 -0
- data/stdlib/minitest/0/minitest/bench_spec.rbs +102 -0
- data/stdlib/minitest/0/minitest/benchmark.rbs +258 -0
- data/stdlib/minitest/0/minitest/composite_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/expectation.rbs +2 -0
- data/stdlib/minitest/0/minitest/expectations.rbs +21 -0
- data/stdlib/minitest/0/minitest/guard.rbs +64 -0
- data/stdlib/minitest/0/minitest/mock.rbs +60 -0
- data/stdlib/minitest/0/minitest/parallel/executor.rbs +42 -0
- data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +6 -0
- data/stdlib/minitest/0/minitest/parallel/test.rbs +3 -0
- data/stdlib/minitest/0/minitest/parallel.rbs +2 -0
- data/stdlib/minitest/0/minitest/pride_io.rbs +54 -0
- data/stdlib/minitest/0/minitest/pride_lol.rbs +17 -0
- data/stdlib/minitest/0/minitest/progress_reporter.rbs +11 -0
- data/stdlib/minitest/0/minitest/reportable.rbs +51 -0
- data/stdlib/minitest/0/minitest/reporter.rbs +5 -0
- data/stdlib/minitest/0/minitest/result.rbs +28 -0
- data/stdlib/minitest/0/minitest/runnable.rbs +131 -0
- data/stdlib/minitest/0/minitest/skip.rbs +6 -0
- data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +48 -0
- data/stdlib/minitest/0/minitest/spec/dsl.rbs +125 -0
- data/stdlib/minitest/0/minitest/spec.rbs +11 -0
- data/stdlib/minitest/0/minitest/statistics_reporter.rbs +76 -0
- data/stdlib/minitest/0/minitest/summary_reporter.rbs +25 -0
- data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +92 -0
- data/stdlib/minitest/0/minitest/test.rbs +76 -0
- data/stdlib/minitest/0/minitest/unexpected_error.rbs +10 -0
- data/stdlib/minitest/0/minitest/unit/test_case.rbs +3 -0
- data/stdlib/minitest/0/minitest/unit.rbs +5 -0
- data/stdlib/minitest/0/minitest.rbs +966 -0
- data/stdlib/rubygems/0/errors.rbs +113 -0
- metadata +54 -4
- data/lib/rbs/char_scanner.rb +0 -20
@@ -0,0 +1,270 @@
|
|
1
|
+
module RBS
|
2
|
+
module Unnamed
|
3
|
+
%a{annotate:rdoc:copy:Random::Base}
|
4
|
+
class Random_Base
|
5
|
+
include Random_Formatter
|
6
|
+
extend Random_Formatter
|
7
|
+
|
8
|
+
# <!--
|
9
|
+
# rdoc-file=random.c
|
10
|
+
# - Random.new(seed = Random.new_seed) -> prng
|
11
|
+
# -->
|
12
|
+
# Creates a new PRNG using `seed` to set the initial state. If `seed` is
|
13
|
+
# omitted, the generator is initialized with Random.new_seed.
|
14
|
+
#
|
15
|
+
# See Random.srand for more information on the use of seed values.
|
16
|
+
#
|
17
|
+
%a{annotate:rdoc:copy:Random.new}
|
18
|
+
def initialize: (?Integer seed) -> void
|
19
|
+
|
20
|
+
# <!--
|
21
|
+
# rdoc-file=random.c
|
22
|
+
# - prng.rand -> float
|
23
|
+
# - prng.rand(max) -> number
|
24
|
+
# - prng.rand(range) -> number
|
25
|
+
# -->
|
26
|
+
# When `max` is an Integer, `rand` returns a random integer greater than or
|
27
|
+
# equal to zero and less than `max`. Unlike Kernel.rand, when `max` is a
|
28
|
+
# negative integer or zero, `rand` raises an ArgumentError.
|
29
|
+
#
|
30
|
+
# prng = Random.new
|
31
|
+
# prng.rand(100) # => 42
|
32
|
+
#
|
33
|
+
# When `max` is a Float, `rand` returns a random floating point number between
|
34
|
+
# 0.0 and `max`, including 0.0 and excluding `max`.
|
35
|
+
#
|
36
|
+
# prng.rand(1.5) # => 1.4600282860034115
|
37
|
+
#
|
38
|
+
# When `range` is a Range, `rand` returns a random number where
|
39
|
+
# `range.member?(number) == true`.
|
40
|
+
#
|
41
|
+
# prng.rand(5..9) # => one of [5, 6, 7, 8, 9]
|
42
|
+
# prng.rand(5...9) # => one of [5, 6, 7, 8]
|
43
|
+
# prng.rand(5.0..9.0) # => between 5.0 and 9.0, including 9.0
|
44
|
+
# prng.rand(5.0...9.0) # => between 5.0 and 9.0, excluding 9.0
|
45
|
+
#
|
46
|
+
# Both the beginning and ending values of the range must respond to subtract
|
47
|
+
# (`-`) and add (`+`)methods, or rand will raise an ArgumentError.
|
48
|
+
#
|
49
|
+
%a{annotate:rdoc:copy:Random#rand}
|
50
|
+
def rand: () -> Float
|
51
|
+
| (Integer | ::Range[Integer] max) -> Integer
|
52
|
+
| (Float | ::Range[Float] max) -> Float
|
53
|
+
|
54
|
+
# <!--
|
55
|
+
# rdoc-file=random.c
|
56
|
+
# - prng.bytes(size) -> string
|
57
|
+
# -->
|
58
|
+
# Returns a random binary string containing `size` bytes.
|
59
|
+
#
|
60
|
+
# random_string = Random.new.bytes(10) # => "\xD7:R\xAB?\x83\xCE\xFAkO"
|
61
|
+
# random_string.size # => 10
|
62
|
+
#
|
63
|
+
%a{annotate:rdoc:copy:Random#bytes}
|
64
|
+
def bytes: (Integer size) -> String
|
65
|
+
|
66
|
+
# <!--
|
67
|
+
# rdoc-file=random.c
|
68
|
+
# - prng.seed -> integer
|
69
|
+
# -->
|
70
|
+
# Returns the seed value used to initialize the generator. This may be used to
|
71
|
+
# initialize another generator with the same state at a later time, causing it
|
72
|
+
# to produce the same sequence of numbers.
|
73
|
+
#
|
74
|
+
# prng1 = Random.new(1234)
|
75
|
+
# prng1.seed #=> 1234
|
76
|
+
# prng1.rand(100) #=> 47
|
77
|
+
#
|
78
|
+
# prng2 = Random.new(prng1.seed)
|
79
|
+
# prng2.rand(100) #=> 47
|
80
|
+
#
|
81
|
+
%a{annotate:rdoc:copy:Random#seed}
|
82
|
+
def seed: () -> Integer
|
83
|
+
end
|
84
|
+
|
85
|
+
# <!-- rdoc-file=lib/random/formatter.rb -->
|
86
|
+
# ## Random number formatter.
|
87
|
+
#
|
88
|
+
# Formats generated random numbers in many manners.
|
89
|
+
#
|
90
|
+
# ### Examples
|
91
|
+
#
|
92
|
+
# Generate random hexadecimal strings:
|
93
|
+
#
|
94
|
+
# require 'random/formatter'
|
95
|
+
#
|
96
|
+
# prng.hex(10) #=> "52750b30ffbc7de3b362"
|
97
|
+
# prng.hex(10) #=> "92b15d6c8dc4beb5f559"
|
98
|
+
# prng.hex(13) #=> "39b290146bea6ce975c37cfc23"
|
99
|
+
#
|
100
|
+
# Generate random base64 strings:
|
101
|
+
#
|
102
|
+
# prng.base64(10) #=> "EcmTPZwWRAozdA=="
|
103
|
+
# prng.base64(10) #=> "KO1nIU+p9DKxGg=="
|
104
|
+
# prng.base64(12) #=> "7kJSM/MzBJI+75j8"
|
105
|
+
#
|
106
|
+
# Generate random binary strings:
|
107
|
+
#
|
108
|
+
# prng.random_bytes(10) #=> "\016\t{\370g\310pbr\301"
|
109
|
+
# prng.random_bytes(10) #=> "\323U\030TO\234\357\020\a\337"
|
110
|
+
#
|
111
|
+
# Generate alphanumeric strings:
|
112
|
+
#
|
113
|
+
# prng.alphanumeric(10) #=> "S8baxMJnPl"
|
114
|
+
# prng.alphanumeric(10) #=> "aOxAg8BAJe"
|
115
|
+
#
|
116
|
+
# Generate UUIDs:
|
117
|
+
#
|
118
|
+
# prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
|
119
|
+
# prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
|
120
|
+
#
|
121
|
+
# <!-- rdoc-file=random.c -->
|
122
|
+
# Generate a random number in the given range as Random does
|
123
|
+
#
|
124
|
+
# prng.random_number #=> 0.5816771641321361
|
125
|
+
# prng.random_number(1000) #=> 485
|
126
|
+
# prng.random_number(1..6) #=> 3
|
127
|
+
# prng.rand #=> 0.5816771641321361
|
128
|
+
# prng.rand(1000) #=> 485
|
129
|
+
# prng.rand(1..6) #=> 3
|
130
|
+
#
|
131
|
+
%a{annotate:rdoc:copy:Random::Formatter}
|
132
|
+
module Random_Formatter
|
133
|
+
# <!--
|
134
|
+
# rdoc-file=lib/random/formatter.rb
|
135
|
+
# - base64(n=nil)
|
136
|
+
# -->
|
137
|
+
# Random::Formatter#base64 generates a random base64 string.
|
138
|
+
#
|
139
|
+
# The argument *n* specifies the length, in bytes, of the random number to be
|
140
|
+
# generated. The length of the result string is about 4/3 of *n*.
|
141
|
+
#
|
142
|
+
# If *n* is not specified or is nil, 16 is assumed. It may be larger in the
|
143
|
+
# future.
|
144
|
+
#
|
145
|
+
# The result may contain A-Z, a-z, 0-9, "+", "/" and "=".
|
146
|
+
#
|
147
|
+
# require 'random/formatter'
|
148
|
+
#
|
149
|
+
# prng.base64 #=> "/2BuBuLf3+WfSKyQbRcc/A=="
|
150
|
+
# prng.base64 #=> "6BbW0pxO0YENxn38HMUbcQ=="
|
151
|
+
#
|
152
|
+
# See RFC 3548 for the definition of base64.
|
153
|
+
#
|
154
|
+
%a{annotate:rdoc:copy:Random::Formatter#base64}
|
155
|
+
def base64: (?Integer? n) -> String
|
156
|
+
|
157
|
+
# <!--
|
158
|
+
# rdoc-file=lib/random/formatter.rb
|
159
|
+
# - hex(n=nil)
|
160
|
+
# -->
|
161
|
+
# Random::Formatter#hex generates a random hexadecimal string.
|
162
|
+
#
|
163
|
+
# The argument *n* specifies the length, in bytes, of the random number to be
|
164
|
+
# generated. The length of the resulting hexadecimal string is twice of *n*.
|
165
|
+
#
|
166
|
+
# If *n* is not specified or is nil, 16 is assumed. It may be larger in the
|
167
|
+
# future.
|
168
|
+
#
|
169
|
+
# The result may contain 0-9 and a-f.
|
170
|
+
#
|
171
|
+
# require 'random/formatter'
|
172
|
+
#
|
173
|
+
# prng.hex #=> "eb693ec8252cd630102fd0d0fb7c3485"
|
174
|
+
# prng.hex #=> "91dc3bfb4de5b11d029d376634589b61"
|
175
|
+
#
|
176
|
+
%a{annotate:rdoc:copy:Random::Formatter#hex}
|
177
|
+
def hex: (?Integer? n) -> String
|
178
|
+
|
179
|
+
# <!-- rdoc-file=random.c -->
|
180
|
+
# Generates formatted random number from raw random bytes. See Random#rand.
|
181
|
+
#
|
182
|
+
%a{annotate:rdoc:copy:Random::Formatter#rand}
|
183
|
+
def rand: () -> Float
|
184
|
+
| (?Float? n) -> Float
|
185
|
+
| (?Integer? n) -> Integer
|
186
|
+
| (?Numeric? n) -> Numeric
|
187
|
+
| (?::Range[Float]? n) -> Float
|
188
|
+
| (?::Range[Integer]? n) -> Integer
|
189
|
+
| (?::Range[Numeric]? n) -> Numeric
|
190
|
+
|
191
|
+
%a{annotate:rdoc:copy:Random::Formatter#random_byte}
|
192
|
+
def random_bytes: (?Integer? n) -> String
|
193
|
+
|
194
|
+
# <!--
|
195
|
+
# rdoc-file=random.c
|
196
|
+
# - prng.random_number -> float
|
197
|
+
# - prng.random_number(max) -> number
|
198
|
+
# - prng.random_number(range) -> number
|
199
|
+
# - prng.rand -> float
|
200
|
+
# - prng.rand(max) -> number
|
201
|
+
# - prng.rand(range) -> number
|
202
|
+
# -->
|
203
|
+
# Generates formatted random number from raw random bytes. See Random#rand.
|
204
|
+
#
|
205
|
+
%a{annotate:rdoc:copy:Random::Formatter#random_number}
|
206
|
+
def random_number: () -> Float
|
207
|
+
| (?Float? n) -> Float
|
208
|
+
| (?Integer? n) -> Integer
|
209
|
+
| (?Numeric? n) -> Numeric
|
210
|
+
| (?::Range[Float]? n) -> Float
|
211
|
+
| (?::Range[Integer]? n) -> Integer
|
212
|
+
| (?::Range[Numeric]? n) -> Numeric
|
213
|
+
|
214
|
+
# <!--
|
215
|
+
# rdoc-file=lib/random/formatter.rb
|
216
|
+
# - urlsafe_base64(n=nil, padding=false)
|
217
|
+
# -->
|
218
|
+
# Random::Formatter#urlsafe_base64 generates a random URL-safe base64 string.
|
219
|
+
#
|
220
|
+
# The argument *n* specifies the length, in bytes, of the random number to be
|
221
|
+
# generated. The length of the result string is about 4/3 of *n*.
|
222
|
+
#
|
223
|
+
# If *n* is not specified or is nil, 16 is assumed. It may be larger in the
|
224
|
+
# future.
|
225
|
+
#
|
226
|
+
# The boolean argument *padding* specifies the padding. If it is false or nil,
|
227
|
+
# padding is not generated. Otherwise padding is generated. By default, padding
|
228
|
+
# is not generated because "=" may be used as a URL delimiter.
|
229
|
+
#
|
230
|
+
# The result may contain A-Z, a-z, 0-9, "-" and "_". "=" is also used if
|
231
|
+
# *padding* is true.
|
232
|
+
#
|
233
|
+
# require 'random/formatter'
|
234
|
+
#
|
235
|
+
# prng.urlsafe_base64 #=> "b4GOKm4pOYU_-BOXcrUGDg"
|
236
|
+
# prng.urlsafe_base64 #=> "UZLdOkzop70Ddx-IJR0ABg"
|
237
|
+
#
|
238
|
+
# prng.urlsafe_base64(nil, true) #=> "i0XQ-7gglIsHGV2_BNPrdQ=="
|
239
|
+
# prng.urlsafe_base64(nil, true) #=> "-M8rLhr7JEpJlqFGUMmOxg=="
|
240
|
+
#
|
241
|
+
# See RFC 3548 for the definition of URL-safe base64.
|
242
|
+
#
|
243
|
+
%a{annotate:rdoc:copy:Random::Formatter#urlsafe_base64}
|
244
|
+
def urlsafe_base64: (?Integer? n, ?boolish padding) -> String
|
245
|
+
|
246
|
+
# <!--
|
247
|
+
# rdoc-file=lib/random/formatter.rb
|
248
|
+
# - uuid()
|
249
|
+
# -->
|
250
|
+
# Random::Formatter#uuid generates a random v4 UUID (Universally Unique
|
251
|
+
# IDentifier).
|
252
|
+
#
|
253
|
+
# require 'random/formatter'
|
254
|
+
#
|
255
|
+
# prng.uuid #=> "2d931510-d99f-494a-8c67-87feb05e1594"
|
256
|
+
# prng.uuid #=> "bad85eb9-0713-4da7-8d36-07a8e4b00eab"
|
257
|
+
# prng.uuid #=> "62936e70-1815-439b-bf89-8492855a7e6b"
|
258
|
+
#
|
259
|
+
# The version 4 UUID is purely random (except the version). It doesn't contain
|
260
|
+
# meaningful information such as MAC addresses, timestamps, etc.
|
261
|
+
#
|
262
|
+
# The result contains 122 random bits (15.25 random bytes).
|
263
|
+
#
|
264
|
+
# See RFC 4122 for details of UUID.
|
265
|
+
#
|
266
|
+
%a{annotate:rdoc:copy:Random::Formatter#uuid}
|
267
|
+
def uuid: () -> String
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
data/core/regexp.rbs
CHANGED
@@ -760,7 +760,7 @@ class Regexp
|
|
760
760
|
# r3 = Regexp.new(r2) #=> /cat/i
|
761
761
|
# r4 = Regexp.new('dog', Regexp::EXTENDED | Regexp::IGNORECASE) #=> /dog/ix
|
762
762
|
#
|
763
|
-
def initialize: (String string, ?
|
763
|
+
def initialize: (String string, ?Integer | nil | false options, ?String kcode) -> Object
|
764
764
|
| (Regexp regexp) -> void
|
765
765
|
|
766
766
|
# <!--
|
@@ -769,8 +769,7 @@ class Regexp
|
|
769
769
|
# -->
|
770
770
|
# Alias for Regexp.new
|
771
771
|
#
|
772
|
-
|
773
|
-
| (Regexp regexp) -> Regexp
|
772
|
+
alias self.compile self.new
|
774
773
|
|
775
774
|
# <!--
|
776
775
|
# rdoc-file=re.c
|
data/docs/CONTRIBUTING.md
CHANGED
@@ -32,7 +32,7 @@ You will typically follow the steps as follows:
|
|
32
32
|
|
33
33
|
1. Run `rbs prototype runtime` to generate list of methods.
|
34
34
|
2. Run `rbs annotate` to import RDoc comments.
|
35
|
-
3. Run `
|
35
|
+
3. Run `rake generate:stdlib_test[LIB]` to generate a test case.
|
36
36
|
4. Write the type definitions and tests.
|
37
37
|
|
38
38
|
See the next *Useful Tools* section and the guides above for writing and testing RBS files.
|
@@ -51,7 +51,7 @@ See the next *Useful Tools* section and the guides above for writing and testing
|
|
51
51
|
* Print RDoc documents in the format you can copy-and-paste to RBS.
|
52
52
|
* `bin/sort core/string.rbs`
|
53
53
|
* Sort declarations members in RBS files.
|
54
|
-
* `rbs
|
54
|
+
* `rbs -r LIB validate`
|
55
55
|
Validate the syntax and some of the semantics.
|
56
56
|
* `rake generate:stdlib_test[String]`
|
57
57
|
Scaffold the stdlib test.
|