rbs 1.0.1 → 1.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d03121b9d58454590a45862ba1d479305feae4f2b4d10707ae8e1a3c24d4aba
4
- data.tar.gz: f147d99859cfc7e18b41a751587f7b2cba484bf397d5b306b9fe69f15dd4b452
3
+ metadata.gz: 0c8f0c698e503246f1952a9f05aed05cd1a820d4ea67721970497664bf0ee3fd
4
+ data.tar.gz: bf2d2e438893b213ad750d1fcd71c9d1b318f9cff1f2212ee65a3dc50cf43e39
5
5
  SHA512:
6
- metadata.gz: 2e325492bc73b6d9f2f62660c4e4821f7d3853780f39a957e02ad4b30fc44ca1e687fbde9d0b2843be786e51126fbb5473e1d5ae5c9c719f255bfc50fe2f7cde
7
- data.tar.gz: '03995c9d63b9db359744338497985952eed7608729cb4a259b20af6e68de5eecdf3c996404701e2821f35d4bebfdb1e2c7c8e6289f9b5a7875fd4c6c507bde27'
6
+ metadata.gz: 53fd4afc4d095999f7a03d6199af9cdd1009a378ebd2976c690c54a2bd2aed81d129912c70a16914733bd252a58e50223f9090bd995ca53a01a1acef513efd4a
7
+ data.tar.gz: b976e7a9c8bd2b80912290d7047403cfc2d7b09ed405e82aa52b75e9ed19737c144bc9c62d72f0ddcf2839117400d3e5207952753fb73097b21fdfd1192d214f
data/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.0.6 (2021-02-17)
6
+
7
+ * Signature Updates
8
+ * `Enumerable` ([\#595](https://github.com/ruby/rbs/pull/595), [\#596](https://github.com/ruby/rbs/pull/596), [\#601](https://github.com/ruby/rbs/pull/601))
9
+ * `#as_json` ([\#597](https://github.com/ruby/rbs/pull/597))
10
+
11
+ ## 1.0.5 (2021-02-13)
12
+
13
+ * Signature Updates
14
+ * Enumerable ([\#596](https://github.com/ruby/rbs/pull/596))
15
+ * Set ([\#595](https://github.com/ruby/rbs/pull/595))
16
+ * `#to_json` ([\#592](https://github.com/ruby/rbs/pull/592))
17
+ * `<=>` ([\#593](https://github.com/ruby/rbs/pull/593))
18
+ * Timeout ([\#586](https://github.com/ruby/rbs/pull/586))
19
+ * URI::RFC2396_Parser ([\#587](https://github.com/ruby/rbs/pull/587))
20
+ * Rename generic class parameters on re-open ([\#594](https://github.com/ruby/rbs/pull/594))
21
+ * Make `refute_send_type` check that method call doesn't match with types in RBS ([\#588](https://github.com/ruby/rbs/pull/588))
22
+
23
+ ## 1.0.4 (2021-01-31)
24
+
25
+ * Unbundle `rr` to run test in `ruby/ruby` repo ([#585](https://github.com/ruby/rbs/pull/585))
26
+
27
+ ## 1.0.3 (2021-01-28)
28
+
29
+ * Set up `#ancestors` and `#location` of `RecursiveAncestorError` ([#583](https://github.com/ruby/rbs/pull/583))
30
+
31
+ ## 1.0.2 (2021-01-28)
32
+
33
+ * Signature Updates
34
+ * Kernel([#582](https://github.com/ruby/rbs/pull/582))
35
+
5
36
  ## 1.0.1 (2021-01-27)
6
37
 
7
38
  * Signature Updates
data/Gemfile CHANGED
@@ -6,7 +6,6 @@ gemspec
6
6
  # Development dependencies
7
7
  gem "rake"
8
8
  gem "test-unit"
9
- gem "test-unit-rr"
10
9
  gem "rspec"
11
10
  gem "racc"
12
11
  gem "rubocop"
data/core/array.rbs CHANGED
@@ -1736,7 +1736,7 @@ class Array[unchecked out Elem] < Object
1736
1736
  # See also Enumerable#sort_by.
1737
1737
  #
1738
1738
  def sort: () -> ::Array[Elem]
1739
- | () { (Elem a, Elem b) -> ::Integer? } -> ::Array[Elem]
1739
+ | () { (Elem a, Elem b) -> ::Integer } -> ::Array[Elem]
1740
1740
 
1741
1741
  # Sorts `self` in place.
1742
1742
  #
@@ -1757,7 +1757,7 @@ class Array[unchecked out Elem] < Object
1757
1757
  # See also Enumerable#sort_by.
1758
1758
  #
1759
1759
  def sort!: () -> self
1760
- | () { (Elem a, Elem b) -> ::Integer? } -> self
1760
+ | () { (Elem a, Elem b) -> ::Integer } -> self
1761
1761
 
1762
1762
  # Sorts `self` in place using a set of keys generated by mapping the values in
1763
1763
  # `self` through the given block.
data/core/complex.rbs CHANGED
@@ -121,7 +121,7 @@ class Complex < Numeric
121
121
  # Complex(2) <=> 2 #=> 0
122
122
  # Complex(2) <=> 3 #=> -1
123
123
  #
124
- def <=>: (Numeric) -> Integer?
124
+ def <=>: (untyped) -> Integer?
125
125
 
126
126
  # Returns true if cmp equals object numerically.
127
127
  #
data/core/enumerable.rbs CHANGED
@@ -286,8 +286,22 @@ module Enumerable[unchecked out Elem]: _Each[Elem]
286
286
  def sort_by: () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
287
287
  | () -> ::Enumerator[Elem, ::Array[Elem]]
288
288
 
289
- def take: (Integer n) -> ::Array[Elem]?
289
+ # Returns first n elements from *enum*.
290
+ #
291
+ # a = [1, 2, 3, 4, 5, 0]
292
+ # a.take(3) #=> [1, 2, 3]
293
+ # a.take(30) #=> [1, 2, 3, 4, 5, 0]
294
+ #
295
+ def take: (Integer n) -> ::Array[Elem]
290
296
 
297
+ # Passes elements to the block until the block returns `nil` or `false`, then
298
+ # stops iterating and returns an array of all prior elements.
299
+ #
300
+ # If no block is given, an enumerator is returned instead.
301
+ #
302
+ # a = [1, 2, 3, 4, 5, 0]
303
+ # a.take_while { |i| i < 3 } #=> [1, 2]
304
+ #
291
305
  def take_while: () { (Elem) -> boolish } -> ::Array[Elem]
292
306
  | () -> ::Enumerator[Elem, ::Array[Elem]]
293
307
 
data/core/enumerator.rbs CHANGED
@@ -244,6 +244,8 @@ end
244
244
 
245
245
  class Enumerator::Generator[out Elem] < Object
246
246
  include Enumerable[Elem]
247
+
248
+ def each: () { (Elem) -> void } -> void
247
249
  end
248
250
 
249
251
  class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
@@ -259,4 +261,6 @@ end
259
261
 
260
262
  class Enumerator::Chain[out Elem] < Object
261
263
  include Enumerable[Elem]
264
+
265
+ def each: () { (Elem) -> void } -> void
262
266
  end
data/core/file.rbs CHANGED
@@ -985,7 +985,8 @@ class File::Stat < Object
985
985
  include Comparable
986
986
 
987
987
  def initialize: (String file) -> Object
988
- def <=>: (File::Stat other) -> Integer?
988
+ def <=>: (File::Stat other) -> Integer
989
+ | (untyped) -> nil
989
990
 
990
991
  def atime: () -> Time
991
992
 
data/core/integer.rbs CHANGED
@@ -112,7 +112,8 @@ class Integer < Numeric
112
112
  #
113
113
  # `nil` is returned if the two values are incomparable.
114
114
  #
115
- def <=>: (Numeric) -> Integer?
115
+ def <=>: (Integer | Rational) -> Integer
116
+ | (untyped) -> Integer?
116
117
 
117
118
  # Returns `true` if `int` equals `other` numerically. Contrast this with
118
119
  # Integer#eql?, which requires `other` to be an Integer.
data/core/kernel.rbs CHANGED
@@ -54,7 +54,7 @@ module Kernel : BasicObject
54
54
  # try { "hello" } #=> "hello"
55
55
  # try do "hello" end #=> "hello"
56
56
  # ```
57
- def self.block_given?: () -> bool
57
+ def self?.block_given?: () -> bool
58
58
 
59
59
  # Returns the names of the current local variables.
60
60
  #
data/core/module.rbs CHANGED
@@ -90,7 +90,7 @@ class Module < Object
90
90
  # Returns `nil` if `module` has no relationship with `other_module`, if
91
91
  # `other_module` is not a module, or if the two values are incomparable.
92
92
  #
93
- def <=>: (Module other) -> Integer?
93
+ def <=>: (untyped other) -> Integer?
94
94
 
95
95
  # Equality --- At the Object level, #== returns `true` only if `obj` and `other`
96
96
  # are the same object. Typically, this method is overridden in descendant
data/core/rational.rbs CHANGED
@@ -125,7 +125,8 @@ class Rational < Numeric
125
125
  #
126
126
  # Rational(1, 3) <=> "0.3" #=> nil
127
127
  #
128
- def <=>: (Numeric) -> Integer?
128
+ def <=>: (Integer | Rational) -> Integer
129
+ | (untyped) -> Integer?
129
130
 
130
131
  # Returns `true` if `rat` equals `object` numerically.
131
132
  #
data/core/string.rbs CHANGED
@@ -91,7 +91,8 @@ class String
91
91
  # "abcdef" <=> "ABCDEF" #=> 1
92
92
  # "abcdef" <=> 1 #=> nil
93
93
  #
94
- def <=>: (untyped other) -> Integer?
94
+ def <=>: (string other) -> Integer
95
+ | (untyped other) -> Integer?
95
96
 
96
97
  # Equality---Returns whether `str` == `obj`, similar to Object#==.
97
98
  #
data/core/symbol.rbs CHANGED
@@ -47,7 +47,8 @@ class Symbol
47
47
  #
48
48
  # See String#<=> for more information.
49
49
  #
50
- def <=>: (untyped other) -> Integer?
50
+ def <=>: (Symbol other) -> Integer
51
+ | (untyped other) -> Integer?
51
52
 
52
53
  # Equality---If *sym* and *obj* are exactly the same symbol, returns `true`.
53
54
  #
data/core/time.rbs CHANGED
@@ -230,7 +230,8 @@ class Time < Object
230
230
  # t2 <=> t #=> 1
231
231
  # t <=> t #=> 0
232
232
  #
233
- def <=>: (Time other) -> Integer?
233
+ def <=>: (Time other) -> Integer
234
+ | (untyped other) -> Integer?
234
235
 
235
236
  def >: (Time arg0) -> bool
236
237
 
data/docs/stdlib.md CHANGED
@@ -70,7 +70,7 @@ One non-trivial but absolutely better solution is to make a tool:
70
70
  The next step should be importing RDoc documents.
71
71
 
72
72
  ```
73
- $ bin/annotate-with-rdoc stdlib/pathname/pathname.rbs
73
+ $ bin/annotate-with-rdoc stdlib/pathname/0/pathname.rbs
74
74
  Loading store from /Users/soutaro/.rbenv/versions/2.7.0-dev/share/ri/2.7.0/system...
75
75
  Loading store from /Users/soutaro/.rbenv/versions/2.7.0-dev/share/ri/2.7.0/site...
76
76
  Opening stdlib/pathname/pathname.rbs...
@@ -245,6 +245,19 @@ module RBS
245
245
  def hash
246
246
  self.class.hash ^ name.hash ^ type.hash ^ ivar_name.hash ^ kind.hash
247
247
  end
248
+
249
+ def update(name: self.name, type: self.type, ivar_name: self.ivar_name, kind: self.kind, annotations: self.annotations, location: self.location, comment: self.comment)
250
+ klass = _ = self.class
251
+ klass.new(
252
+ name: name,
253
+ type: type,
254
+ ivar_name: ivar_name,
255
+ kind: kind,
256
+ annotations: annotations,
257
+ location: location,
258
+ comment: comment
259
+ )
260
+ end
248
261
  end
249
262
 
250
263
  class AttrReader < Base
@@ -139,9 +139,8 @@ module RBS
139
139
  case entry
140
140
  when Environment::ClassEntry, Environment::ModuleEntry
141
141
  ancestors = ancestor_builder.instance_ancestors(type_name)
142
- self_type = Types::ClassInstance.new(name: type_name,
143
- args: Types::Variable.build(entry.type_params.each.map(&:name)),
144
- location: nil)
142
+ args = Types::Variable.build(entry.type_params.each.map(&:name))
143
+ self_type = Types::ClassInstance.new(name: type_name, args: args, location: nil)
145
144
 
146
145
  Definition.new(type_name: type_name, entry: entry, self_type: self_type, ancestors: ancestors).tap do |definition|
147
146
  one_ancestors = ancestor_builder.one_instance_ancestors(type_name)
@@ -217,6 +216,8 @@ module RBS
217
216
  super_interface_method: entry.is_a?(Environment::ModuleEntry))
218
217
 
219
218
  entry.decls.each do |d|
219
+ subst = Substitution.build(d.decl.type_params.each.map(&:name), args)
220
+
220
221
  d.decl.members.each do |member|
221
222
  case member
222
223
  when AST::Members::AttrReader, AST::Members::AttrAccessor, AST::Members::AttrWriter
@@ -229,12 +230,18 @@ module RBS
229
230
  end
230
231
 
231
232
  if ivar_name
232
- insert_variable(type_name, definition.instance_variables, name: ivar_name, type: member.type)
233
+ insert_variable(type_name,
234
+ definition.instance_variables,
235
+ name: ivar_name,
236
+ type: member.type.sub(subst))
233
237
  end
234
238
  end
235
239
 
236
240
  when AST::Members::InstanceVariable
237
- insert_variable(type_name, definition.instance_variables, name: member.name, type: member.type)
241
+ insert_variable(type_name,
242
+ definition.instance_variables,
243
+ name: member.name,
244
+ type: member.type.sub(subst))
238
245
 
239
246
  when AST::Members::ClassVariable
240
247
  insert_variable(type_name, definition.class_variables, name: member.name, type: member.type)
@@ -96,15 +96,22 @@ module RBS
96
96
  type = Types::ClassInstance.new(name: type_name, args: args, location: nil)
97
97
  Methods.new(type: type).tap do |methods|
98
98
  entry.decls.each do |d|
99
+ subst = Substitution.build(d.decl.type_params.each.map(&:name), args)
99
100
  each_member_with_accessibility(d.decl.members) do |member, accessibility|
100
101
  case member
101
102
  when AST::Members::MethodDefinition
102
103
  if member.instance?
103
- build_method(methods, type, member: member, accessibility: accessibility)
104
+ build_method(methods,
105
+ type,
106
+ member: member.update(types: member.types.map {|type| type.sub(subst) }),
107
+ accessibility: accessibility)
104
108
  end
105
109
  when AST::Members::AttrReader, AST::Members::AttrWriter, AST::Members::AttrAccessor
106
110
  if member.kind == :instance
107
- build_attribute(methods, type, member: member, accessibility: accessibility)
111
+ build_attribute(methods,
112
+ type,
113
+ member: member.update(type: member.type.sub(subst)),
114
+ accessibility: accessibility)
108
115
  end
109
116
  when AST::Members::Alias
110
117
  if member.kind == :instance
data/lib/rbs/errors.rb CHANGED
@@ -40,6 +40,9 @@ module RBS
40
40
  attr_reader :location
41
41
 
42
42
  def initialize(ancestors:, location:)
43
+ @ancestors = ancestors
44
+ @location = location
45
+
43
46
  names = ancestors.map do |ancestor|
44
47
  case ancestor
45
48
  when Definition::Ancestor::Singleton
data/lib/rbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.6"
3
3
  end
data/sig/members.rbs CHANGED
@@ -104,6 +104,8 @@ module RBS
104
104
  def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, kind: kind, annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
105
105
 
106
106
  include _HashEqual
107
+
108
+ def update: (?name: Symbol, ?type: Types::t, ?ivar_name: Symbol | false | nil, ?kind: kind, ?annotations: Array[Annotation], ?location: Location?, ?comment: Comment?) -> instance
107
109
  end
108
110
 
109
111
  class AttrReader < Base
@@ -321,7 +321,7 @@ class BigDecimal < Numeric
321
321
 
322
322
  # The comparison operator. a <=> b is 0 if a == b, 1 if a > b, -1 if a < b.
323
323
  #
324
- def <=>: (Numeric) -> Integer?
324
+ def <=>: (untyped) -> Integer?
325
325
 
326
326
  # Tests for value equality; returns true if the values are equal.
327
327
  #
@@ -496,7 +496,7 @@ class Date
496
496
  #
497
497
  # See also Comparable.
498
498
  #
499
- def <=>: (Date | Rational | Object other) -> Integer?
499
+ def <=>: (untyped other) -> Integer?
500
500
 
501
501
  # Returns true if they are the same day.
502
502
  #
@@ -339,3 +339,291 @@ JSON::VERSION_BUILD: Integer
339
339
  JSON::VERSION_MAJOR: Integer
340
340
 
341
341
  JSON::VERSION_MINOR: Integer
342
+
343
+ class Object
344
+ # Converts this object to a string (calling #to_s), converts
345
+ # it to a JSON string, and returns the result. This is a fallback, if no
346
+ # special method #to_json was defined for some object.
347
+ #
348
+ def to_json: (?JSON::State state) -> String
349
+ end
350
+
351
+ class NilClass
352
+ # Returns a JSON string for nil: 'null'.
353
+ #
354
+ def to_json: (?JSON::State state) -> String
355
+ end
356
+
357
+ class TrueClass
358
+ # Returns a JSON string for true: 'true'.
359
+ #
360
+ def to_json: (?JSON::State state) -> String
361
+ end
362
+
363
+ class FalseClass
364
+ # Returns a JSON string for false: 'false'.
365
+ #
366
+ def to_json: (?JSON::State state) -> String
367
+ end
368
+
369
+ class String
370
+ # This string should be encoded with UTF-8 A call to this method
371
+ # returns a JSON string encoded with UTF16 big endian characters as
372
+ # \u????.
373
+ #
374
+ def to_json: (?JSON::State state) -> String
375
+ end
376
+
377
+ class Integer
378
+ # Returns a JSON string representation for this Integer number.
379
+ #
380
+ def to_json: (?JSON::State state) -> String
381
+ end
382
+
383
+ class Float
384
+ # Returns a JSON string representation for this Float number.
385
+ #
386
+ def to_json: (?JSON::State state) -> String
387
+ end
388
+
389
+ class Hash[unchecked out K, unchecked out V]
390
+ # Returns a JSON string containing a JSON object, that is generated from
391
+ # this Hash instance.
392
+ # _state_ is a JSON::State object, that can also be used to configure the
393
+ # produced JSON string output further.
394
+ #
395
+ def to_json: (?JSON::State state) -> String
396
+ end
397
+
398
+ class Array[unchecked out Elem]
399
+ # Returns a JSON string containing a JSON array, that is generated from
400
+ # this Array instance.
401
+ # _state_ is a JSON::State object, that can also be used to configure the
402
+ # produced JSON string output further.
403
+ #
404
+ def to_json: (?JSON::State state) -> String
405
+ end
406
+
407
+ class BigDecimal
408
+ # Import a JSON Marshalled object.
409
+ #
410
+ # method used for JSON marshalling support.
411
+ #
412
+ def self.json_create: (Hash[String, String] object) -> instance
413
+
414
+ # Marshal the object to JSON.
415
+ #
416
+ # method used for JSON marshalling support.
417
+ #
418
+ def as_json: (*untyped) -> Hash[String, String]
419
+
420
+ # return the JSON value
421
+ #
422
+ def to_json: (?JSON::State state) -> String
423
+ end
424
+
425
+ class Complex
426
+ # Deserializes JSON string by converting Real value `r`, imaginary value `i`, to
427
+ # a Complex object.
428
+ #
429
+ def self.json_create: (Hash[String, String | Numeric] object) -> instance
430
+
431
+ # Returns a hash, that will be turned into a JSON object and represent this
432
+ # object.
433
+ #
434
+ def as_json: (*untyped) -> Hash[String, String | Numeric]
435
+
436
+ # Stores class name (Complex) along with real value `r` and imaginary value `i`
437
+ # as JSON string
438
+ #
439
+ def to_json: (?JSON::State state) -> String
440
+ end
441
+
442
+ class Date
443
+ # Deserializes JSON string by converting Julian year `y`, month `m`, day `d` and
444
+ # Day of Calendar Reform `sg` to Date.
445
+ #
446
+ def self.json_create: (Hash[String, String | Integer | Float] object) -> instance
447
+
448
+ # Returns a hash, that will be turned into a JSON object and represent this
449
+ # object.
450
+ #
451
+ def as_json: (*untyped) -> Hash[String, String | Integer | Float]
452
+
453
+ # Stores class name (Date) with Julian year `y`, month `m`, day `d` and Day of
454
+ # Calendar Reform `sg` as JSON string
455
+ #
456
+ def to_json: (?JSON::State state) -> String
457
+ end
458
+
459
+ class DateTime
460
+ # Deserializes JSON string by converting year `y`, month `m`, day `d`, hour `H`,
461
+ # minute `M`, second `S`, offset `of` and Day of Calendar Reform `sg` to
462
+ # DateTime.
463
+ #
464
+ def self.json_create: (Hash[String, String | Integer | Float] object) -> instance
465
+
466
+ # Returns a hash, that will be turned into a JSON object and represent this
467
+ # object.
468
+ #
469
+ def as_json: (*untyped) -> Hash[String, String | Integer | Float]
470
+
471
+ # Stores class name (DateTime) with Julian year `y`, month `m`, day `d`, hour
472
+ # `H`, minute `M`, second `S`, offset `of` and Day of Calendar Reform `sg` as
473
+ # JSON string
474
+ #
475
+ def to_json: (?JSON::State state) -> String
476
+ end
477
+
478
+ class Exception
479
+ # Deserializes JSON string by constructing new Exception object with message `m`
480
+ # and backtrace `b` serialized with `to_json`
481
+ #
482
+ def self.json_create: (Hash[String, String | Array[String] | nil] object) -> instance
483
+
484
+ # Returns a hash, that will be turned into a JSON object and represent this
485
+ # object.
486
+ #
487
+ def as_json: (*untyped) -> Hash[String, String | Array[String] | nil]
488
+
489
+ # Stores class name (Exception) with message `m` and backtrace array `b` as JSON
490
+ # string
491
+ #
492
+ def to_json: (?JSON::State state) -> String
493
+ end
494
+
495
+ class OpenStruct
496
+ # Deserializes JSON string by constructing new Struct object with values `t`
497
+ # serialized by `to_json`.
498
+ #
499
+ def self.json_create: (Hash[String, String | Hash[Symbol, untyped]] object) -> instance
500
+
501
+ # Returns a hash, that will be turned into a JSON object and represent this
502
+ # object.
503
+ #
504
+ def as_json: (*untyped) -> Hash[String, String | Hash[Symbol, untyped]]
505
+
506
+ # Stores class name (OpenStruct) with this struct's values `t` as a JSON string.
507
+ #
508
+ def to_json: (?JSON::State state) -> String
509
+ end
510
+
511
+ class Range[out Elem]
512
+ # Deserializes JSON string by constructing new Range object with arguments `a`
513
+ # serialized by `to_json`.
514
+ #
515
+ def self.json_create: (Hash[String, String | [Elem, Elem, bool]] object) -> instance
516
+
517
+ # Returns a hash, that will be turned into a JSON object and represent this
518
+ # object.
519
+ #
520
+ def as_json: (*untyped) -> Hash[String, String | [Elem, Elem, bool]]
521
+
522
+ # Stores class name (Range) with JSON array of arguments `a` which include
523
+ # `first` (integer), `last` (integer), and `exclude_end?` (boolean) as JSON
524
+ # string.
525
+ #
526
+ def to_json: (?JSON::State state) -> String
527
+ end
528
+
529
+ class Rational
530
+ # Deserializes JSON string by converting numerator value `n`, denominator value
531
+ # `d`, to a Rational object.
532
+ #
533
+ def self.json_create: (Hash[String, String | Integer] object) -> instance
534
+
535
+ # Returns a hash, that will be turned into a JSON object and represent this
536
+ # object.
537
+ #
538
+ def as_json: (*untyped) -> Hash[String, String | Integer]
539
+
540
+ # Stores class name (Rational) along with numerator value `n` and denominator
541
+ # value `d` as JSON string
542
+ #
543
+ def to_json: (?JSON::State state) -> String
544
+ end
545
+
546
+ class Regexp
547
+ # Deserializes JSON string by constructing new Regexp object with source `s`
548
+ # (Regexp or String) and options `o` serialized by `to_json`
549
+ #
550
+ def self.json_create: (Hash[String, String | Integer] object) -> instance
551
+
552
+ # Returns a hash, that will be turned into a JSON object and represent this
553
+ # object.
554
+ #
555
+ def as_json: (*untyped) -> Hash[String, String | Integer]
556
+
557
+ # Stores class name (Regexp) with options `o` and source `s` (Regexp or String)
558
+ # as JSON string
559
+ #
560
+ def to_json: (?JSON::State state) -> String
561
+ end
562
+
563
+ class Set[A]
564
+ # Import a JSON Marshalled object.
565
+ #
566
+ # method used for JSON marshalling support.
567
+ #
568
+ def self.json_create: (Hash[String, String | Array[A]] object) -> instance
569
+
570
+ # Marshal the object to JSON.
571
+ #
572
+ # method used for JSON marshalling support.
573
+ #
574
+ def as_json: (*untyped) -> Hash[String, String | Array[A]]
575
+
576
+ # return the JSON value
577
+ #
578
+ def to_json: (?JSON::State state) -> String
579
+ end
580
+
581
+ class Struct[Elem]
582
+ # Deserializes JSON string by constructing new Struct object with values `v`
583
+ # serialized by `to_json`.
584
+ #
585
+ def self.json_create: (Hash[String, String | Array[Elem]] object) -> instance
586
+
587
+ # Returns a hash, that will be turned into a JSON object and represent this
588
+ # object.
589
+ #
590
+ def as_json: (*untyped) -> Hash[String, String | Array[Elem]]
591
+
592
+ # Stores class name (Struct) with Struct values `v` as a JSON string. Only named
593
+ # structs are supported.
594
+ #
595
+ def to_json: (?JSON::State state) -> String
596
+ end
597
+
598
+ class Symbol
599
+ # Deserializes JSON string by converting the `string` value stored in the object
600
+ # to a Symbol
601
+ #
602
+ def self.json_create: (Hash[String, String] object) -> instance
603
+
604
+ # Returns a hash, that will be turned into a JSON object and represent this
605
+ # object.
606
+ #
607
+ def as_json: (*untyped) -> Hash[String, String]
608
+
609
+ # Stores class name (Symbol) with String representation of Symbol as a JSON
610
+ # string.
611
+ #
612
+ def to_json: (?JSON::State state) -> String
613
+ end
614
+
615
+ class Time
616
+ # Deserializes JSON string by converting time since epoch to Time
617
+ #
618
+ def self.json_create: (Hash[String, String | Integer] object) -> instance
619
+
620
+ # Returns a hash, that will be turned into a JSON object and represent this
621
+ # object.
622
+ #
623
+ def as_json: (*untyped) -> Hash[String, String | Integer]
624
+
625
+ # Stores class name (Time) with number of seconds since epoch and number of
626
+ # microseconds for Time as JSON string
627
+ #
628
+ def to_json: (?JSON::State state) -> String
629
+ end
@@ -240,7 +240,8 @@ class Pathname
240
240
  # relative to the right argument. Or it will return `nil` if the arguments are
241
241
  # not comparable.
242
242
  #
243
- def <=>: (untyped other) -> Integer?
243
+ def <=>: (Pathname other) -> Integer
244
+ | (untyped other) -> nil
244
245
 
245
246
  # Compare this pathname with `other`. The comparison is string-based. Be aware
246
247
  # that two different paths (`foo.txt` and `./foo.txt`) can refer to the same
data/stdlib/set/0/set.rbs CHANGED
@@ -299,3 +299,10 @@ class Set[A]
299
299
 
300
300
  include Enumerable[A]
301
301
  end
302
+
303
+ module Enumerable[unchecked out Elem]
304
+ # Makes a set from the enumerable object with given arguments.
305
+ # Needs to `require "set"` to use this method.
306
+ #
307
+ def to_set: () -> Set[Elem]
308
+ end
@@ -0,0 +1,57 @@
1
+ # Timeout long-running blocks
2
+ #
3
+ # ## Synopsis
4
+ #
5
+ # require 'timeout'
6
+ # status = Timeout::timeout(5) {
7
+ # # Something that should be interrupted if it takes more than 5 seconds...
8
+ # }
9
+ #
10
+ # ## Description
11
+ #
12
+ # Timeout provides a way to auto-terminate a potentially long-running operation
13
+ # if it hasn't finished in a fixed amount of time.
14
+ #
15
+ # Previous versions didn't use a module for namespacing, however #timeout is
16
+ # provided for backwards compatibility. You should prefer Timeout.timeout
17
+ # instead.
18
+ #
19
+ # ## Copyright
20
+ #
21
+ # Copyright
22
+ # : (C) 2000 Network Applied Communication Laboratory, Inc.
23
+ # Copyright
24
+ # : (C) 2000 Information-technology Promotion Agency, Japan
25
+ #
26
+ module Timeout
27
+ # Perform an operation in a block, raising an error if it takes longer than
28
+ # `sec` seconds to complete.
29
+ #
30
+ # `sec`
31
+ # : Number of seconds to wait for the block to terminate. Any number may be
32
+ # used, including Floats to specify fractional seconds. A value of 0 or
33
+ # `nil` will execute the block without any timeout.
34
+ # `klass`
35
+ # : Exception Class to raise if the block fails to terminate in `sec` seconds.
36
+ # Omitting will use the default, Timeout::Error
37
+ # `message`
38
+ # : Error message to raise with Exception Class. Omitting will use the
39
+ # default, "execution expired"
40
+ #
41
+ #
42
+ # Returns the result of the block **if** the block completed before `sec`
43
+ # seconds, otherwise throws an exception, based on the value of `klass`.
44
+ #
45
+ # The exception thrown to terminate the given block cannot be rescued inside the
46
+ # block unless `klass` is given explicitly. However, the block can use ensure to
47
+ # prevent the handling of the exception. For that reason, this method cannot be
48
+ # relied on to enforce timeouts for untrusted blocks.
49
+ #
50
+ # Note that this is both a method of module Timeout, so you can `include
51
+ # Timeout` into your classes so they have a #timeout method, as well as a module
52
+ # method, so you can call it directly as Timeout.timeout().
53
+ #
54
+ def self?.timeout: [T] (Numeric? sec, ?singleton(Exception) klass, ?String message) { (Numeric sec) -> T } -> T
55
+ end
56
+
57
+ Timeout::VERSION: String
@@ -1,9 +1,146 @@
1
- # Class that parses String's into URI's.
2
- #
3
- # It contains a Hash set of patterns and Regexp's that match and validate.
4
- class URI::RFC2396_Parser
5
- end
1
+ module URI
2
+ # Includes URI::REGEXP::PATTERN
3
+ #
4
+ module RFC2396_REGEXP
5
+ end
6
+
7
+ # Class that parses String's into URI's.
8
+ #
9
+ # It contains a Hash set of patterns and Regexp's that match and validate.
10
+ #
11
+ class RFC2396_Parser
12
+ include RFC2396_REGEXP
13
+
14
+ # The Hash of patterns.
15
+ #
16
+ # See also URI::Parser.initialize_pattern.
17
+ #
18
+ attr_reader pattern: Hash[Symbol, String]
19
+
20
+ # The Hash of Regexp.
21
+ #
22
+ # See also URI::Parser.initialize_regexp.
23
+ #
24
+ attr_reader regexp: Hash[Symbol, Regexp]
25
+
26
+ # == Synopsis
27
+ #
28
+ # URI::Parser.new([opts])
29
+ #
30
+ # == Args
31
+ #
32
+ # The constructor accepts a hash as options for parser.
33
+ # Keys of options are pattern names of URI components
34
+ # and values of options are pattern strings.
35
+ # The constructor generates set of regexps for parsing URIs.
36
+ #
37
+ # You can use the following keys:
38
+ #
39
+ # * :ESCAPED (URI::PATTERN::ESCAPED in default)
40
+ # * :UNRESERVED (URI::PATTERN::UNRESERVED in default)
41
+ # * :DOMLABEL (URI::PATTERN::DOMLABEL in default)
42
+ # * :TOPLABEL (URI::PATTERN::TOPLABEL in default)
43
+ # * :HOSTNAME (URI::PATTERN::HOSTNAME in default)
44
+ #
45
+ # == Examples
46
+ #
47
+ # p = URI::Parser.new(:ESCAPED => "(?:%[a-fA-F0-9]{2}|%u[a-fA-F0-9]{4})")
48
+ # u = p.parse("http://example.jp/%uABCD") #=> #<URI::HTTP http://example.jp/%uABCD>
49
+ # URI.parse(u.to_s) #=> raises URI::InvalidURIError
50
+ #
51
+ # s = "http://example.com/ABCD"
52
+ # u1 = p.parse(s) #=> #<URI::HTTP http://example.com/ABCD>
53
+ # u2 = URI.parse(s) #=> #<URI::HTTP http://example.com/ABCD>
54
+ # u1 == u2 #=> true
55
+ # u1.eql?(u2) #=> false
56
+ #
57
+ def initialize: (?Hash[Symbol, String] opts) -> void
58
+
59
+ # ## Args
60
+ #
61
+ # `str`
62
+ # : String to make safe
63
+ # `unsafe`
64
+ # : Regexp to apply. Defaults to [self.regexp](:UNSAFE)
65
+ #
66
+ #
67
+ # ## Description
68
+ #
69
+ # Constructs a safe String from `str`, removing unsafe characters, replacing
70
+ # them with codes.
71
+ #
72
+ def escape: (String str, ?Regexp unsafe) -> String
73
+
74
+ # ## Args
75
+ #
76
+ # `str`
77
+ # : String to search
78
+ # `schemes`
79
+ # : Patterns to apply to `str`
80
+ #
81
+ #
82
+ # ## Description
83
+ #
84
+ # Attempts to parse and merge a set of URIs. If no `block` given, then returns
85
+ # the result, else it calls `block` for each element in result.
86
+ #
87
+ # See also URI::Parser.make_regexp.
88
+ #
89
+ def extract: (String str, ?Array[String] schemes) -> Array[String]
90
+ | (String str, ?Array[String] schemes) { (String) -> untyped } -> nil
91
+
92
+ # ## Args
93
+ #
94
+ # `uris`
95
+ # : an Array of Strings
96
+ #
97
+ #
98
+ # ## Description
99
+ #
100
+ # Attempts to parse and merge a set of URIs.
101
+ #
102
+ def join: (*String uris) -> URI::Generic
103
+
104
+ # Returns Regexp that is default [self.regexp](:ABS_URI_REF), unless `schemes`
105
+ # is provided. Then it is a Regexp.union with [self.pattern](:X_ABS_URI).
106
+ #
107
+ def make_regexp: (?Array[String] schemes) -> Regexp
108
+
109
+ # ## Args
110
+ #
111
+ # `uri`
112
+ # : String
113
+ #
114
+ #
115
+ # ## Description
116
+ #
117
+ # Parses `uri` and constructs either matching URI scheme object (File, FTP,
118
+ # HTTP, HTTPS, LDAP, LDAPS, or MailTo) or URI::Generic.
119
+ #
120
+ # ## Usage
121
+ #
122
+ # p = URI::Parser.new
123
+ # p.parse("ldap://ldap.example.com/dc=example?user=john")
124
+ # #=> #<URI::LDAP ldap://ldap.example.com/dc=example?user=john>
125
+ #
126
+ def parse: (String uri) -> URI::Generic
127
+
128
+ # Returns a split URI against [regexp](:ABS_URI).
129
+ #
130
+ def split: (String uri) -> [ String?, String?, String?, String?, String?, String?, String?, String?, String? ]
6
131
 
7
- # Includes URI::REGEXP::PATTERN
8
- module URI::RFC2396_REGEXP
132
+ # ## Args
133
+ #
134
+ # `str`
135
+ # : String to remove escapes from
136
+ # `escaped`
137
+ # : Regexp to apply. Defaults to [self.regexp](:ESCAPED)
138
+ #
139
+ #
140
+ # ## Description
141
+ #
142
+ # Removes escapes from `str`.
143
+ #
144
+ def unescape: (String str, ?Regexp escaped) -> String
145
+ end
9
146
  end
data/steep/Gemfile.lock CHANGED
@@ -1,42 +1,40 @@
1
1
  GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (6.1.0)
4
+ activesupport (6.1.2.1)
5
5
  concurrent-ruby (~> 1.0, >= 1.0.2)
6
6
  i18n (>= 1.6, < 2)
7
7
  minitest (>= 5.1)
8
8
  tzinfo (~> 2.0)
9
9
  zeitwerk (~> 2.3)
10
- ast (2.4.1)
11
- ast_utils (0.3.0)
12
- parser (~> 2.4)
13
- thor (>= 0.19)
14
- concurrent-ruby (1.1.7)
15
- ffi (1.13.1)
16
- i18n (1.8.5)
10
+ ast (2.4.2)
11
+ ast_utils (0.4.0)
12
+ parser (>= 2.7.0)
13
+ concurrent-ruby (1.1.8)
14
+ ffi (1.14.2)
15
+ i18n (1.8.8)
17
16
  concurrent-ruby (~> 1.0)
18
17
  language_server-protocol (3.15.0.1)
19
- listen (3.3.3)
18
+ listen (3.4.1)
20
19
  rb-fsevent (~> 0.10, >= 0.10.3)
21
20
  rb-inotify (~> 0.9, >= 0.9.10)
22
- minitest (5.14.2)
23
- parser (2.7.2.0)
21
+ minitest (5.14.3)
22
+ parser (3.0.0.0)
24
23
  ast (~> 2.4.1)
25
24
  rainbow (3.0.0)
26
25
  rb-fsevent (0.10.4)
27
26
  rb-inotify (0.10.1)
28
27
  ffi (~> 1.0)
29
- rbs (0.20.1)
30
- steep (0.38.0)
28
+ rbs (1.0.4)
29
+ steep (0.41.0)
31
30
  activesupport (>= 5.1)
32
- ast_utils (~> 0.3.0)
31
+ ast_utils (>= 0.4.0)
33
32
  language_server-protocol (~> 3.15.0.1)
34
33
  listen (~> 3.0)
35
- parser (~> 2.7.0)
34
+ parser (>= 2.7)
36
35
  rainbow (>= 2.2.2, < 4.0)
37
- rbs (>= 0.20.0)
38
- thor (1.0.1)
39
- tzinfo (2.0.3)
36
+ rbs (~> 1.0.3)
37
+ tzinfo (2.0.4)
40
38
  concurrent-ruby (~> 1.0)
41
39
  zeitwerk (2.4.2)
42
40
 
@@ -47,4 +45,4 @@ DEPENDENCIES
47
45
  steep
48
46
 
49
47
  BUNDLED WITH
50
- 2.2.0.rc.2
48
+ 2.2.3
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.0.1
4
+ version: 1.0.6
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-01-27 00:00:00.000000000 Z
11
+ date: 2021-02-16 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.
@@ -224,6 +224,7 @@ files:
224
224
  - stdlib/set/0/set.rbs
225
225
  - stdlib/singleton/0/singleton.rbs
226
226
  - stdlib/time/0/time.rbs
227
+ - stdlib/timeout/0/timeout.rbs
227
228
  - stdlib/tmpdir/0/tmpdir.rbs
228
229
  - stdlib/tsort/0/cyclic.rbs
229
230
  - stdlib/tsort/0/interfaces.rbs