rbs 0.15.0 → 0.19.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/ruby.yml +8 -4
- data/CHANGELOG.md +29 -1
- data/Gemfile +1 -0
- data/README.md +1 -1
- data/Rakefile +19 -1
- data/Steepfile +0 -1
- data/bin/test_runner.rb +15 -1
- data/{stdlib/builtin → core}/array.rbs +1 -1
- data/{stdlib/builtin → core}/basic_object.rbs +0 -0
- data/{stdlib/builtin → core}/binding.rbs +0 -0
- data/{stdlib/builtin → core}/builtin.rbs +2 -2
- data/{stdlib/builtin → core}/class.rbs +0 -0
- data/{stdlib/builtin → core}/comparable.rbs +0 -0
- data/{stdlib/builtin → core}/complex.rbs +0 -0
- data/{stdlib/builtin → core}/constants.rbs +0 -0
- data/{stdlib/builtin → core}/data.rbs +0 -0
- data/{stdlib/builtin → core}/deprecated.rbs +0 -0
- data/{stdlib/builtin → core}/dir.rbs +1 -1
- data/{stdlib/builtin → core}/encoding.rbs +0 -0
- data/{stdlib/builtin → core}/enumerable.rbs +41 -40
- data/{stdlib/builtin → core}/enumerator.rbs +5 -5
- data/{stdlib/builtin → core}/errno.rbs +0 -0
- data/{stdlib/builtin → core}/errors.rbs +0 -0
- data/{stdlib/builtin → core}/exception.rbs +0 -0
- data/{stdlib/builtin → core}/false_class.rbs +0 -0
- data/{stdlib/builtin → core}/fiber.rbs +0 -0
- data/{stdlib/builtin → core}/fiber_error.rbs +0 -0
- data/{stdlib/builtin → core}/file.rbs +0 -4
- data/{stdlib/builtin → core}/file_test.rbs +0 -0
- data/{stdlib/builtin → core}/float.rbs +0 -0
- data/{stdlib/builtin → core}/gc.rbs +0 -0
- data/{stdlib/builtin → core}/hash.rbs +8 -8
- data/{stdlib/builtin → core}/integer.rbs +0 -0
- data/{stdlib/builtin → core}/io.rbs +1 -1
- data/{stdlib/builtin → core}/kernel.rbs +0 -0
- data/{stdlib/builtin → core}/marshal.rbs +0 -0
- data/{stdlib/builtin → core}/match_data.rbs +0 -0
- data/{stdlib/builtin → core}/math.rbs +0 -0
- data/{stdlib/builtin → core}/method.rbs +0 -0
- data/{stdlib/builtin → core}/module.rbs +0 -0
- data/{stdlib/builtin → core}/nil_class.rbs +0 -0
- data/{stdlib/builtin → core}/numeric.rbs +0 -0
- data/{stdlib/builtin → core}/object.rbs +0 -0
- data/core/object_space.rbs +98 -0
- data/{stdlib/builtin → core}/proc.rbs +0 -0
- data/{stdlib/builtin → core}/process.rbs +0 -0
- data/{stdlib/builtin → core}/random.rbs +0 -0
- data/{stdlib/builtin → core}/range.rbs +1 -1
- data/{stdlib/builtin → core}/rational.rbs +0 -0
- data/{stdlib/builtin → core}/rb_config.rbs +0 -0
- data/{stdlib/builtin → core}/regexp.rbs +0 -0
- data/{stdlib/builtin → core}/ruby_vm.rbs +0 -0
- data/{stdlib/builtin → core}/signal.rbs +0 -0
- data/{stdlib/builtin → core}/string.rbs +0 -0
- data/{stdlib/builtin → core}/string_io.rbs +0 -0
- data/{stdlib/builtin → core}/struct.rbs +1 -1
- data/{stdlib/builtin → core}/symbol.rbs +0 -0
- data/{stdlib/builtin → core}/thread.rbs +0 -0
- data/{stdlib/builtin → core}/thread_group.rbs +0 -0
- data/{stdlib/builtin → core}/time.rbs +0 -0
- data/{stdlib/builtin → core}/trace_point.rbs +0 -0
- data/{stdlib/builtin → core}/true_class.rbs +0 -0
- data/{stdlib/builtin → core}/unbound_method.rbs +0 -0
- data/{stdlib/builtin → core}/warning.rbs +0 -0
- data/docs/repo.md +125 -0
- data/lib/rbs.rb +1 -0
- data/lib/rbs/cli.rb +105 -103
- data/lib/rbs/definition.rb +9 -4
- data/lib/rbs/definition_builder.rb +48 -15
- data/lib/rbs/environment_loader.rb +79 -105
- data/lib/rbs/environment_walker.rb +70 -35
- data/lib/rbs/parser.rb +306 -301
- data/lib/rbs/parser.y +15 -8
- data/lib/rbs/prototype/rb.rb +150 -21
- data/lib/rbs/prototype/runtime.rb +1 -0
- data/lib/rbs/repository.rb +121 -0
- data/lib/rbs/test/hook.rb +25 -15
- data/lib/rbs/test/setup.rb +5 -3
- data/lib/rbs/test/type_check.rb +6 -1
- data/lib/rbs/type_name.rb +2 -1
- data/lib/rbs/vendorer.rb +38 -16
- data/lib/rbs/version.rb +1 -1
- data/sig/cli.rbs +58 -0
- data/sig/definition.rbs +8 -3
- data/sig/definition_builder.rbs +4 -1
- data/sig/environment_loader.rbs +92 -46
- data/sig/polyfill.rbs +42 -0
- data/sig/rbs.rbs +8 -0
- data/sig/repository.rbs +79 -0
- data/sig/vendorer.rbs +44 -0
- data/stdlib/abbrev/{abbrev.rbs → 0/abbrev.rbs} +0 -0
- data/stdlib/base64/{base64.rbs → 0/base64.rbs} +0 -0
- data/stdlib/benchmark/{benchmark.rbs → 0/benchmark.rbs} +0 -0
- data/stdlib/{bigdecimal/math → bigdecimal-math/0}/big_math.rbs +0 -0
- data/stdlib/bigdecimal/{big_decimal.rbs → 0/big_decimal.rbs} +0 -0
- data/stdlib/coverage/{coverage.rbs → 0/coverage.rbs} +0 -0
- data/stdlib/csv/{csv.rbs → 0/csv.rbs} +3 -3
- data/stdlib/date/{date.rbs → 0/date.rbs} +0 -0
- data/stdlib/date/{date_time.rbs → 0/date_time.rbs} +0 -0
- data/stdlib/dbm/0/dbm.rbs +277 -0
- data/stdlib/erb/{erb.rbs → 0/erb.rbs} +0 -0
- data/stdlib/fiber/{fiber.rbs → 0/fiber.rbs} +0 -0
- data/stdlib/find/{find.rbs → 0/find.rbs} +0 -0
- data/stdlib/forwardable/{forwardable.rbs → 0/forwardable.rbs} +0 -0
- data/stdlib/ipaddr/{ipaddr.rbs → 0/ipaddr.rbs} +0 -0
- data/stdlib/json/{json.rbs → 0/json.rbs} +0 -0
- data/stdlib/logger/{formatter.rbs → 0/formatter.rbs} +0 -0
- data/stdlib/logger/{log_device.rbs → 0/log_device.rbs} +0 -0
- data/stdlib/logger/{logger.rbs → 0/logger.rbs} +0 -0
- data/stdlib/logger/{period.rbs → 0/period.rbs} +0 -0
- data/stdlib/logger/{severity.rbs → 0/severity.rbs} +0 -0
- data/stdlib/monitor/0/monitor.rbs +119 -0
- data/stdlib/mutex_m/{mutex_m.rbs → 0/mutex_m.rbs} +0 -0
- data/stdlib/pathname/{pathname.rbs → 0/pathname.rbs} +0 -0
- data/stdlib/prime/{integer-extension.rbs → 0/integer-extension.rbs} +0 -0
- data/stdlib/prime/{prime.rbs → 0/prime.rbs} +1 -1
- data/stdlib/pstore/{pstore.rbs → 0/pstore.rbs} +0 -0
- data/stdlib/pty/{pty.rbs → 0/pty.rbs} +0 -0
- data/stdlib/securerandom/{securerandom.rbs → 0/securerandom.rbs} +0 -0
- data/stdlib/set/{set.rbs → 0/set.rbs} +10 -10
- data/stdlib/singleton/0/singleton.rbs +111 -0
- data/stdlib/tmpdir/{tmpdir.rbs → 0/tmpdir.rbs} +0 -0
- data/stdlib/tsort/0/cyclic.rbs +4 -0
- data/stdlib/tsort/0/interfaces.rbs +19 -0
- data/stdlib/tsort/0/tsort.rbs +363 -0
- data/stdlib/uri/{file.rbs → 0/file.rbs} +0 -0
- data/stdlib/uri/{generic.rbs → 0/generic.rbs} +0 -0
- data/stdlib/uri/{http.rbs → 0/http.rbs} +0 -0
- data/stdlib/uri/{https.rbs → 0/https.rbs} +0 -0
- data/stdlib/uri/{ldap.rbs → 0/ldap.rbs} +0 -0
- data/stdlib/uri/{ldaps.rbs → 0/ldaps.rbs} +0 -0
- data/stdlib/yaml/0/dbm.rbs +221 -0
- data/stdlib/yaml/0/store.rbs +53 -0
- data/stdlib/zlib/{zlib.rbs → 0/zlib.rbs} +0 -0
- data/steep/Gemfile.lock +9 -9
- metadata +108 -94
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8305afa064e98cd22b78a49fb402692abed204c735a7ce05d90f6a48d7bd6b96
|
|
4
|
+
data.tar.gz: 7840d67b2bbd54eb041342e093892b6d1046b21b6655b80eba109df6b773451d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4919d1fd1323fa5cb2c40f89f5338d2168d3ae4fcabed2e2c428b3e5b4bacda2e395e9dfb2fc52a6517e75137358118b4142b330f607f77c162f259485ac0b13
|
|
7
|
+
data.tar.gz: dc36b905d8c746eb5e976f6f3fc4a06ba8ed2b037d15d73e8bfa4360497c9c814f44dd604981f7c3622002ef0bb603b1b9374e2f49ab0af67bc35ecbe2d7b26e
|
data/.github/workflows/ruby.yml
CHANGED
|
@@ -13,16 +13,20 @@ jobs:
|
|
|
13
13
|
matrix:
|
|
14
14
|
container_tag:
|
|
15
15
|
- master-nightly-bionic
|
|
16
|
-
- 2.6
|
|
17
|
-
- 2.7
|
|
16
|
+
- 2.6-bionic
|
|
17
|
+
- 2.7-bionic
|
|
18
18
|
job:
|
|
19
19
|
- test
|
|
20
20
|
- stdlib_test
|
|
21
|
-
- rubocop validate test_doc build test_generate_stdlib
|
|
21
|
+
- rubocop validate test_doc build test_generate_stdlib confirm_parser
|
|
22
22
|
container:
|
|
23
23
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
|
24
24
|
steps:
|
|
25
25
|
- uses: actions/checkout@v1
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
apt-get update
|
|
29
|
+
apt-get install -y libdb-dev
|
|
26
30
|
- name: Install
|
|
27
31
|
run: |
|
|
28
32
|
ruby -v
|
|
@@ -31,4 +35,4 @@ jobs:
|
|
|
31
35
|
- name: Run test
|
|
32
36
|
run: |
|
|
33
37
|
bundle exec rake ${{ matrix.job }}
|
|
34
|
-
if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6
|
|
38
|
+
if: "!(matrix.job == 'stdlib_test' && contains(matrix.container_tag, '2.6'))"
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,35 @@
|
|
|
2
2
|
|
|
3
3
|
## master
|
|
4
4
|
|
|
5
|
-
## 0.
|
|
5
|
+
## 0.19.0 (2020-12-02)
|
|
6
|
+
|
|
7
|
+
* Signature updates for `Monitor` and File ([#485](https://github.com/ruby/rbs/pull/485), [#495](https://github.com/ruby/rbs/pull/495))
|
|
8
|
+
|
|
9
|
+
## 0.18.1 (2020-12-01)
|
|
10
|
+
|
|
11
|
+
* Fix `EnvironmentWalker#each_type_name` ([#494](https://github.com/ruby/rbs/pull/494))
|
|
12
|
+
|
|
13
|
+
## 0.18.0 (2020-12-01)
|
|
14
|
+
|
|
15
|
+
* Signature updates for `YAML`, `ObjectSpace`, and `Singleton` ([#408](https://github.com/ruby/rbs/pull/408), [#477](https://github.com/ruby/rbs/pull/477), [#482](https://github.com/ruby/rbs/pull/482))
|
|
16
|
+
* `prototype rb` improvements ([#492](https://github.com/ruby/rbs/pull/492), [#487](https://github.com/ruby/rbs/pull/487), [#486](https://github.com/ruby/rbs/pull/486), [#481](https://github.com/ruby/rbs/pull/481))
|
|
17
|
+
* Runtime type checker improvements ([#488](https://github.com/ruby/rbs/pull/488), [#489](https://github.com/ruby/rbs/pull/489), [#490](https://github.com/ruby/rbs/pull/490))
|
|
18
|
+
* Update `DependencyWalker` API to receive _Node_ objects instead of `TypeName` ([#484](https://github.com/ruby/rbs/pull/484))
|
|
19
|
+
* Assume encoding of RBS files to be UTF-8 ([#493](https://github.com/ruby/rbs/pull/493))
|
|
20
|
+
|
|
21
|
+
## 0.17.0 (2020-11-14)
|
|
22
|
+
|
|
23
|
+
* Signature updates for `Enumerable`, `Hash`, and `TSort` ([#462](https://github.com/ruby/rbs/pull/462), [#468](https://github.com/ruby/rbs/pull/468), [#471](https://github.com/ruby/rbs/pull/471), [#472](https://github.com/ruby/rbs/pull/472), [#473](https://github.com/ruby/rbs/pull/473), [#474](https://github.com/ruby/rbs/pull/474))
|
|
24
|
+
* Parser error handling improvement ([#463](https://github.com/ruby/rbs/pull/463), [#475](https://github.com/ruby/rbs/pull/475))
|
|
25
|
+
* Hash spread syntax handling improvement with `prototype rb` ([#465](https://github.com/ruby/rbs/pull/465))
|
|
26
|
+
|
|
27
|
+
## 0.16.0 (2020-11-05)
|
|
28
|
+
|
|
29
|
+
* Signature update for `DBM` ([#441](https://github.com/ruby/rbs/pull/441))
|
|
30
|
+
* RBS repository ([#405](https://github.com/ruby/rbs/pull/405))
|
|
31
|
+
* Support `alias` in `rbs prototype rb` ([#457](https://github.com/ruby/rbs/pull/457))
|
|
32
|
+
|
|
33
|
+
## 0.15.0 (2020-11-02)
|
|
6
34
|
|
|
7
35
|
* Signature updates for `Kernel`, `PStore`, `Enumerable`, and `Array` ([#450](https://github.com/ruby/rbs/pull/450), [#443](https://github.com/ruby/rbs/pull/443), [#438](https://github.com/ruby/rbs/pull/438), [#437](https://github.com/ruby/rbs/pull/437), [#433](https://github.com/ruby/rbs/pull/433), [#432](https://github.com/ruby/rbs/pull/432))
|
|
8
36
|
* Add helper interfaces ([#434](https://github.com/ruby/rbs/pull/434), [#428](https://github.com/ruby/rbs/pull/428))
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -46,7 +46,7 @@ module ChatApp
|
|
|
46
46
|
def initialize: (name: String) -> void
|
|
47
47
|
|
|
48
48
|
def each_member: () { (User | Bot) -> void } -> void # `{` and `}` means block.
|
|
49
|
-
| () ->
|
|
49
|
+
| () -> Enumerator[User | Bot, void] # Method can be overloaded.
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
52
|
```
|
data/Rakefile
CHANGED
|
@@ -29,7 +29,19 @@ task :validate => :parser do
|
|
|
29
29
|
|
|
30
30
|
FileList["stdlib/*"].each do |path|
|
|
31
31
|
next if path =~ %r{stdlib/builtin}
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
lib = [File.basename(path).to_s]
|
|
34
|
+
|
|
35
|
+
if lib == ["bigdecimal-math"]
|
|
36
|
+
lib << "bigdecimal"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if lib == ["yaml"]
|
|
40
|
+
lib << "dbm"
|
|
41
|
+
lib << "pstore"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
sh "#{ruby} #{rbs} #{lib.map {|l| "-r #{l}"}.join(" ")} validate --silent"
|
|
33
45
|
end
|
|
34
46
|
end
|
|
35
47
|
|
|
@@ -53,6 +65,12 @@ task :test => :parser
|
|
|
53
65
|
task :stdlib_test => :parser
|
|
54
66
|
task :build => :parser
|
|
55
67
|
|
|
68
|
+
task :confirm_parser do
|
|
69
|
+
puts "Testing if parser.rb is updated with respect to parser.y"
|
|
70
|
+
sh "racc -v -o lib/rbs/parser.rb lib/rbs/parser.y"
|
|
71
|
+
sh "git diff --exit-code lib/rbs/parser.rb"
|
|
72
|
+
end
|
|
73
|
+
|
|
56
74
|
namespace :generate do
|
|
57
75
|
task :stdlib_test, [:class] do |_task, args|
|
|
58
76
|
klass = args.fetch(:class) do
|
data/Steepfile
CHANGED
data/bin/test_runner.rb
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
$LOAD_PATH << File.join(__dir__, "../lib")
|
|
4
4
|
|
|
5
|
+
require "set"
|
|
6
|
+
|
|
5
7
|
IS_RUBY_27 = Gem::Version.new(RUBY_VERSION).yield_self do |ruby_version|
|
|
6
8
|
Gem::Version.new('2.7.0') <= ruby_version &&
|
|
7
9
|
ruby_version <= Gem::Version.new('2.8.0')
|
|
@@ -11,6 +13,18 @@ unless IS_RUBY_27
|
|
|
11
13
|
STDERR.puts "⚠️⚠️⚠️⚠️ stdlib test assumes Ruby 2.7 but RUBY_VERSION==#{RUBY_VERSION} ⚠️⚠️⚠️⚠️"
|
|
12
14
|
end
|
|
13
15
|
|
|
16
|
+
KNOWN_FAILS = %w(dbm).map do |lib|
|
|
17
|
+
/cannot load such file -- #{lib}/
|
|
18
|
+
end
|
|
19
|
+
|
|
14
20
|
ARGV.each do |arg|
|
|
15
|
-
|
|
21
|
+
begin
|
|
22
|
+
load arg
|
|
23
|
+
rescue LoadError => exn
|
|
24
|
+
if KNOWN_FAILS.any? {|pat| pat =~ exn.message }
|
|
25
|
+
STDERR.puts "Loading #{arg} failed, ignoring it: #{exn.inspect}"
|
|
26
|
+
else
|
|
27
|
+
raise
|
|
28
|
+
end
|
|
29
|
+
end
|
|
16
30
|
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
# objects in the collection must also implement a meaningful `<=>`
|
|
6
6
|
# operator, as these methods rely on an ordering between members of the
|
|
7
7
|
# collection.
|
|
8
|
-
module Enumerable[unchecked out Elem
|
|
8
|
+
module Enumerable[unchecked out Elem]: _Each[Elem]
|
|
9
9
|
# Passes each element of the collection to the given block. The method
|
|
10
10
|
# returns `true` if the block never returns `false` or `nil` . If the
|
|
11
11
|
# block is not given, Ruby adds an implicit block of `{ |obj| obj }` which
|
|
@@ -66,24 +66,24 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
66
66
|
| () { (Elem) -> boolish } -> Integer
|
|
67
67
|
|
|
68
68
|
def cycle: (?Integer n) { (Elem arg0) -> untyped } -> NilClass
|
|
69
|
-
| (?Integer n) -> ::Enumerator[Elem,
|
|
69
|
+
| (?Integer n) -> ::Enumerator[Elem, NilClass]
|
|
70
70
|
|
|
71
71
|
def detect: (?Proc ifnone) { (Elem) -> boolish } -> Elem?
|
|
72
|
-
| (?Proc ifnone) -> ::Enumerator[Elem,
|
|
72
|
+
| (?Proc ifnone) -> ::Enumerator[Elem, Elem?]
|
|
73
73
|
|
|
74
74
|
def drop: (Integer n) -> ::Array[Elem]
|
|
75
75
|
|
|
76
76
|
def drop_while: () { (Elem) -> boolish } -> ::Array[Elem]
|
|
77
|
-
| () -> ::Enumerator[Elem,
|
|
77
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
78
78
|
|
|
79
79
|
def each_cons: (Integer n) { (::Array[Elem] arg0) -> untyped } -> NilClass
|
|
80
|
-
| (Integer n) -> ::Enumerator[::Array[Elem],
|
|
80
|
+
| (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
|
|
81
81
|
|
|
82
|
-
def each_with_index: () { (Elem arg0, Integer arg1) -> untyped } ->
|
|
83
|
-
| () -> ::Enumerator[[ Elem, Integer ],
|
|
82
|
+
def each_with_index: () { (Elem arg0, Integer arg1) -> untyped } -> void
|
|
83
|
+
| () -> ::Enumerator[[ Elem, Integer ], void]
|
|
84
84
|
|
|
85
85
|
def each_with_object: [U] (U arg0) { (Elem arg0, untyped arg1) -> untyped } -> U
|
|
86
|
-
| [U] (U arg0) -> ::Enumerator[[ Elem, U ],
|
|
86
|
+
| [U] (U arg0) -> ::Enumerator[[ Elem, U ], U]
|
|
87
87
|
|
|
88
88
|
# Returns an array containing the items in *enum* .
|
|
89
89
|
#
|
|
@@ -97,14 +97,14 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
97
97
|
def entries: () -> ::Array[Elem]
|
|
98
98
|
|
|
99
99
|
def find_all: () { (Elem) -> boolish } -> ::Array[Elem]
|
|
100
|
-
| () -> ::Enumerator[Elem,
|
|
100
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
101
101
|
|
|
102
102
|
alias select find_all
|
|
103
103
|
alias filter find_all
|
|
104
104
|
|
|
105
105
|
def find_index: (?untyped value) -> Integer?
|
|
106
106
|
| () { (Elem) -> boolish } -> Integer?
|
|
107
|
-
| () -> ::Enumerator[Elem,
|
|
107
|
+
| () -> ::Enumerator[Elem, Integer?]
|
|
108
108
|
|
|
109
109
|
# Returns the first element, or the first `n` elements, of the enumerable.
|
|
110
110
|
# If the enumerable is empty, the first form returns `nil`, and the
|
|
@@ -118,7 +118,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
118
118
|
# [].first(10) #=> []
|
|
119
119
|
# ```
|
|
120
120
|
def first: () -> Elem?
|
|
121
|
-
| (
|
|
121
|
+
| (Integer n) -> ::Array[Elem]?
|
|
122
122
|
|
|
123
123
|
def grep: (untyped arg0) -> ::Array[Elem]
|
|
124
124
|
| [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
|
|
@@ -127,7 +127,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
127
127
|
| [U] (untyped arg0) { (Elem arg0) -> U } -> ::Array[U]
|
|
128
128
|
|
|
129
129
|
def group_by: [U] () { (Elem arg0) -> U } -> ::Hash[U, ::Array[Elem]]
|
|
130
|
-
| () -> ::Enumerator[Elem,
|
|
130
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
131
131
|
|
|
132
132
|
def `include?`: (untyped arg0) -> bool
|
|
133
133
|
|
|
@@ -157,13 +157,13 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
157
157
|
# ```
|
|
158
158
|
def max: () -> Elem?
|
|
159
159
|
| () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
|
|
160
|
-
| (
|
|
161
|
-
| (
|
|
160
|
+
| (Integer arg0) -> ::Array[Elem]
|
|
161
|
+
| (Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
|
|
162
162
|
|
|
163
|
-
def max_by: () -> ::Enumerator[Elem,
|
|
163
|
+
def max_by: () -> ::Enumerator[Elem, Elem?]
|
|
164
164
|
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
|
|
165
|
-
| (
|
|
166
|
-
| (
|
|
165
|
+
| (Integer arg0) -> ::Enumerator[Elem, ::Array[Elem]]
|
|
166
|
+
| (Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
|
|
167
167
|
|
|
168
168
|
# Returns the object in *enum* with the minimum value. The first form
|
|
169
169
|
# assumes all objects implement `Comparable` ; the second uses the block
|
|
@@ -186,13 +186,13 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
186
186
|
# ```
|
|
187
187
|
def min: () -> Elem?
|
|
188
188
|
| () { (Elem arg0, Elem arg1) -> Integer } -> Elem?
|
|
189
|
-
| (
|
|
190
|
-
| (
|
|
189
|
+
| (Integer arg0) -> ::Array[Elem]
|
|
190
|
+
| (Integer arg0) { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
|
|
191
191
|
|
|
192
|
-
def min_by: () -> ::Enumerator[Elem,
|
|
192
|
+
def min_by: () -> ::Enumerator[Elem, Elem?]
|
|
193
193
|
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> Elem?
|
|
194
|
-
| (
|
|
195
|
-
| (
|
|
194
|
+
| (Integer arg0) -> ::Enumerator[Elem, ::Array[Elem]]
|
|
195
|
+
| (Integer arg0) { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
|
|
196
196
|
|
|
197
197
|
# Returns a two element array which contains the minimum and the maximum
|
|
198
198
|
# value in the enumerable. The first form assumes all objects implement
|
|
@@ -207,7 +207,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
207
207
|
| () { (Elem arg0, Elem arg1) -> Integer } -> [ Elem?, Elem? ]
|
|
208
208
|
|
|
209
209
|
def minmax_by: () -> [ Elem?, Elem? ]
|
|
210
|
-
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } ->
|
|
210
|
+
| () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> [ Elem?, Elem? ]
|
|
211
211
|
|
|
212
212
|
# Passes each element of the collection to the given block. The method
|
|
213
213
|
# returns `true` if the block never returns `true` for all elements. If
|
|
@@ -252,13 +252,13 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
252
252
|
| () { (Elem) -> boolish } -> bool
|
|
253
253
|
|
|
254
254
|
def partition: () { (Elem) -> boolish } -> [ ::Array[Elem], ::Array[Elem] ]
|
|
255
|
-
| () -> ::Enumerator[Elem,
|
|
255
|
+
| () -> ::Enumerator[Elem, [ ::Array[Elem], ::Array[Elem] ]]
|
|
256
256
|
|
|
257
257
|
def reject: () { (Elem) -> boolish } -> ::Array[Elem]
|
|
258
|
-
| () -> ::Enumerator[Elem,
|
|
258
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
259
259
|
|
|
260
|
-
def reverse_each: () { (Elem arg0) -> untyped } ->
|
|
261
|
-
| () -> ::Enumerator[Elem,
|
|
260
|
+
def reverse_each: () { (Elem arg0) -> untyped } -> void
|
|
261
|
+
| () -> ::Enumerator[Elem, void]
|
|
262
262
|
|
|
263
263
|
# Returns an array containing the items in *enum* sorted.
|
|
264
264
|
#
|
|
@@ -284,12 +284,12 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
284
284
|
| () { (Elem arg0, Elem arg1) -> Integer } -> ::Array[Elem]
|
|
285
285
|
|
|
286
286
|
def sort_by: () { (Elem arg0) -> (Comparable | ::Array[untyped]) } -> ::Array[Elem]
|
|
287
|
-
| () -> ::Enumerator[Elem,
|
|
287
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
288
288
|
|
|
289
289
|
def take: (Integer n) -> ::Array[Elem]?
|
|
290
290
|
|
|
291
291
|
def take_while: () { (Elem) -> boolish } -> ::Array[Elem]
|
|
292
|
-
| () -> ::Enumerator[Elem,
|
|
292
|
+
| () -> ::Enumerator[Elem, ::Array[Elem]]
|
|
293
293
|
|
|
294
294
|
# Implemented in C++
|
|
295
295
|
# Returns the result of interpreting *enum* as a list of `[key, value]`
|
|
@@ -306,9 +306,10 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
306
306
|
# #=> {1=>1, 2=>4, 3=>9, 4=>16, 5=>25}
|
|
307
307
|
# ```
|
|
308
308
|
def to_h: () -> ::Hash[untyped, untyped]
|
|
309
|
+
| [T, U] () { (Elem) -> [T, U] } -> ::Hash[T, U]
|
|
309
310
|
|
|
310
311
|
def each_slice: (Integer n) { (::Array[Elem]) -> untyped } -> NilClass
|
|
311
|
-
| (Integer n) -> ::Enumerator[::Array[Elem],
|
|
312
|
+
| (Integer n) -> ::Enumerator[::Array[Elem], NilClass]
|
|
312
313
|
|
|
313
314
|
interface _NotFound[T]
|
|
314
315
|
def call: () -> T
|
|
@@ -319,8 +320,8 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
319
320
|
| [T] (_NotFound[T] ifnone) { (Elem) -> boolish } -> (Elem | T)
|
|
320
321
|
| [T] (_NotFound[T] ifnone) -> ::Enumerator[Elem, Elem | T]
|
|
321
322
|
|
|
322
|
-
def flat_map: [U] () { (Elem
|
|
323
|
-
| () -> ::Enumerator[Elem,
|
|
323
|
+
def flat_map: [U] () { (Elem) -> (Array[U] | U) } -> Array[U]
|
|
324
|
+
| () -> ::Enumerator[Elem, Array[untyped]]
|
|
324
325
|
|
|
325
326
|
def map: [U] () { (Elem arg0) -> U } -> ::Array[U]
|
|
326
327
|
| () -> ::Enumerator[Elem, ::Array[untyped]]
|
|
@@ -370,7 +371,7 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
370
371
|
# # show pythagorean triples less than 100
|
|
371
372
|
# p pythagorean_triples.take_while { |*, z| z < 100 }.force
|
|
372
373
|
# ```
|
|
373
|
-
def lazy: () -> Enumerator::Lazy[Elem,
|
|
374
|
+
def lazy: () -> Enumerator::Lazy[Elem, void]
|
|
374
375
|
|
|
375
376
|
def uniq: () -> ::Array[Elem]
|
|
376
377
|
| () { (Elem item) -> untyped } -> ::Array[Elem]
|
|
@@ -381,22 +382,22 @@ module Enumerable[unchecked out Elem, out Return]: _Each[Elem, Return]
|
|
|
381
382
|
| [U] (?U arg0) { (Elem arg0) -> U } -> U
|
|
382
383
|
|
|
383
384
|
def filter_map: [U] () { (Elem elem) -> (nil | false | U) } -> ::Array[U]
|
|
384
|
-
| () -> ::Enumerator[Elem,
|
|
385
|
+
| () -> ::Enumerator[Elem, ::Array[untyped]]
|
|
385
386
|
|
|
386
|
-
def chain: (*self enumerables) -> ::Enumerator::Chain[Elem
|
|
387
|
+
def chain: (*self enumerables) -> ::Enumerator::Chain[Elem]
|
|
387
388
|
|
|
388
389
|
def tally: () -> ::Hash[Elem, Integer]
|
|
389
390
|
|
|
390
|
-
def each_entry: () -> ::Enumerator[Elem,
|
|
391
|
+
def each_entry: () -> ::Enumerator[Elem, self]
|
|
391
392
|
| () { (Elem arg0) -> untyped } -> self
|
|
392
393
|
|
|
393
394
|
# variadic type parameter is not supported yet
|
|
394
395
|
# https://github.com/ruby/rbs/issues/21
|
|
395
|
-
def zip: [Elem2
|
|
396
|
-
| [U, Elem2
|
|
396
|
+
def zip: [Elem2] (::Enumerable[Elem2] enum) -> ::Array[[Elem, Elem2 | nil]]
|
|
397
|
+
| [U, Elem2] (::Enumerable[Elem2]) { ([Elem, Elem2 | nil]) -> U } -> nil
|
|
397
398
|
|
|
398
|
-
def chunk: () -> ::Enumerator[Elem,
|
|
399
|
-
|
|
|
399
|
+
def chunk: [U] () { (Elem elt) -> U } -> ::Enumerator[[U, Array[Elem]], void]
|
|
400
|
+
| () -> ::Enumerator[Elem, Enumerator[untyped, untyped]]
|
|
400
401
|
|
|
401
402
|
def chunk_while: () { (Elem elt_before, Elem elt_after) -> boolish } -> ::Enumerator[::Array[Elem], void]
|
|
402
403
|
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
# # => [], [:b], [1], [:b, 1], [1, 2], [:b, 1, 2], 3
|
|
97
97
|
# ```
|
|
98
98
|
class Enumerator[unchecked out Elem, out Return] < Object
|
|
99
|
-
include Enumerable[Elem
|
|
99
|
+
include Enumerable[Elem]
|
|
100
100
|
|
|
101
101
|
def each: () { (Elem arg0) -> untyped } -> Return
|
|
102
102
|
| () -> self
|
|
@@ -242,8 +242,8 @@ class Enumerator[unchecked out Elem, out Return] < Object
|
|
|
242
242
|
| [U] (U arg0) -> ::Enumerator[[ Elem, U ], Return]
|
|
243
243
|
end
|
|
244
244
|
|
|
245
|
-
class Enumerator::Generator[out Elem
|
|
246
|
-
include Enumerable[Elem
|
|
245
|
+
class Enumerator::Generator[out Elem] < Object
|
|
246
|
+
include Enumerable[Elem]
|
|
247
247
|
end
|
|
248
248
|
|
|
249
249
|
class Enumerator::Lazy[out Elem, out Return] < Enumerator[Elem, Return]
|
|
@@ -257,6 +257,6 @@ class Enumerator::Yielder < Object
|
|
|
257
257
|
def to_proc: () -> Proc
|
|
258
258
|
end
|
|
259
259
|
|
|
260
|
-
class Enumerator::Chain[out Elem
|
|
261
|
-
include Enumerable[Elem
|
|
260
|
+
class Enumerator::Chain[out Elem] < Object
|
|
261
|
+
include Enumerable[Elem]
|
|
262
262
|
end
|