rbs 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/core/string_io.rbs CHANGED
@@ -164,10 +164,9 @@ class StringIO
164
164
 
165
165
  # See IO#read.
166
166
  #
167
- def read: (?Integer length, ?String outbuf) -> String?
167
+ def read: (?int? length, ?string outbuf) -> String?
168
168
 
169
- def read_nonblock: (Integer len) -> String
170
- | (Integer len, ?String buf) -> String
169
+ def read_nonblock: (int len, ?string buf) -> String
171
170
 
172
171
  def readbyte: () -> Integer
173
172
 
@@ -179,8 +178,7 @@ class StringIO
179
178
  #
180
179
  def readlines: (?String sep, ?Integer limit, ?chomp: boolish) -> ::Array[String]
181
180
 
182
- def readpartial: (Integer maxlen) -> String
183
- | (Integer maxlen, ?String outbuf) -> String
181
+ def readpartial: (int maxlen, ?string outbuf) -> String
184
182
 
185
183
  # Reinitializes the stream with the given *other_StrIO* or *string* and *mode*
186
184
  # (see StringIO#new).
data/lib/rbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
@@ -0,0 +1,418 @@
1
+ # This module provides a framework for message digest libraries.
2
+ #
3
+ # You may want to look at OpenSSL::Digest as it supports more algorithms.
4
+ #
5
+ # A cryptographic hash function is a procedure that takes data and returns a
6
+ # fixed bit string: the hash value, also known as *digest*. Hash functions are
7
+ # also called one-way functions, it is easy to compute a digest from a message,
8
+ # but it is infeasible to generate a message from a digest.
9
+ #
10
+ # ## Examples
11
+ #
12
+ # require 'digest'
13
+ #
14
+ # # Compute a complete digest
15
+ # Digest::SHA256.digest 'message' #=> "\xABS\n\x13\xE4Y..."
16
+ #
17
+ # sha256 = Digest::SHA256.new
18
+ # sha256.digest 'message' #=> "\xABS\n\x13\xE4Y..."
19
+ #
20
+ # # Other encoding formats
21
+ # Digest::SHA256.hexdigest 'message' #=> "ab530a13e459..."
22
+ # Digest::SHA256.base64digest 'message' #=> "q1MKE+RZFJgr..."
23
+ #
24
+ # # Compute digest by chunks
25
+ # md5 = Digest::MD5.new
26
+ # md5.update 'message1'
27
+ # md5 << 'message2' # << is an alias for update
28
+ #
29
+ # md5.hexdigest #=> "94af09c09bb9..."
30
+ #
31
+ # # Compute digest for a file
32
+ # sha256 = Digest::SHA256.file 'testfile'
33
+ # sha256.hexdigest
34
+ #
35
+ # Additionally digests can be encoded in "bubble babble" format as a sequence of
36
+ # consonants and vowels which is more recognizable and comparable than a
37
+ # hexadecimal digest.
38
+ #
39
+ # require 'digest/bubblebabble'
40
+ #
41
+ # Digest::SHA256.bubblebabble 'message' #=> "xopoh-fedac-fenyh-..."
42
+ #
43
+ # See the bubble babble specification at
44
+ # http://web.mit.edu/kenta/www/one/bubblebabble/spec/jrtrjwzi/draft-huima-01.txt
45
+ # .
46
+ #
47
+ # ## Digest algorithms
48
+ #
49
+ # Different digest algorithms (or hash functions) are available:
50
+ #
51
+ # MD5
52
+ # : See RFC 1321 The MD5 Message-Digest Algorithm
53
+ # RIPEMD-160
54
+ # : As Digest::RMD160. See
55
+ # http://homes.esat.kuleuven.be/~bosselae/ripemd160.html.
56
+ # SHA1
57
+ # : See FIPS 180 Secure Hash Standard.
58
+ # SHA2 family
59
+ # : See FIPS 180 Secure Hash Standard which defines the following algorithms:
60
+ # * SHA512
61
+ # * SHA384
62
+ # * SHA256
63
+ #
64
+ #
65
+ #
66
+ # The latest versions of the FIPS publications can be found here:
67
+ # http://csrc.nist.gov/publications/PubsFIPS.html.
68
+ module Digest
69
+ # Returns a BubbleBabble encoded version of a given *string*.
70
+ #
71
+ def self.bubblebabble: (String) -> String
72
+
73
+ def self.const_missing: (Symbol name) -> singleton(::Digest::Base)
74
+
75
+ # Generates a hex-encoded version of a given *string*.
76
+ #
77
+ def self.hexencode: (String) -> String
78
+
79
+ private
80
+
81
+ def bubblebabble: (String) -> String
82
+
83
+ def hexencode: (String) -> String
84
+ end
85
+
86
+ # A mutex for Digest().
87
+ Digest::REQUIRE_MUTEX: Thread::Mutex
88
+
89
+ # This module provides instance methods for a digest implementation object to
90
+ # calculate message digest values.
91
+ module Digest::Instance
92
+ public
93
+
94
+ # Updates the digest using a given *string* and returns self.
95
+ #
96
+ # The update() method and the left-shift operator are overridden by each
97
+ # implementation subclass. (One should be an alias for the other)
98
+ #
99
+ def <<: (String) -> self
100
+
101
+ # If a string is given, checks whether it is equal to the hex-encoded hash value
102
+ # of the digest object. If another digest instance is given, checks whether
103
+ # they have the same hash value. Otherwise returns false.
104
+ #
105
+ def ==: (::Digest::Instance | String) -> bool
106
+
107
+ # If none is given, returns the resulting hash value of the digest in a base64
108
+ # encoded form, keeping the digest's state.
109
+ #
110
+ # If a `string` is given, returns the hash value for the given `string` in a
111
+ # base64 encoded form, resetting the digest to the initial state before and
112
+ # after the process.
113
+ #
114
+ # In either case, the return value is properly padded with '=' and contains no
115
+ # line feeds.
116
+ #
117
+ def base64digest: (?String? str) -> String
118
+
119
+ # Returns the resulting hash value and resets the digest to the initial state.
120
+ #
121
+ def base64digest!: () -> String
122
+
123
+ # Returns the block length of the digest.
124
+ #
125
+ # This method is overridden by each implementation subclass.
126
+ #
127
+ def block_length: () -> Integer
128
+
129
+ # Returns the resulting hash value in a Bubblebabble encoded form.
130
+ #
131
+ def bubblebabble: () -> String
132
+
133
+ # If none is given, returns the resulting hash value of the digest, keeping the
134
+ # digest's state.
135
+ #
136
+ # If a *string* is given, returns the hash value for the given *string*,
137
+ # resetting the digest to the initial state before and after the process.
138
+ #
139
+ def digest: (?String) -> String
140
+
141
+ # Returns the resulting hash value and resets the digest to the initial state.
142
+ #
143
+ def digest!: () -> String
144
+
145
+ # Returns the length of the hash value of the digest.
146
+ #
147
+ # This method should be overridden by each implementation subclass. If not,
148
+ # digest_obj.digest().length() is returned.
149
+ #
150
+ def digest_length: () -> Integer
151
+
152
+ # Updates the digest with the contents of a given file *name* and returns self.
153
+ #
154
+ def file: (String name) -> self
155
+
156
+ # If none is given, returns the resulting hash value of the digest in a
157
+ # hex-encoded form, keeping the digest's state.
158
+ #
159
+ # If a *string* is given, returns the hash value for the given *string* in a
160
+ # hex-encoded form, resetting the digest to the initial state before and after
161
+ # the process.
162
+ #
163
+ def hexdigest: (?String) -> String
164
+
165
+ # Returns the resulting hash value in a hex-encoded form and resets the digest
166
+ # to the initial state.
167
+ #
168
+ def hexdigest!: () -> String
169
+
170
+ # Creates a printable version of the digest object.
171
+ #
172
+ def inspect: () -> String
173
+
174
+ # Returns digest_obj.digest_length().
175
+ #
176
+ def length: () -> Integer
177
+
178
+ # Returns a new, initialized copy of the digest object. Equivalent to
179
+ # digest_obj.clone().reset().
180
+ #
181
+ def new: () -> ::Digest::Base
182
+
183
+ # Resets the digest to the initial state and returns self.
184
+ #
185
+ # This method is overridden by each implementation subclass.
186
+ #
187
+ def reset: () -> self
188
+
189
+ # Returns digest_obj.digest_length().
190
+ #
191
+ def size: () -> Integer
192
+
193
+ # Returns digest_obj.hexdigest().
194
+ #
195
+ def to_s: () -> String
196
+
197
+ # Updates the digest using a given *string* and returns self.
198
+ #
199
+ # The update() method and the left-shift operator are overridden by each
200
+ # implementation subclass. (One should be an alias for the other)
201
+ #
202
+ def update: (String) -> self
203
+
204
+ private
205
+
206
+ # Finishes the digest and returns the resulting hash value.
207
+ #
208
+ # This method is overridden by each implementation subclass and often made
209
+ # private, because some of those subclasses may leave internal data
210
+ # uninitialized. Do not call this method from outside. Use #digest!() instead,
211
+ # which ensures that internal data be reset for security reasons.
212
+ #
213
+ def finish: () -> self
214
+ end
215
+
216
+ # This module stands as a base class for digest implementation classes.
217
+ class Digest::Class
218
+ include ::Digest::Instance
219
+
220
+ # Returns the base64 encoded hash value of a given *string*. The return value
221
+ # is properly padded with '=' and contains no line feeds.
222
+ #
223
+ def self.base64digest: (String str, *untyped) -> String
224
+
225
+ # Returns the BubbleBabble encoded hash value of a given *string*.
226
+ #
227
+ def self.bubblebabble: (String, *untyped) -> String
228
+
229
+ # Returns the hash value of a given *string*. This is equivalent to
230
+ # Digest::Class.new(*parameters).digest(string), where extra *parameters*, if
231
+ # any, are passed through to the constructor and the *string* is passed to
232
+ # #digest().
233
+ #
234
+ def self.digest: (String, *untyped) -> String
235
+
236
+ # Creates a digest object and reads a given file, *name*. Optional arguments are
237
+ # passed to the constructor of the digest class.
238
+ #
239
+ # p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
240
+ # # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
241
+ #
242
+ def self.file: (String name, *untyped) -> ::Digest::Class
243
+
244
+ # Returns the hex-encoded hash value of a given *string*. This is almost
245
+ # equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
246
+ #
247
+ def self.hexdigest: (String, *untyped) -> String
248
+
249
+ private
250
+
251
+ def initialize: () -> self
252
+ end
253
+
254
+ # This abstract class provides a common interface to message digest
255
+ # implementation classes written in C.
256
+ #
257
+ # ## Write a Digest subclass in C
258
+ # Digest::Base provides a common interface to message digest classes written in
259
+ # C. These classes must provide a struct of type rb_digest_metadata_t:
260
+ # typedef int (*rb_digest_hash_init_func_t)(void *);
261
+ # typedef void (*rb_digest_hash_update_func_t)(void *, unsigned char *, size_t);
262
+ # typedef int (*rb_digest_hash_finish_func_t)(void *, unsigned char *);
263
+ #
264
+ # typedef struct {
265
+ # int api_version;
266
+ # size_t digest_len;
267
+ # size_t block_len;
268
+ # size_t ctx_size;
269
+ # rb_digest_hash_init_func_t init_func;
270
+ # rb_digest_hash_update_func_t update_func;
271
+ # rb_digest_hash_finish_func_t finish_func;
272
+ # } rb_digest_metadata_t;
273
+ #
274
+ # This structure must be set as an instance variable named `metadata` (without
275
+ # the +@+ in front of the name). By example:
276
+ # static const rb_digest_metadata_t sha1 = {
277
+ # RUBY_DIGEST_API_VERSION,
278
+ # SHA1_DIGEST_LENGTH,
279
+ # SHA1_BLOCK_LENGTH,
280
+ # sizeof(SHA1_CTX),
281
+ # (rb_digest_hash_init_func_t)SHA1_Init,
282
+ # (rb_digest_hash_update_func_t)SHA1_Update,
283
+ # (rb_digest_hash_finish_func_t)SHA1_Finish,
284
+ # };
285
+ #
286
+ # rb_ivar_set(cDigest_SHA1, rb_intern("metadata"),
287
+ # Data_Wrap_Struct(0, 0, 0, (void *)&sha1));
288
+ class Digest::Base < Digest::Class
289
+ public
290
+
291
+ # Update the digest using given *string* and return `self`.
292
+ #
293
+ def <<: (String) -> self
294
+
295
+ # Return the block length of the digest in bytes.
296
+ #
297
+ def block_length: () -> Integer
298
+
299
+ # Return the length of the hash value in bytes.
300
+ #
301
+ def digest_length: () -> Integer
302
+
303
+ # Reset the digest to its initial state and return `self`.
304
+ #
305
+ def reset: () -> self
306
+
307
+ # Update the digest using given *string* and return `self`.
308
+ #
309
+ def update: (String) -> self
310
+
311
+ private
312
+
313
+ def finish: () -> String
314
+
315
+ def initialize_copy: (::Digest::Base) -> self
316
+ end
317
+
318
+ # A class for calculating message digests using the SHA-1 Secure Hash Algorithm
319
+ # by NIST (the US' National Institute of Standards and Technology), described in
320
+ # FIPS PUB 180-1.
321
+ #
322
+ # See Digest::Instance for digest API.
323
+ #
324
+ # SHA-1 calculates a digest of 160 bits (20 bytes).
325
+ #
326
+ # ## Examples
327
+ # require 'digest'
328
+ #
329
+ # # Compute a complete digest
330
+ # Digest::SHA1.hexdigest 'abc' #=> "a9993e36..."
331
+ #
332
+ # # Compute digest by chunks
333
+ # sha1 = Digest::SHA1.new # =>#<Digest::SHA1>
334
+ # sha1.update "ab"
335
+ # sha1 << "c" # alias for #update
336
+ # sha1.hexdigest # => "a9993e36..."
337
+ #
338
+ # # Use the same object to compute another digest
339
+ # sha1.reset
340
+ # sha1 << "message"
341
+ # sha1.hexdigest # => "6f9b9af3..."
342
+ class Digest::SHA1 < Digest::Base
343
+ end
344
+
345
+ # A class for calculating message digests using the MD5 Message-Digest Algorithm
346
+ # by RSA Data Security, Inc., described in RFC1321.
347
+ #
348
+ # MD5 calculates a digest of 128 bits (16 bytes).
349
+ #
350
+ # ## Examples
351
+ # require 'digest'
352
+ #
353
+ # # Compute a complete digest
354
+ # Digest::MD5.hexdigest 'abc' #=> "90015098..."
355
+ #
356
+ # # Compute digest by chunks
357
+ # md5 = Digest::MD5.new # =>#<Digest::MD5>
358
+ # md5.update "ab"
359
+ # md5 << "c" # alias for #update
360
+ # md5.hexdigest # => "90015098..."
361
+ #
362
+ # # Use the same object to compute another digest
363
+ # md5.reset
364
+ # md5 << "message"
365
+ # md5.hexdigest # => "78e73102..."
366
+ class Digest::MD5 < Digest::Base
367
+ end
368
+
369
+ # A class for calculating message digests using RIPEMD-160 cryptographic hash
370
+ # function, designed by Hans Dobbertin, Antoon Bosselaers, and Bart Preneel.
371
+ #
372
+ # RMD160 calculates a digest of 160 bits (20 bytes).
373
+ #
374
+ # ## Examples
375
+ # require 'digest'
376
+ #
377
+ # # Compute a complete digest
378
+ # Digest::RMD160.hexdigest 'abc' #=> "8eb208f7..."
379
+ #
380
+ # # Compute digest by chunks
381
+ # rmd160 = Digest::RMD160.new # =>#<Digest::RMD160>
382
+ # rmd160.update "ab"
383
+ # rmd160 << "c" # alias for #update
384
+ # rmd160.hexdigest # => "8eb208f7..."
385
+ #
386
+ # # Use the same object to compute another digest
387
+ # rmd160.reset
388
+ # rmd160 << "message"
389
+ # rmd160.hexdigest # => "1dddbe1b..."
390
+ class Digest::RMD160 < Digest::Base
391
+ end
392
+
393
+ class Digest::SHA256 < Digest::Base
394
+ end
395
+
396
+ class Digest::SHA384 < Digest::Base
397
+ end
398
+
399
+ class Digest::SHA512 < Digest::Base
400
+ end
401
+
402
+ class Object
403
+ # Returns a Digest subclass by `name` in a thread-safe manner even when
404
+ # on-demand loading is involved.
405
+ #
406
+ # require 'digest'
407
+ #
408
+ # Digest("MD5")
409
+ # # => Digest::MD5
410
+ #
411
+ # Digest(:SHA256)
412
+ # # => Digest::SHA256
413
+ #
414
+ # Digest(:Foo)
415
+ # # => LoadError: library not found for class Digest::Foo -- digest/foo
416
+ #
417
+ def Digest: (String | Symbol name) -> singleton(::Digest::Base)
418
+ 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: 1.4.0
4
+ version: 1.5.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: 2021-08-18 00:00:00.000000000 Z
11
+ date: 2021-08-21 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -56,6 +56,7 @@ files:
56
56
  - core/hash.rbs
57
57
  - core/integer.rbs
58
58
  - core/io.rbs
59
+ - core/io/wait.rbs
59
60
  - core/kernel.rbs
60
61
  - core/marshal.rbs
61
62
  - core/match_data.rbs
@@ -68,6 +69,7 @@ files:
68
69
  - core/object_space.rbs
69
70
  - core/proc.rbs
70
71
  - core/process.rbs
72
+ - core/ractor.rbs
71
73
  - core/random.rbs
72
74
  - core/range.rbs
73
75
  - core/rational.rbs
@@ -203,6 +205,7 @@ files:
203
205
  - stdlib/date/0/date.rbs
204
206
  - stdlib/date/0/date_time.rbs
205
207
  - stdlib/dbm/0/dbm.rbs
208
+ - stdlib/digest/0/digest.rbs
206
209
  - stdlib/erb/0/erb.rbs
207
210
  - stdlib/fiber/0/fiber.rbs
208
211
  - stdlib/fileutils/0/fileutils.rbs