rbs 4.1.0.pre.1 → 4.1.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/.dockerignore +37 -0
- data/.github/workflows/bundle-update.yml +1 -1
- data/.github/workflows/c-check.yml +14 -6
- data/.github/workflows/comments.yml +2 -2
- data/.github/workflows/dependabot.yml +2 -2
- data/.github/workflows/jruby.yml +79 -0
- data/.github/workflows/milestone.yml +13 -2
- data/.github/workflows/ruby.yml +16 -4
- data/.github/workflows/rust.yml +13 -8
- data/.github/workflows/truffleruby.yml +54 -0
- data/.github/workflows/typecheck.yml +5 -2
- data/.github/workflows/wasm.yml +55 -0
- data/.github/workflows/windows.yml +8 -2
- data/.gitignore +8 -0
- data/CHANGELOG.md +88 -0
- data/Dockerfile.jruby +53 -0
- data/README.md +3 -3
- data/Rakefile +103 -1
- data/Steepfile +9 -0
- data/core/array.rbs +243 -180
- data/core/builtin.rbs +6 -6
- data/core/enumerable.rbs +109 -109
- data/core/enumerator/product.rbs +5 -5
- data/core/enumerator.rbs +28 -28
- data/core/file.rbs +24 -1018
- data/core/file_constants.rbs +463 -0
- data/core/file_stat.rbs +534 -0
- data/core/float.rbs +0 -24
- data/core/hash.rbs +117 -101
- data/core/integer.rbs +21 -58
- data/core/io.rbs +25 -7
- data/core/match_data.rbs +1 -1
- data/core/module.rbs +88 -74
- data/core/numeric.rbs +3 -0
- data/core/object_space/weak_key_map.rbs +7 -7
- data/core/pathname.rbs +0 -10
- data/core/ractor.rbs +0 -10
- data/core/range.rbs +23 -23
- data/core/rbs/ops.rbs +154 -0
- data/core/rbs/unnamed/argf.rbs +3 -3
- data/core/rubygems/errors.rbs +4 -1
- data/core/rubygems/requirement.rbs +0 -10
- data/core/rubygems/rubygems.rbs +4 -1
- data/core/rubygems/specification.rbs +8 -0
- data/core/rubygems/version.rbs +0 -160
- data/core/set.rbs +3 -3
- data/core/struct.rbs +16 -16
- data/core/thread.rbs +9 -14
- data/docs/CONTRIBUTING.md +2 -1
- data/docs/inline.md +36 -6
- data/docs/rbs_by_example.md +20 -20
- data/docs/release.md +69 -0
- data/docs/syntax.md +2 -2
- data/docs/wasm_serialization.md +80 -0
- data/ext/rbs_extension/ast_translation.c +1294 -973
- data/ext/rbs_extension/ast_translation.h +4 -0
- data/ext/rbs_extension/legacy_location.c +11 -6
- data/ext/rbs_extension/main.c +139 -4
- data/include/rbs/ast.h +9 -1
- data/include/rbs/serialize.h +39 -0
- data/lib/rbs/ast/ruby/comment_block.rb +6 -4
- data/lib/rbs/ast/ruby/helpers/location_helper.rb +1 -1
- data/lib/rbs/ast/ruby/members.rb +12 -1
- data/lib/rbs/buffer.rb +48 -11
- data/lib/rbs/collection/sources/git.rb +6 -0
- data/lib/rbs/definition_builder/method_builder.rb +12 -6
- data/lib/rbs/environment.rb +4 -3
- data/lib/rbs/inline_parser.rb +5 -3
- data/lib/rbs/namespace.rb +47 -11
- data/lib/rbs/parser_aux.rb +4 -2
- data/lib/rbs/prototype/rbi.rb +193 -25
- data/lib/rbs/prototype/runtime.rb +2 -0
- data/lib/rbs/resolver/type_name_resolver.rb +12 -14
- data/lib/rbs/type_name.rb +33 -13
- data/lib/rbs/unit_test/type_assertions.rb +9 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/wasm/deserializer.rb +213 -0
- data/lib/rbs/wasm/location.rb +61 -0
- data/lib/rbs/wasm/parser.rb +137 -0
- data/lib/rbs/wasm/runtime.rb +196 -0
- data/lib/rbs/wasm/serialization_schema.rb +110 -0
- data/lib/rbs.rb +13 -2
- data/lib/rbs_jars.rb +39 -0
- data/lib/rdoc_plugin/parser.rb +5 -0
- data/rbs.gemspec +32 -2
- data/sig/ast/ruby/members.rbs +6 -1
- data/sig/buffer.rbs +19 -1
- data/sig/namespace.rbs +20 -0
- data/sig/parser.rbs +10 -0
- data/sig/prototype/rbi.rbs +33 -4
- data/sig/resolver/type_name_resolver.rbs +2 -4
- data/sig/typename.rbs +15 -0
- data/sig/unit_test/type_assertions.rbs +4 -0
- data/sig/wasm/deserializer.rbs +66 -0
- data/sig/wasm/serialization_schema.rbs +13 -0
- data/src/ast.c +78 -78
- data/src/lexer.c +97 -93
- data/src/lexer.re +1 -1
- data/src/lexstate.c +9 -1
- data/src/serialize.c +958 -0
- data/src/util/rbs_allocator.c +14 -8
- data/stdlib/abbrev/0/array.rbs +1 -1
- data/stdlib/csv/0/csv.rbs +5 -5
- data/stdlib/delegate/0/delegator.rbs +2 -1
- data/stdlib/digest/0/digest.rbs +11 -5
- data/stdlib/erb/0/erb.rbs +1 -1
- data/stdlib/etc/0/etc.rbs +18 -4
- data/stdlib/fileutils/0/fileutils.rbs +21 -21
- data/stdlib/ipaddr/0/ipaddr.rbs +0 -5
- data/stdlib/json/0/json.rbs +6 -6
- data/stdlib/monitor/0/monitor.rbs +2 -2
- data/stdlib/openssl/0/openssl.rbs +44 -38
- data/stdlib/resolv/0/resolv.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +32 -10
- data/stdlib/strscan/0/string_scanner.rbs +74 -55
- data/stdlib/tempfile/0/manifest.yaml +3 -0
- data/stdlib/timeout/0/timeout.rbs +0 -5
- data/stdlib/tsort/0/cyclic.rbs +1 -1
- data/stdlib/tsort/0/interfaces.rbs +8 -8
- data/stdlib/tsort/0/tsort.rbs +9 -9
- data/stdlib/uri/0/generic.rbs +0 -5
- data/stdlib/zlib/0/gzip_reader.rbs +2 -2
- data/stdlib/zlib/0/zstream.rbs +0 -1
- data/wasm/README.md +60 -0
- data/wasm/rbs_wasm.c +423 -0
- metadata +26 -5
- data/.vscode/extensions.json +0 -5
- data/.vscode/settings.json +0 -19
data/core/range.rbs
CHANGED
|
@@ -235,8 +235,8 @@
|
|
|
235
235
|
#
|
|
236
236
|
# require 'json/add/range'
|
|
237
237
|
#
|
|
238
|
-
class Range[out
|
|
239
|
-
include Enumerable[
|
|
238
|
+
class Range[out E] < Object
|
|
239
|
+
include Enumerable[E]
|
|
240
240
|
|
|
241
241
|
# <!--
|
|
242
242
|
# rdoc-file=range.c
|
|
@@ -260,8 +260,8 @@ class Range[out Elem] < Object
|
|
|
260
260
|
# (0..7) % 2 #=> ((0..7).%(2)) -- as expected
|
|
261
261
|
# 0..7 % 2 #=> 0..1 -- parsed as 0..(7 % 2)
|
|
262
262
|
#
|
|
263
|
-
def %: (Numeric | int n) -> Enumerator[
|
|
264
|
-
| (Numeric | int n) { (
|
|
263
|
+
def %: (Numeric | int n) -> Enumerator[E, self]
|
|
264
|
+
| (Numeric | int n) { (E element) -> void } -> self
|
|
265
265
|
|
|
266
266
|
# <!--
|
|
267
267
|
# rdoc-file=range.c
|
|
@@ -345,7 +345,7 @@ class Range[out Elem] < Object
|
|
|
345
345
|
#
|
|
346
346
|
# Related: Range#first, Range#end.
|
|
347
347
|
#
|
|
348
|
-
def begin: () ->
|
|
348
|
+
def begin: () -> E
|
|
349
349
|
|
|
350
350
|
# <!--
|
|
351
351
|
# rdoc-file=range.c
|
|
@@ -355,9 +355,9 @@ class Range[out Elem] < Object
|
|
|
355
355
|
#
|
|
356
356
|
# See [Binary Searching](rdoc-ref:language/bsearch.rdoc).
|
|
357
357
|
#
|
|
358
|
-
def bsearch: () -> ::Enumerator[
|
|
359
|
-
| () { (
|
|
360
|
-
| () { (
|
|
358
|
+
def bsearch: () -> ::Enumerator[E, E?]
|
|
359
|
+
| () { (E) -> (true | false) } -> E?
|
|
360
|
+
| () { (E) -> ::Integer } -> E?
|
|
361
361
|
|
|
362
362
|
# <!--
|
|
363
363
|
# rdoc-file=range.c
|
|
@@ -500,8 +500,8 @@ class Range[out Elem] < Object
|
|
|
500
500
|
#
|
|
501
501
|
# With no block given, returns an enumerator.
|
|
502
502
|
#
|
|
503
|
-
def each: () { (
|
|
504
|
-
| () -> ::Enumerator[
|
|
503
|
+
def each: () { (E arg0) -> untyped } -> self
|
|
504
|
+
| () -> ::Enumerator[E, self]
|
|
505
505
|
|
|
506
506
|
# <!--
|
|
507
507
|
# rdoc-file=range.c
|
|
@@ -515,7 +515,7 @@ class Range[out Elem] < Object
|
|
|
515
515
|
#
|
|
516
516
|
# Related: Range#begin, Range#last.
|
|
517
517
|
#
|
|
518
|
-
def end: () ->
|
|
518
|
+
def end: () -> E
|
|
519
519
|
|
|
520
520
|
# <!--
|
|
521
521
|
# rdoc-file=range.c
|
|
@@ -551,8 +551,8 @@ class Range[out Elem] < Object
|
|
|
551
551
|
#
|
|
552
552
|
# (..4).first # Raises RangeError
|
|
553
553
|
#
|
|
554
|
-
def first: () ->
|
|
555
|
-
| (Integer n) -> ::Array[
|
|
554
|
+
def first: () -> E
|
|
555
|
+
| (Integer n) -> ::Array[E]
|
|
556
556
|
|
|
557
557
|
# <!--
|
|
558
558
|
# rdoc-file=range.c
|
|
@@ -605,7 +605,7 @@ class Range[out Elem] < Object
|
|
|
605
605
|
# Range.new('a', 'd').to_a # => ["a", "b", "c", "d"]
|
|
606
606
|
# Range.new('a', 'd', true).to_a # => ["a", "b", "c"]
|
|
607
607
|
#
|
|
608
|
-
def initialize: (
|
|
608
|
+
def initialize: (E from, E to, ?boolish exclude_end) -> void
|
|
609
609
|
|
|
610
610
|
# <!--
|
|
611
611
|
# rdoc-file=range.c
|
|
@@ -661,8 +661,8 @@ class Range[out Elem] < Object
|
|
|
661
661
|
#
|
|
662
662
|
# (1..).last # Raises RangeError
|
|
663
663
|
#
|
|
664
|
-
def last: () ->
|
|
665
|
-
| (Integer n) -> ::Array[
|
|
664
|
+
def last: () -> E
|
|
665
|
+
| (Integer n) -> ::Array[E]
|
|
666
666
|
|
|
667
667
|
# <!--
|
|
668
668
|
# rdoc-file=range.c
|
|
@@ -958,8 +958,8 @@ class Range[out Elem] < Object
|
|
|
958
958
|
#
|
|
959
959
|
# With no block given, returns an enumerator.
|
|
960
960
|
#
|
|
961
|
-
def reverse_each: () { (
|
|
962
|
-
| () -> ::Enumerator[
|
|
961
|
+
def reverse_each: () { (E) -> void } -> self
|
|
962
|
+
| () -> ::Enumerator[E, self]
|
|
963
963
|
|
|
964
964
|
# <!--
|
|
965
965
|
# rdoc-file=range.c
|
|
@@ -1016,7 +1016,7 @@ class Range[out Elem] < Object
|
|
|
1016
1016
|
#
|
|
1017
1017
|
def count: () -> (Integer | Float)
|
|
1018
1018
|
| (untyped) -> Integer
|
|
1019
|
-
| () { (
|
|
1019
|
+
| () { (E) -> boolish } -> Integer
|
|
1020
1020
|
|
|
1021
1021
|
# <!--
|
|
1022
1022
|
# rdoc-file=range.c
|
|
@@ -1096,10 +1096,10 @@ class Range[out Elem] < Object
|
|
|
1096
1096
|
# ('a'..'e').step { p _1 }
|
|
1097
1097
|
# # Default step 1; prints: a, b, c, d, e
|
|
1098
1098
|
#
|
|
1099
|
-
def step: (?Numeric | int) -> Enumerator[
|
|
1100
|
-
| (?Numeric | int) { (
|
|
1101
|
-
| (untyped) -> Enumerator[
|
|
1102
|
-
| (untyped) { (
|
|
1099
|
+
def step: (?Numeric | int) -> Enumerator[E, self]
|
|
1100
|
+
| (?Numeric | int) { (E element) -> void } -> self
|
|
1101
|
+
| (untyped) -> Enumerator[E, self]
|
|
1102
|
+
| (untyped) { (E element) -> void } -> self
|
|
1103
1103
|
|
|
1104
1104
|
# <!--
|
|
1105
1105
|
# rdoc-file=range.c
|
data/core/rbs/ops.rbs
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
module RBS
|
|
2
|
+
module Ops
|
|
3
|
+
# An interface for types implementing the `+` operator
|
|
4
|
+
interface _Add[O, R]
|
|
5
|
+
# Perform the `+` operation
|
|
6
|
+
def +: (O other) -> R
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
# An interface for types implementing the `-` operator
|
|
10
|
+
interface _Subtract[O, R]
|
|
11
|
+
# Perform the `-` operation
|
|
12
|
+
def -: (O other) -> R
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# An interface for types implementing the `*` operator
|
|
16
|
+
interface _Times[O, R]
|
|
17
|
+
# Perform the `*` operation
|
|
18
|
+
def *: (O other) -> R
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# An interface for types implementing the `/` operator
|
|
22
|
+
interface _Divide[O, R]
|
|
23
|
+
# Perform the `/` operation
|
|
24
|
+
def /: (O other) -> R
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# An interface for types implementing the `%` operator
|
|
28
|
+
interface _Modulo[O, R]
|
|
29
|
+
# Perform the `%` operation
|
|
30
|
+
def %: (O other) -> R
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
# An interface for types implementing the `**` operator
|
|
34
|
+
interface _Power[O, R]
|
|
35
|
+
# Perform the `**` operation
|
|
36
|
+
def **: (O other) -> R
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# An interface for types implementing the `<` operator
|
|
40
|
+
interface _LessThan[O, R = bool]
|
|
41
|
+
# Perform the `<` operation
|
|
42
|
+
def <: (O other) -> R
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# An interface for types implementing the `>` operator
|
|
46
|
+
interface _GreaterThan[O, R = bool]
|
|
47
|
+
# Perform the `>` operation
|
|
48
|
+
def >: (O other) -> R
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# An interface for types implementing the `<=` operator
|
|
52
|
+
interface _LessThanOrEqual[O, R = bool]
|
|
53
|
+
# Perform the `<=` operation
|
|
54
|
+
def <=: (O other) -> R
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# An interface for types implementing the `>=` operator
|
|
58
|
+
interface _GreaterThanOrEqual[O, R = bool]
|
|
59
|
+
# Perform the `>=` operation
|
|
60
|
+
def >=: (O other) -> R
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# An interface for types implementing the `<=>` operator
|
|
64
|
+
interface _Compare[O = untyped, R = (-1 | 0 | 1)?]
|
|
65
|
+
# Perform the `<=>` operation
|
|
66
|
+
def <=>: (O other) -> R
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# An interface for types implementing the `&` operator
|
|
70
|
+
interface _And[O, R]
|
|
71
|
+
# Perform the `&` operation
|
|
72
|
+
def &: (O other) -> R
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# An interface for types implementing the `|` operator
|
|
76
|
+
interface _Or[O, R]
|
|
77
|
+
# Perform the `|` operation
|
|
78
|
+
def |: (O other) -> R
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# An interface for types implementing the `^` operator
|
|
82
|
+
interface _Xor[O, R]
|
|
83
|
+
# Perform the `^` operation
|
|
84
|
+
def ^: (O other) -> R
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
# An interface for types implementing the `<<` operator
|
|
88
|
+
interface _LeftShift[O, R]
|
|
89
|
+
# Perform the `<<` operation
|
|
90
|
+
def <<: (O other) -> R
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# An interface for types implementing the `>>` operator
|
|
94
|
+
interface _RightShift[O, R]
|
|
95
|
+
# Perform the `>>` operation
|
|
96
|
+
def >>: (O other) -> R
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# An interface for types implementing the `~` operator
|
|
100
|
+
interface _Not[R]
|
|
101
|
+
# Perform the `~` operation
|
|
102
|
+
def ~: () -> R
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# An interface for types implementing the `+@` operator
|
|
106
|
+
interface _UnaryPos[R]
|
|
107
|
+
# Perform the `+@` operation
|
|
108
|
+
def +@: () -> R
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# An interface for types implementing the `-@` operator
|
|
112
|
+
interface _UnaryNeg[R]
|
|
113
|
+
# Perform the `-@` operation
|
|
114
|
+
def -@: () -> R
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# An interface for types implementing the `!` operator
|
|
118
|
+
interface _LogicalNot[R = bool]
|
|
119
|
+
# Perform the `!` operation
|
|
120
|
+
def !: () -> R
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# An interface for types implementing the `==` operator
|
|
124
|
+
interface _Equal[O = untyped, R = bool]
|
|
125
|
+
# Perform the `==` operation
|
|
126
|
+
def ==: (O other) -> R
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# An interface for types implementing the `===` operator
|
|
130
|
+
interface _CaseEqual[O, R = bool]
|
|
131
|
+
# Perform the `===` operation
|
|
132
|
+
def ===: (O other) -> R
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
# An interface for types implementing the `=~` operator
|
|
136
|
+
interface _Matches[O, R]
|
|
137
|
+
# Perform the `=~` operation
|
|
138
|
+
def =~: (O other) -> R
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
# An interface for types implementing the `!=` operator
|
|
142
|
+
interface _NotEqual[O = untyped, R = bool]
|
|
143
|
+
# Perform the `!=` operation
|
|
144
|
+
def !=: (O other) -> R
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# An interface for types implementing the `!~` operator
|
|
148
|
+
interface _NotMatches[O, R = bool]
|
|
149
|
+
# Perform the `!~` operation
|
|
150
|
+
def !~: (O other) -> R
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
data/core/rbs/unnamed/argf.rbs
CHANGED
|
@@ -959,7 +959,7 @@ module RBS
|
|
|
959
959
|
# ARGF#readpartial or ARGF#read_nonblock.
|
|
960
960
|
#
|
|
961
961
|
%a{annotate:rdoc:copy:ARGF#read}
|
|
962
|
-
def read: (?int? length, ?string outbuf) -> String?
|
|
962
|
+
def read: (?int? length, ?string? outbuf) -> String?
|
|
963
963
|
|
|
964
964
|
# <!--
|
|
965
965
|
# rdoc-file=io.c
|
|
@@ -969,7 +969,7 @@ module RBS
|
|
|
969
969
|
# Reads at most *maxlen* bytes from the ARGF stream in non-blocking mode.
|
|
970
970
|
#
|
|
971
971
|
%a{annotate:rdoc:copy:ARGF#read_nonblock}
|
|
972
|
-
def read_nonblock: (int maxlen, ?string buf, **untyped options) -> String
|
|
972
|
+
def read_nonblock: (int maxlen, ?string? buf, **untyped options) -> String
|
|
973
973
|
|
|
974
974
|
# <!--
|
|
975
975
|
# rdoc-file=io.c
|
|
@@ -1070,7 +1070,7 @@ module RBS
|
|
|
1070
1070
|
# last one.
|
|
1071
1071
|
#
|
|
1072
1072
|
%a{annotate:rdoc:copy:ARGF#readpartial}
|
|
1073
|
-
def readpartial: (int maxlen, ?string outbuf) -> String
|
|
1073
|
+
def readpartial: (int maxlen, ?string? outbuf) -> String
|
|
1074
1074
|
|
|
1075
1075
|
# <!--
|
|
1076
1076
|
# rdoc-file=io.c
|
data/core/rubygems/errors.rbs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
# Further RubyGems documentation can be found at:
|
|
18
18
|
#
|
|
19
19
|
# * [RubyGems Guides](https://guides.rubygems.org)
|
|
20
|
-
# * [RubyGems API](https://
|
|
20
|
+
# * [RubyGems API](https://guides.rubygems.org/rubygems-org-api/) (also
|
|
21
21
|
# available from `gem server`)
|
|
22
22
|
#
|
|
23
23
|
# ## RubyGems Plugins
|
|
@@ -90,6 +90,9 @@
|
|
|
90
90
|
#
|
|
91
91
|
# -The RubyGems Team
|
|
92
92
|
#
|
|
93
|
+
# <!-- rdoc-file=lib/rubygems/version.rb -->
|
|
94
|
+
# Workaround for directly loading Gem::Version in some cases
|
|
95
|
+
#
|
|
93
96
|
module Gem
|
|
94
97
|
# <!-- rdoc-file=lib/rubygems/errors.rb -->
|
|
95
98
|
# Raised when RubyGems is unable to load or activate a gem. Contains the name
|
|
@@ -123,18 +123,8 @@ module Gem
|
|
|
123
123
|
#
|
|
124
124
|
def satisfied_by?: (Gem::Version version) -> bool
|
|
125
125
|
|
|
126
|
-
# <!--
|
|
127
|
-
# rdoc-file=lib/rubygems/requirement.rb
|
|
128
|
-
# - ===(version)
|
|
129
|
-
# -->
|
|
130
|
-
#
|
|
131
126
|
alias === satisfied_by?
|
|
132
127
|
|
|
133
|
-
# <!--
|
|
134
|
-
# rdoc-file=lib/rubygems/requirement.rb
|
|
135
|
-
# - =~(version)
|
|
136
|
-
# -->
|
|
137
|
-
#
|
|
138
128
|
alias =~ satisfied_by?
|
|
139
129
|
|
|
140
130
|
# <!--
|
data/core/rubygems/rubygems.rbs
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
# Further RubyGems documentation can be found at:
|
|
18
18
|
#
|
|
19
19
|
# * [RubyGems Guides](https://guides.rubygems.org)
|
|
20
|
-
# * [RubyGems API](https://
|
|
20
|
+
# * [RubyGems API](https://guides.rubygems.org/rubygems-org-api/) (also
|
|
21
21
|
# available from `gem server`)
|
|
22
22
|
#
|
|
23
23
|
# ## RubyGems Plugins
|
|
@@ -90,6 +90,9 @@
|
|
|
90
90
|
#
|
|
91
91
|
# -The RubyGems Team
|
|
92
92
|
#
|
|
93
|
+
# <!-- rdoc-file=lib/rubygems/version.rb -->
|
|
94
|
+
# Workaround for directly loading Gem::Version in some cases
|
|
95
|
+
#
|
|
93
96
|
module Gem
|
|
94
97
|
interface _HashLike[K, V]
|
|
95
98
|
def each_pair: () { ([ K, V ]) -> untyped } -> self
|
|
@@ -19,5 +19,13 @@
|
|
|
19
19
|
# #metadata for restrictions on the format and size of metadata items you may
|
|
20
20
|
# add to a specification.
|
|
21
21
|
#
|
|
22
|
+
# Specifications must be deterministic, as in the example above. For instance,
|
|
23
|
+
# you cannot define attributes conditionally:
|
|
24
|
+
#
|
|
25
|
+
# # INVALID: do not do this.
|
|
26
|
+
# unless RUBY_ENGINE == "jruby"
|
|
27
|
+
# s.extensions << "ext/example/extconf.rb"
|
|
28
|
+
# end
|
|
29
|
+
#
|
|
22
30
|
class Gem::Specification < Gem::BasicSpecification
|
|
23
31
|
end
|
data/core/rubygems/version.rbs
CHANGED
|
@@ -1,165 +1,5 @@
|
|
|
1
1
|
%a{annotate:rdoc:skip}
|
|
2
2
|
module Gem
|
|
3
|
-
# <!-- rdoc-file=lib/rubygems/version.rb -->
|
|
4
|
-
# The Version class processes string versions into comparable values. A version
|
|
5
|
-
# string should normally be a series of numbers separated by periods. Each part
|
|
6
|
-
# (digits separated by periods) is considered its own number, and these are used
|
|
7
|
-
# for sorting. So for instance, 3.10 sorts higher than 3.2 because ten is
|
|
8
|
-
# greater than two.
|
|
9
|
-
#
|
|
10
|
-
# If any part contains letters (currently only a-z are supported) then that
|
|
11
|
-
# version is considered prerelease. Versions with a prerelease part in the Nth
|
|
12
|
-
# part sort less than versions with N-1 parts. Prerelease parts are sorted
|
|
13
|
-
# alphabetically using the normal Ruby string sorting rules. If a prerelease
|
|
14
|
-
# part contains both letters and numbers, it will be broken into multiple parts
|
|
15
|
-
# to provide expected sort behavior (1.0.a10 becomes 1.0.a.10, and is greater
|
|
16
|
-
# than 1.0.a9).
|
|
17
|
-
#
|
|
18
|
-
# Prereleases sort between real releases (newest to oldest):
|
|
19
|
-
#
|
|
20
|
-
# 1. 1.0
|
|
21
|
-
# 2. 1.0.b1
|
|
22
|
-
# 3. 1.0.a.2
|
|
23
|
-
# 4. 0.9
|
|
24
|
-
#
|
|
25
|
-
# If you want to specify a version restriction that includes both prereleases
|
|
26
|
-
# and regular releases of the 1.x series this is the best way:
|
|
27
|
-
#
|
|
28
|
-
# s.add_dependency 'example', '>= 1.0.0.a', '< 2.0.0'
|
|
29
|
-
#
|
|
30
|
-
# ## How Software Changes
|
|
31
|
-
#
|
|
32
|
-
# Users expect to be able to specify a version constraint that gives them some
|
|
33
|
-
# reasonable expectation that new versions of a library will work with their
|
|
34
|
-
# software if the version constraint is true, and not work with their software
|
|
35
|
-
# if the version constraint is false. In other words, the perfect system will
|
|
36
|
-
# accept all compatible versions of the library and reject all incompatible
|
|
37
|
-
# versions.
|
|
38
|
-
#
|
|
39
|
-
# Libraries change in 3 ways (well, more than 3, but stay focused here!).
|
|
40
|
-
#
|
|
41
|
-
# 1. The change may be an implementation detail only and have no effect on the
|
|
42
|
-
# client software.
|
|
43
|
-
# 2. The change may add new features, but do so in a way that client software
|
|
44
|
-
# written to an earlier version is still compatible.
|
|
45
|
-
# 3. The change may change the public interface of the library in such a way
|
|
46
|
-
# that old software is no longer compatible.
|
|
47
|
-
#
|
|
48
|
-
# Some examples are appropriate at this point. Suppose I have a Stack class
|
|
49
|
-
# that supports a `push` and a `pop` method.
|
|
50
|
-
#
|
|
51
|
-
# ### Examples of Category 1 changes:
|
|
52
|
-
#
|
|
53
|
-
# * Switch from an array based implementation to a linked-list based
|
|
54
|
-
# implementation.
|
|
55
|
-
# * Provide an automatic (and transparent) backing store for large stacks.
|
|
56
|
-
#
|
|
57
|
-
# ### Examples of Category 2 changes might be:
|
|
58
|
-
#
|
|
59
|
-
# * Add a `depth` method to return the current depth of the stack.
|
|
60
|
-
# * Add a `top` method that returns the current top of stack (without changing
|
|
61
|
-
# the stack).
|
|
62
|
-
# * Change `push` so that it returns the item pushed (previously it had no
|
|
63
|
-
# usable return value).
|
|
64
|
-
#
|
|
65
|
-
# ### Examples of Category 3 changes might be:
|
|
66
|
-
#
|
|
67
|
-
# * Changes `pop` so that it no longer returns a value (you must use `top` to
|
|
68
|
-
# get the top of the stack).
|
|
69
|
-
# * Rename the methods to `push_item` and `pop_item`.
|
|
70
|
-
#
|
|
71
|
-
# ## RubyGems Rational Versioning
|
|
72
|
-
#
|
|
73
|
-
# * Versions shall be represented by three non-negative integers, separated by
|
|
74
|
-
# periods (e.g. 3.1.4). The first integers is the "major" version number,
|
|
75
|
-
# the second integer is the "minor" version number, and the third integer is
|
|
76
|
-
# the "build" number.
|
|
77
|
-
#
|
|
78
|
-
# * A category 1 change (implementation detail) will increment the build
|
|
79
|
-
# number.
|
|
80
|
-
#
|
|
81
|
-
# * A category 2 change (backwards compatible) will increment the minor
|
|
82
|
-
# version number and reset the build number.
|
|
83
|
-
#
|
|
84
|
-
# * A category 3 change (incompatible) will increment the major build number
|
|
85
|
-
# and reset the minor and build numbers.
|
|
86
|
-
#
|
|
87
|
-
# * Any "public" release of a gem should have a different version. Normally
|
|
88
|
-
# that means incrementing the build number. This means a developer can
|
|
89
|
-
# generate builds all day long, but as soon as they make a public release,
|
|
90
|
-
# the version must be updated.
|
|
91
|
-
#
|
|
92
|
-
# ### Examples
|
|
93
|
-
#
|
|
94
|
-
# Let's work through a project lifecycle using our Stack example from above.
|
|
95
|
-
#
|
|
96
|
-
# Version 0.0.1
|
|
97
|
-
# : The initial Stack class is release.
|
|
98
|
-
#
|
|
99
|
-
# Version 0.0.2
|
|
100
|
-
# : Switched to a linked=list implementation because it is cooler.
|
|
101
|
-
#
|
|
102
|
-
# Version 0.1.0
|
|
103
|
-
# : Added a `depth` method.
|
|
104
|
-
#
|
|
105
|
-
# Version 1.0.0
|
|
106
|
-
# : Added `top` and made `pop` return nil (`pop` used to return the old top
|
|
107
|
-
# item).
|
|
108
|
-
#
|
|
109
|
-
# Version 1.1.0
|
|
110
|
-
# : `push` now returns the value pushed (it used it return nil).
|
|
111
|
-
#
|
|
112
|
-
# Version 1.1.1
|
|
113
|
-
# : Fixed a bug in the linked list implementation.
|
|
114
|
-
#
|
|
115
|
-
# Version 1.1.2
|
|
116
|
-
# : Fixed a bug introduced in the last fix.
|
|
117
|
-
#
|
|
118
|
-
#
|
|
119
|
-
# Client A needs a stack with basic push/pop capability. They write to the
|
|
120
|
-
# original interface (no `top`), so their version constraint looks like:
|
|
121
|
-
#
|
|
122
|
-
# gem 'stack', '>= 0.0'
|
|
123
|
-
#
|
|
124
|
-
# Essentially, any version is OK with Client A. An incompatible change to the
|
|
125
|
-
# library will cause them grief, but they are willing to take the chance (we
|
|
126
|
-
# call Client A optimistic).
|
|
127
|
-
#
|
|
128
|
-
# Client B is just like Client A except for two things: (1) They use the `depth`
|
|
129
|
-
# method and (2) they are worried about future incompatibilities, so they write
|
|
130
|
-
# their version constraint like this:
|
|
131
|
-
#
|
|
132
|
-
# gem 'stack', '~> 0.1'
|
|
133
|
-
#
|
|
134
|
-
# The `depth` method was introduced in version 0.1.0, so that version or
|
|
135
|
-
# anything later is fine, as long as the version stays below version 1.0 where
|
|
136
|
-
# incompatibilities are introduced. We call Client B pessimistic because they
|
|
137
|
-
# are worried about incompatible future changes (it is OK to be pessimistic!).
|
|
138
|
-
#
|
|
139
|
-
# ## Preventing Version Catastrophe:
|
|
140
|
-
#
|
|
141
|
-
# From:
|
|
142
|
-
# https://www.zenspider.com/ruby/2008/10/rubygems-how-to-preventing-catastrophe.
|
|
143
|
-
# html
|
|
144
|
-
#
|
|
145
|
-
# Let's say you're depending on the fnord gem version 2.y.z. If you specify your
|
|
146
|
-
# dependency as ">= 2.0.0" then, you're good, right? What happens if fnord 3.0
|
|
147
|
-
# comes out and it isn't backwards compatible with 2.y.z? Your stuff will break
|
|
148
|
-
# as a result of using ">=". The better route is to specify your dependency with
|
|
149
|
-
# an "approximate" version specifier ("~>"). They're a tad confusing, so here is
|
|
150
|
-
# how the dependency specifiers work:
|
|
151
|
-
#
|
|
152
|
-
# Specification From ... To (exclusive)
|
|
153
|
-
# ">= 3.0" 3.0 ... ∞
|
|
154
|
-
# "~> 3.0" 3.0 ... 4.0
|
|
155
|
-
# "~> 3.0.0" 3.0.0 ... 3.1
|
|
156
|
-
# "~> 3.5" 3.5 ... 4.0
|
|
157
|
-
# "~> 3.5.0" 3.5.0 ... 3.6
|
|
158
|
-
# "~> 3" 3.0 ... 4.0
|
|
159
|
-
#
|
|
160
|
-
# For the last example, single-digit versions are automatically extended with a
|
|
161
|
-
# zero to give a sensible result.
|
|
162
|
-
#
|
|
163
3
|
class Version
|
|
164
4
|
include Comparable
|
|
165
5
|
|
data/core/set.rbs
CHANGED
|
@@ -738,7 +738,7 @@ class Set[unchecked out A]
|
|
|
738
738
|
end
|
|
739
739
|
|
|
740
740
|
%a{annotate:rdoc:skip}
|
|
741
|
-
module Enumerable[unchecked out
|
|
741
|
+
module Enumerable[unchecked out E]
|
|
742
742
|
# <!--
|
|
743
743
|
# rdoc-file=prelude.rb
|
|
744
744
|
# - to_set(*args, &block)
|
|
@@ -746,6 +746,6 @@ module Enumerable[unchecked out Elem]
|
|
|
746
746
|
# Makes a set from the enumerable object with given arguments. Passing arguments
|
|
747
747
|
# to this method is deprecated.
|
|
748
748
|
#
|
|
749
|
-
def to_set: () -> Set[
|
|
750
|
-
| [T] () { (
|
|
749
|
+
def to_set: () -> Set[E]
|
|
750
|
+
| [T] () { (E) -> T } -> Set[T]
|
|
751
751
|
end
|
data/core/struct.rbs
CHANGED
|
@@ -104,8 +104,8 @@
|
|
|
104
104
|
# * #inspect (aliased as #to_s): Returns a string representation of `self`.
|
|
105
105
|
# * #to_h: Returns a hash of the member name/value pairs in `self`.
|
|
106
106
|
#
|
|
107
|
-
class Struct[
|
|
108
|
-
include Enumerable[
|
|
107
|
+
class Struct[E]
|
|
108
|
+
include Enumerable[E]
|
|
109
109
|
|
|
110
110
|
# The types that can be used when "indexing" into a `Struct` via `[]`, `[]=`, `dig`, and
|
|
111
111
|
# `deconstruct_keys`.
|
|
@@ -362,7 +362,7 @@ class Struct[Elem]
|
|
|
362
362
|
#
|
|
363
363
|
# Related: #members.
|
|
364
364
|
#
|
|
365
|
-
def to_a: () -> Array[
|
|
365
|
+
def to_a: () -> Array[E]
|
|
366
366
|
|
|
367
367
|
# <!--
|
|
368
368
|
# rdoc-file=struct.c
|
|
@@ -385,8 +385,8 @@ class Struct[Elem]
|
|
|
385
385
|
#
|
|
386
386
|
# Raises ArgumentError if the block returns an inappropriate value.
|
|
387
387
|
#
|
|
388
|
-
def to_h: () -> Hash[Symbol,
|
|
389
|
-
| [K, V] () { (Symbol key,
|
|
388
|
+
def to_h: () -> Hash[Symbol, E]
|
|
389
|
+
| [K, V] () { (Symbol key, E value) -> [K, V] } -> Hash[K, V]
|
|
390
390
|
|
|
391
391
|
# <!-- rdoc-file=struct.c -->
|
|
392
392
|
# Returns the values in `self` as an array:
|
|
@@ -441,8 +441,8 @@ class Struct[Elem]
|
|
|
441
441
|
#
|
|
442
442
|
# Related: #each_pair.
|
|
443
443
|
#
|
|
444
|
-
def each: () -> Enumerator[
|
|
445
|
-
| () { (
|
|
444
|
+
def each: () -> Enumerator[E, self]
|
|
445
|
+
| () { (E value) -> void } -> self
|
|
446
446
|
|
|
447
447
|
# <!--
|
|
448
448
|
# rdoc-file=struct.c
|
|
@@ -465,8 +465,8 @@ class Struct[Elem]
|
|
|
465
465
|
#
|
|
466
466
|
# Related: #each.
|
|
467
467
|
#
|
|
468
|
-
def each_pair: () -> Enumerator[[Symbol,
|
|
469
|
-
| () { ([Symbol,
|
|
468
|
+
def each_pair: () -> Enumerator[[Symbol, E], self]
|
|
469
|
+
| () { ([Symbol, E] key_value) -> void } -> self
|
|
470
470
|
|
|
471
471
|
# <!--
|
|
472
472
|
# rdoc-file=struct.c
|
|
@@ -492,7 +492,7 @@ class Struct[Elem]
|
|
|
492
492
|
#
|
|
493
493
|
# Raises IndexError if `n` is out of range.
|
|
494
494
|
#
|
|
495
|
-
def []: (index name_or_position) ->
|
|
495
|
+
def []: (index name_or_position) -> E
|
|
496
496
|
|
|
497
497
|
# <!--
|
|
498
498
|
# rdoc-file=struct.c
|
|
@@ -521,7 +521,7 @@ class Struct[Elem]
|
|
|
521
521
|
#
|
|
522
522
|
# Raises IndexError if `n` is out of range.
|
|
523
523
|
#
|
|
524
|
-
def []=: (index name_or_position,
|
|
524
|
+
def []=: (index name_or_position, E value) -> E
|
|
525
525
|
|
|
526
526
|
# <!--
|
|
527
527
|
# rdoc-file=struct.c
|
|
@@ -540,8 +540,8 @@ class Struct[Elem]
|
|
|
540
540
|
#
|
|
541
541
|
# With no block given, returns an Enumerator.
|
|
542
542
|
#
|
|
543
|
-
def select: () -> Enumerator[
|
|
544
|
-
| () { (
|
|
543
|
+
def select: () -> Enumerator[E, Array[E]]
|
|
544
|
+
| () { (E value) -> boolish } -> Array[E]
|
|
545
545
|
|
|
546
546
|
# <!-- rdoc-file=struct.c -->
|
|
547
547
|
# With a block given, returns an array of values from `self` for which the block
|
|
@@ -591,7 +591,7 @@ class Struct[Elem]
|
|
|
591
591
|
# Raises RangeError if any element of the range is negative and out of range;
|
|
592
592
|
# see Array@Array+Indexes.
|
|
593
593
|
#
|
|
594
|
-
def values_at: (*int | range[int?] positions) -> Array[
|
|
594
|
+
def values_at: (*int | range[int?] positions) -> Array[E]
|
|
595
595
|
|
|
596
596
|
# <!--
|
|
597
597
|
# rdoc-file=struct.c
|
|
@@ -634,7 +634,7 @@ class Struct[Elem]
|
|
|
634
634
|
# f.dig(0, 0, :b, 0) # => 1
|
|
635
635
|
# f.dig(:b, 0) # => nil
|
|
636
636
|
#
|
|
637
|
-
def dig: (index name_or_position) ->
|
|
637
|
+
def dig: (index name_or_position) -> E
|
|
638
638
|
| (index name_or_position, untyped, *untyped) -> untyped
|
|
639
639
|
|
|
640
640
|
# <!-- rdoc-file=struct.c -->
|
|
@@ -664,5 +664,5 @@ class Struct[Elem]
|
|
|
664
664
|
# h = joe.deconstruct_keys(nil)
|
|
665
665
|
# h # => {:name=>"Joseph Smith, Jr.", :address=>"123 Maple, Anytown NC", :zip=>12345}
|
|
666
666
|
#
|
|
667
|
-
def deconstruct_keys: (Array[index & Hash::_Key]? indices) -> Hash[index & Hash::_Key,
|
|
667
|
+
def deconstruct_keys: (Array[index & Hash::_Key]? indices) -> Hash[index & Hash::_Key, E]
|
|
668
668
|
end
|