rbs 2.0.0.pre1 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/comments.yml +34 -0
- data/.github/workflows/ruby.yml +5 -0
- data/CHANGELOG.md +96 -4
- data/README.md +6 -1
- data/Rakefile +52 -21
- data/core/array.rbs +2866 -1086
- data/core/basic_object.rbs +150 -30
- data/core/binding.rbs +33 -0
- data/core/builtin.rbs +4 -4
- data/core/class.rbs +43 -5
- data/core/comparable.rbs +57 -0
- data/core/complex.rbs +170 -4
- data/core/constants.rbs +51 -0
- data/core/deprecated.rbs +7 -0
- data/core/dir.rbs +305 -20
- data/core/encoding.rbs +1214 -77
- data/core/enumerable.rbs +2173 -234
- data/core/enumerator.rbs +448 -182
- data/core/env.rbs +448 -1
- data/core/errno.rbs +1 -10
- data/core/errors.rbs +152 -2
- data/core/exception.rbs +201 -127
- data/core/false_class.rbs +27 -0
- data/core/fiber.rbs +118 -37
- data/core/fiber_error.rbs +8 -9
- data/core/file.rbs +1060 -142
- data/core/file_test.rbs +287 -32
- data/core/float.rbs +776 -300
- data/core/gc.rbs +185 -34
- data/core/global_variables.rbs +5 -1
- data/core/hash.rbs +1582 -649
- data/core/integer.rbs +974 -204
- data/core/io/buffer.rbs +710 -0
- data/core/io/wait.rbs +29 -8
- data/core/io.rbs +2438 -417
- data/core/kernel.rbs +2319 -318
- data/core/marshal.rbs +37 -2
- data/core/match_data.rbs +123 -6
- data/core/math.rbs +126 -6
- data/core/method.rbs +226 -102
- data/core/module.rbs +421 -45
- data/core/nil_class.rbs +64 -0
- data/core/numeric.rbs +620 -142
- data/core/object.rbs +453 -81
- data/core/object_space.rbs +92 -2
- data/core/proc.rbs +482 -285
- data/core/process.rbs +443 -34
- data/core/ractor.rbs +232 -9
- data/core/random.rbs +151 -52
- data/core/range.rbs +885 -160
- data/core/rational.rbs +122 -6
- data/core/rb_config.rbs +14 -4
- data/core/refinement.rbs +44 -0
- data/core/regexp.rbs +156 -14
- data/core/ruby_vm.rbs +42 -3
- data/core/signal.rbs +78 -39
- data/core/string.rbs +2123 -567
- data/core/string_io.rbs +204 -0
- data/core/struct.rbs +283 -28
- data/core/symbol.rbs +304 -30
- data/core/thread.rbs +1288 -688
- data/core/thread_group.rbs +66 -10
- data/core/time.rbs +643 -217
- data/core/trace_point.rbs +100 -12
- data/core/true_class.rbs +24 -0
- data/core/unbound_method.rbs +73 -7
- data/core/warning.rbs +37 -12
- data/docs/CONTRIBUTING.md +40 -34
- data/docs/stdlib.md +3 -102
- data/docs/syntax.md +54 -11
- data/ext/rbs_extension/extconf.rb +1 -0
- data/ext/rbs_extension/lexer.h +5 -0
- data/ext/rbs_extension/lexstate.c +6 -0
- data/ext/rbs_extension/parser.c +85 -10
- data/ext/rbs_extension/ruby_objs.c +4 -2
- data/ext/rbs_extension/ruby_objs.h +2 -2
- data/goodcheck.yml +0 -11
- data/lib/rbs/annotate/annotations.rb +197 -0
- data/lib/rbs/annotate/formatter.rb +80 -0
- data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
- data/lib/rbs/annotate/rdoc_source.rb +120 -0
- data/lib/rbs/annotate.rb +6 -0
- data/lib/rbs/ast/members.rb +21 -13
- data/lib/rbs/buffer.rb +17 -11
- data/lib/rbs/cli.rb +48 -1
- data/lib/rbs/definition_builder/method_builder.rb +28 -16
- data/lib/rbs/definition_builder.rb +6 -2
- data/lib/rbs/environment.rb +8 -4
- data/lib/rbs/location_aux.rb +12 -0
- data/lib/rbs/namespace.rb +1 -1
- data/lib/rbs/prototype/rb.rb +12 -0
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +1 -1
- data/lib/rbs/validator.rb +2 -0
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +54 -4
- data/lib/rbs.rb +0 -2
- data/schema/typeParam.json +3 -3
- data/sig/annotate/annotations.rbs +102 -0
- data/sig/annotate/formatter.rbs +24 -0
- data/sig/annotate/rdoc_annotater.rbs +82 -0
- data/sig/annotate/rdoc_source.rbs +30 -0
- data/sig/buffer.rbs +6 -2
- data/sig/cli.rbs +2 -0
- data/sig/collection/{collections.rbs → sources.rbs} +0 -0
- data/sig/location.rbs +6 -0
- data/sig/members.rbs +24 -18
- data/sig/method_builder.rbs +5 -4
- data/sig/method_types.rbs +5 -1
- data/sig/polyfill.rbs +78 -0
- data/sig/writer.rbs +79 -2
- data/stdlib/abbrev/0/abbrev.rbs +6 -0
- data/stdlib/abbrev/0/array.rbs +26 -0
- data/stdlib/base64/0/base64.rbs +31 -0
- data/stdlib/benchmark/0/benchmark.rbs +74 -3
- data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
- data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
- data/stdlib/cgi/0/core.rbs +59 -0
- data/stdlib/coverage/0/coverage.rbs +164 -2
- data/stdlib/csv/0/csv.rbs +2862 -398
- data/stdlib/date/0/date.rbs +483 -25
- data/stdlib/date/0/date_time.rbs +187 -12
- data/stdlib/dbm/0/dbm.rbs +152 -17
- data/stdlib/digest/0/digest.rbs +146 -0
- data/stdlib/erb/0/erb.rbs +65 -245
- data/stdlib/fiber/0/fiber.rbs +73 -91
- data/stdlib/fileutils/0/fileutils.rbs +301 -1
- data/stdlib/find/0/find.rbs +9 -0
- data/stdlib/forwardable/0/forwardable.rbs +65 -1
- data/stdlib/io-console/0/io-console.rbs +227 -15
- data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
- data/stdlib/json/0/json.rbs +1146 -144
- data/stdlib/logger/0/formatter.rbs +24 -0
- data/stdlib/logger/0/log_device.rbs +64 -0
- data/stdlib/logger/0/logger.rbs +165 -13
- data/stdlib/logger/0/period.rbs +10 -0
- data/stdlib/logger/0/severity.rbs +26 -0
- data/stdlib/monitor/0/monitor.rbs +163 -0
- data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
- data/stdlib/net-http/0/manifest.yaml +1 -0
- data/stdlib/net-http/0/net-http.rbs +1513 -683
- data/stdlib/nkf/0/nkf.rbs +372 -0
- data/stdlib/objspace/0/objspace.rbs +149 -90
- data/stdlib/openssl/0/openssl.rbs +8108 -71
- data/stdlib/optparse/0/optparse.rbs +487 -19
- data/stdlib/pathname/0/pathname.rbs +425 -124
- data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
- data/stdlib/prime/0/integer-extension.rbs +20 -2
- data/stdlib/prime/0/prime.rbs +88 -21
- data/stdlib/pstore/0/pstore.rbs +102 -0
- data/stdlib/pty/0/pty.rbs +64 -14
- data/stdlib/resolv/0/resolv.rbs +420 -31
- data/stdlib/rubygems/0/basic_specification.rbs +4 -1
- data/stdlib/rubygems/0/config_file.rbs +33 -1
- data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
- data/stdlib/rubygems/0/installer.rbs +13 -1
- data/stdlib/rubygems/0/path_support.rbs +4 -1
- data/stdlib/rubygems/0/platform.rbs +5 -1
- data/stdlib/rubygems/0/request_set.rbs +44 -2
- data/stdlib/rubygems/0/requirement.rbs +65 -2
- data/stdlib/rubygems/0/rubygems.rbs +407 -0
- data/stdlib/rubygems/0/source_list.rbs +13 -0
- data/stdlib/rubygems/0/specification.rbs +21 -1
- data/stdlib/rubygems/0/stream_ui.rbs +3 -1
- data/stdlib/rubygems/0/uninstaller.rbs +8 -1
- data/stdlib/rubygems/0/version.rbs +60 -157
- data/stdlib/securerandom/0/securerandom.rbs +44 -0
- data/stdlib/set/0/set.rbs +420 -106
- data/stdlib/shellwords/0/shellwords.rbs +55 -77
- data/stdlib/singleton/0/singleton.rbs +20 -0
- data/stdlib/socket/0/addrinfo.rbs +210 -9
- data/stdlib/socket/0/basic_socket.rbs +103 -11
- data/stdlib/socket/0/ip_socket.rbs +31 -9
- data/stdlib/socket/0/socket.rbs +586 -38
- data/stdlib/socket/0/tcp_server.rbs +22 -2
- data/stdlib/socket/0/tcp_socket.rbs +12 -1
- data/stdlib/socket/0/udp_socket.rbs +25 -2
- data/stdlib/socket/0/unix_server.rbs +22 -2
- data/stdlib/socket/0/unix_socket.rbs +45 -5
- data/stdlib/strscan/0/string_scanner.rbs +210 -9
- data/stdlib/tempfile/0/tempfile.rbs +58 -10
- data/stdlib/time/0/time.rbs +208 -116
- data/stdlib/timeout/0/timeout.rbs +10 -0
- data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
- data/stdlib/tsort/0/cyclic.rbs +1 -0
- data/stdlib/tsort/0/interfaces.rbs +1 -0
- data/stdlib/tsort/0/tsort.rbs +42 -0
- data/stdlib/uri/0/common.rbs +57 -8
- data/stdlib/uri/0/file.rbs +55 -109
- data/stdlib/uri/0/ftp.rbs +6 -3
- data/stdlib/uri/0/generic.rbs +591 -362
- data/stdlib/uri/0/http.rbs +60 -114
- data/stdlib/uri/0/https.rbs +8 -102
- data/stdlib/uri/0/ldap.rbs +143 -137
- data/stdlib/uri/0/ldaps.rbs +8 -102
- data/stdlib/uri/0/mailto.rbs +3 -0
- data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
- data/stdlib/uri/0/ws.rbs +6 -3
- data/stdlib/uri/0/wss.rbs +5 -3
- data/stdlib/yaml/0/dbm.rbs +151 -87
- data/stdlib/yaml/0/store.rbs +6 -0
- data/stdlib/zlib/0/zlib.rbs +90 -31
- metadata +20 -8
- data/lib/rbs/location.rb +0 -221
- data/sig/char_scanner.rbs +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4afaa0d6ac4b7b74aae38aa7cd04679dad881ad073ca496aa06f272a7261cfe
|
4
|
+
data.tar.gz: 041f1bf758d156f9a968ae3cb460da45a99f80aacb2868513549687ee4e4ad76
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8891199897e1ef1574b8009bc810c0d60a1a8fbe4a9f2d5d6658b703c75d515d6e89022e5246a6196657775d8f0ea2bd44db13718a425face5d16d3e5cff38dd
|
7
|
+
data.tar.gz: faa9199018c944a87de33fc99a4bf203e73f2f24d27960d79cd92fb82aaa6be2218cae07a2bb6887ad1dee2df96e8abc7b43ec818bf11d5a40dfabf3e782f1c2
|
@@ -0,0 +1,34 @@
|
|
1
|
+
name: RBS Comments
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
pull_request: {}
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: "ubuntu-latest"
|
12
|
+
container:
|
13
|
+
image: rubylang/ruby:3.1-focal
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- name: Install dependencies
|
17
|
+
run: |
|
18
|
+
apt-get update
|
19
|
+
apt-get install -y libdb-dev
|
20
|
+
- name: Update rubygems & bundler
|
21
|
+
run: |
|
22
|
+
ruby -v
|
23
|
+
gem update --system
|
24
|
+
- name: bundle config set with
|
25
|
+
run: |
|
26
|
+
echo "NO_MINITEST=true" >> $GITHUB_ENV
|
27
|
+
bundle config set --local without 'minitest'
|
28
|
+
if: "contains(matrix.container_tag, 'master-nightly')"
|
29
|
+
- name: bin/setup
|
30
|
+
run: |
|
31
|
+
bin/setup
|
32
|
+
- name: Run test
|
33
|
+
run: |
|
34
|
+
bundle exec rake annotate confirm_annotation
|
data/.github/workflows/ruby.yml
CHANGED
@@ -13,6 +13,7 @@ jobs:
|
|
13
13
|
matrix:
|
14
14
|
container_tag:
|
15
15
|
- master-nightly-focal
|
16
|
+
- 3.1-focal
|
16
17
|
- 3.0-focal
|
17
18
|
- 2.7-bionic
|
18
19
|
- 2.6-bionic
|
@@ -27,6 +28,10 @@ jobs:
|
|
27
28
|
job: confirm_lexer
|
28
29
|
- container_tag: 2.6-bionic
|
29
30
|
job: stdlib_test
|
31
|
+
- container_tag: 2.7-bionic
|
32
|
+
job: stdlib_test
|
33
|
+
- container_tag: 3.0-focal
|
34
|
+
job: stdlib_test
|
30
35
|
container:
|
31
36
|
image: rubylang/ruby:${{ matrix.container_tag }}
|
32
37
|
steps:
|
data/CHANGELOG.md
CHANGED
@@ -2,11 +2,79 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
-
## 2.
|
5
|
+
## 2.2.0 (2022-02-22)
|
6
|
+
|
7
|
+
RBS 2.2 ships with a new syntax to specify the visibility of a method per definition bases.
|
8
|
+
|
9
|
+
```rbs
|
10
|
+
class Foo
|
11
|
+
private def hello: () -> void
|
12
|
+
|
13
|
+
private attr_accessor world: String
|
14
|
+
end
|
15
|
+
```
|
16
|
+
|
17
|
+
It also changes the semantics of `self?` method.
|
18
|
+
It defines both _public_ singleton method and _private_ instance method, which is equivalent to `module_function`.
|
19
|
+
|
20
|
+
## Signature updates
|
21
|
+
|
22
|
+
* `net-http` ([\#892](https://github.com/ruby/rbs/pull/892))
|
23
|
+
* `uri` ([\#864](https://github.com/ruby/rbs/pull/864))
|
24
|
+
* `Encoding` ([\#897](https://github.com/ruby/rbs/pull/897), [\#898](https://github.com/ruby/rbs/pull/898))
|
25
|
+
* `File::Stat` ([\#879](https://github.com/ruby/rbs/pull/879))
|
26
|
+
* `Kernel#sleep` ([\#893](https://github.com/ruby/rbs/pull/893))
|
27
|
+
|
28
|
+
### Language updates
|
29
|
+
|
30
|
+
* Add public/private per member modifier ([\#911](https://github.com/ruby/rbs/pull/911))
|
31
|
+
* Let `self?.` be equivalent to `module_function` ([\#910](https://github.com/ruby/rbs/pull/910))
|
32
|
+
|
33
|
+
### Library changes
|
34
|
+
|
35
|
+
* Add c99 flag for compiling on Ruby 2 ([\#895](https://github.com/ruby/rbs/pull/895))
|
36
|
+
* Fix incorrect URI reference in `schema/typeParam.json` ([\#891](https://github.com/ruby/rbs/pull/891))
|
37
|
+
* Allow scaffolding below namespace ([\#894](https://github.com/ruby/rbs/pull/894))
|
38
|
+
* Let `Writer` preserve format ([\#900](https://github.com/ruby/rbs/pull/900))
|
39
|
+
* Reduce memory usage of `RBS::Buffer` ([\#907](https://github.com/ruby/rbs/pull/907))
|
40
|
+
* Do not call `#class` from `#hash` to improve performance ([\#906](https://github.com/ruby/rbs/pull/906))
|
41
|
+
* Skip type variable validation if `unchcked` ([\#909](https://github.com/ruby/rbs/pull/909))
|
42
|
+
|
43
|
+
### Miscellaneous
|
44
|
+
|
45
|
+
* Add `Thread::Backtrace` and `Thread::Backtrace::Location` test ([\#896](https://github.com/ruby/rbs/pull/896))
|
46
|
+
* Test annotations ([\#902](https://github.com/ruby/rbs/pull/902))
|
47
|
+
* Remove goodcheck rule for arglists section ([\#901](https://github.com/ruby/rbs/pull/901))
|
48
|
+
* Remove `CharScanner` due to no longer used ([\#905](https://github.com/ruby/rbs/pull/905))
|
49
|
+
|
50
|
+
## 2.1.0 (2022-02-02)
|
51
|
+
|
52
|
+
RBS 2.1 is a release to deliver the types and documents of the new and updated methods of Ruby 3.1.
|
53
|
+
|
54
|
+
### Signature updates
|
55
|
+
|
56
|
+
* Documents imported from Ruby 3.1 ([\#881](https://github.com/ruby/rbs/pull/881))
|
57
|
+
* Methods/classes updated in Ruby 3.1 ([\#886](https://github.com/ruby/rbs/pull/886))
|
58
|
+
* io/wait ([\#865](https://github.com/ruby/rbs/pull/865))
|
59
|
+
* json ([\#863](https://github.com/ruby/rbs/pull/863))
|
60
|
+
* nkf ([\#873](https://github.com/ruby/rbs/pull/873))
|
61
|
+
* openssl ([\#866](https://github.com/ruby/rbs/pull/866))
|
62
|
+
* `Dir.exists?`, `FileTest#exists?` ([\#884](https://github.com/ruby/rbs/pull/884))
|
63
|
+
* `FileTest` ([\#880](https://github.com/ruby/rbs/pull/880))
|
64
|
+
* `Gem::Version#<=>` ([\#869](https://github.com/ruby/rbs/pull/869))
|
65
|
+
* `Process.clock_gettime` ([\#858](https://github.com/ruby/rbs/pull/858))
|
66
|
+
|
67
|
+
### Library changes
|
68
|
+
|
69
|
+
* Introduce `rbs annotate` command ([\#881](https://github.com/ruby/rbs/pull/881))
|
70
|
+
* Make prototype rb to be aware of prepend ([\#861](https://github.com/ruby/rbs/pull/861))
|
71
|
+
* Fixes incorrect "Invalid Variance" error when method type variable shadows outer type variable ([#889](https://github.com/ruby/rbs/pull/889))
|
72
|
+
|
73
|
+
## 2.0.0 (2021-12-24)
|
6
74
|
|
7
75
|
### Bounded Generics
|
8
76
|
|
9
|
-
RBS 2.0 ships with _bounded generics_, which improves the expressiveness of the language by adding new syntax to define
|
77
|
+
RBS 2.0 ships with _bounded generics_, which improves the expressiveness of the language by adding a new syntax to define constraints on type parameters.
|
10
78
|
|
11
79
|
```rbs
|
12
80
|
class PrettyPrint[T < _Output]
|
@@ -28,7 +96,31 @@ It means _`T` has to be compatible with `_Output` interface._
|
|
28
96
|
|
29
97
|
See [the PR for details](https://github.com/ruby/rbs/pull/844).
|
30
98
|
|
31
|
-
|
99
|
+
### RBS Collection manager
|
100
|
+
|
101
|
+
RBS Collection feature is generally available on RBS 2.0. In short, it is Bundler for RBS. You can manage RBSs of standard libraries and third party gems with `rbs collection` subcommand.
|
102
|
+
|
103
|
+
```bash
|
104
|
+
$ rbs collection init
|
105
|
+
created: rbs_collection.yaml
|
106
|
+
|
107
|
+
# The `install` command set up RBS files and creates `rbs_collection.lock.yaml` file
|
108
|
+
$ rbs collection install
|
109
|
+
Installing actionpack:6.0 (actionpack@ce6664cec73)
|
110
|
+
(...snip...)
|
111
|
+
Using tsort:0 (/path/to/rbs-2.0.0/stdlib/tsort/0)
|
112
|
+
It's done! 21 gems' RBSs now installed.
|
113
|
+
|
114
|
+
# Now you can use `rbs`, `typeprof` and `steep` commands with the dependencies out of the box!
|
115
|
+
$ rbs validate
|
116
|
+
$ typeprof app.rb
|
117
|
+
$ steep check
|
118
|
+
```
|
119
|
+
|
120
|
+
RBS 2.0 also introduces `manifest.yaml` to declare the dependencies from your gems to standard libraries explicitly.
|
121
|
+
See [the documentation](https://github.com/ruby/rbs/blob/master/docs/collection.md) for more information.
|
122
|
+
|
123
|
+
### Breaking changes
|
32
124
|
|
33
125
|
This version contains a bug fix, which potentially breaks the compatibility with older versions.
|
34
126
|
The super class names in class definitions are now resolved in _outer_ context.
|
@@ -36,7 +128,7 @@ It was an incompatibility with Ruby and [this PR](https://github.com/ruby/rbs/pu
|
|
36
128
|
|
37
129
|
### Signature updates
|
38
130
|
|
39
|
-
* uri ([\#846](https://github.com/ruby/rbs/pull/846), [\#852](https://github.com/ruby/rbs/pull/852), [\#851](https://github.com/ruby/rbs/pull/851), [\#850](https://github.com/ruby/rbs/pull/850))
|
131
|
+
* uri ([\#846](https://github.com/ruby/rbs/pull/846), [\#852](https://github.com/ruby/rbs/pull/852), [\#851](https://github.com/ruby/rbs/pull/851), [\#850](https://github.com/ruby/rbs/pull/850), [#849](https://github.com/ruby/rbs/pull/849))
|
40
132
|
|
41
133
|
### Language updates
|
42
134
|
|
data/README.md
CHANGED
@@ -52,6 +52,11 @@ end
|
|
52
52
|
```
|
53
53
|
<!-- run-end -->
|
54
54
|
|
55
|
+
## The Target Version
|
56
|
+
|
57
|
+
* The standard library signatures targets Ruby 3.1. (The latest release of Ruby.)
|
58
|
+
* The library code targets Ruby 3.1, 3.0, and 2.7. (It runs on 2.6 in fact.)
|
59
|
+
|
55
60
|
## Installation
|
56
61
|
|
57
62
|
Install the `rbs` gem. `$ gem install rbs` from the command line, or add a line in your `Gemfile`.
|
@@ -122,7 +127,7 @@ puts singleton.methods[:gsub]
|
|
122
127
|
|
123
128
|
## Guides
|
124
129
|
|
125
|
-
- [
|
130
|
+
- [Core and standard library signature contribution guide](docs/CONTRIBUTING.md)
|
126
131
|
- [Writing signatures guide](docs/sigs.md)
|
127
132
|
- [Stdlib signatures guide](docs/stdlib.md)
|
128
133
|
- [Syntax](docs/syntax.md)
|
data/Rakefile
CHANGED
@@ -34,6 +34,15 @@ rule ".c" => ".re" do |t|
|
|
34
34
|
puts "⚠️⚠️⚠️ #{t.name} is older than #{t.source}. You may need to run `rake lexer` ⚠️⚠️⚠️"
|
35
35
|
end
|
36
36
|
|
37
|
+
task :annotate do
|
38
|
+
sh "rbs annotate core stdlib"
|
39
|
+
end
|
40
|
+
|
41
|
+
task :confirm_annotation do
|
42
|
+
puts "Testing if RBS docs are updated with respect to RDoc"
|
43
|
+
sh "git diff --exit-code core stdlib"
|
44
|
+
end
|
45
|
+
|
37
46
|
task :compile => "ext/rbs_extension/lexer.c"
|
38
47
|
|
39
48
|
task :test_doc do
|
@@ -73,6 +82,7 @@ task :validate => :compile do
|
|
73
82
|
|
74
83
|
if lib == ["net-http"]
|
75
84
|
lib << "uri"
|
85
|
+
lib << "timeout"
|
76
86
|
end
|
77
87
|
|
78
88
|
if lib == ["resolv"]
|
@@ -106,17 +116,40 @@ namespace :generate do
|
|
106
116
|
raise "Class name is necessary. e.g. rake 'generate:stdlib_test[String]'"
|
107
117
|
end
|
108
118
|
|
109
|
-
path = Pathname(ENV["RBS_GENERATE_TEST_PATH"] || "test/stdlib/#{klass}_test.rb")
|
110
|
-
raise "#{path} already exists!" if path.exist?
|
111
|
-
|
112
119
|
require "erb"
|
113
120
|
require "rbs"
|
114
121
|
|
122
|
+
class TestTarget
|
123
|
+
def initialize(klass)
|
124
|
+
@type_name = RBS::Namespace.parse(klass).to_type_name
|
125
|
+
end
|
126
|
+
|
127
|
+
def path
|
128
|
+
Pathname(ENV['RBS_GENERATE_TEST_PATH'] || "test/stdlib/#{file_name}_test.rb")
|
129
|
+
end
|
130
|
+
|
131
|
+
def file_name
|
132
|
+
@type_name.to_s.gsub(/\A::/, '').gsub(/::/, '_')
|
133
|
+
end
|
134
|
+
|
135
|
+
def to_s
|
136
|
+
@type_name.to_s
|
137
|
+
end
|
138
|
+
|
139
|
+
def absolute_type_name
|
140
|
+
@absolute_type_name ||= @type_name.absolute!
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
target = TestTarget.new(klass)
|
145
|
+
path = target.path
|
146
|
+
raise "#{path} already exists!" if path.exist?
|
147
|
+
|
115
148
|
class TestTemplateBuilder
|
116
|
-
attr_reader :
|
149
|
+
attr_reader :target, :env
|
117
150
|
|
118
|
-
def initialize(
|
119
|
-
@
|
151
|
+
def initialize(target)
|
152
|
+
@target = target
|
120
153
|
|
121
154
|
loader = RBS::EnvironmentLoader.new
|
122
155
|
Dir['stdlib/*'].each do |lib|
|
@@ -132,17 +165,17 @@ namespace :generate do
|
|
132
165
|
require_relative "test_helper"
|
133
166
|
|
134
167
|
<%- unless class_methods.empty? -%>
|
135
|
-
class <%=
|
168
|
+
class <%= target %>SingletonTest < Test::Unit::TestCase
|
136
169
|
include TypeAssertions
|
137
170
|
|
138
171
|
# library "pathname", "set", "securerandom" # Declare library signatures to load
|
139
|
-
testing "singleton(::<%=
|
172
|
+
testing "singleton(::<%= target %>)"
|
140
173
|
|
141
174
|
<%- class_methods.each do |method_name, definition| %>
|
142
175
|
def test_<%= test_name_for(method_name) %>
|
143
176
|
<%- definition.method_types.each do |method_type| -%>
|
144
177
|
assert_send_type "<%= method_type %>",
|
145
|
-
<%=
|
178
|
+
<%= target %>, :<%= method_name %>
|
146
179
|
<%- end -%>
|
147
180
|
end
|
148
181
|
<%- end -%>
|
@@ -150,17 +183,17 @@ namespace :generate do
|
|
150
183
|
<%- end -%>
|
151
184
|
|
152
185
|
<%- unless instance_methods.empty? -%>
|
153
|
-
class <%=
|
186
|
+
class <%= target %>Test < Test::Unit::TestCase
|
154
187
|
include TypeAssertions
|
155
188
|
|
156
189
|
# library "pathname", "set", "securerandom" # Declare library signatures to load
|
157
|
-
testing "::<%=
|
190
|
+
testing "::<%= target %>"
|
158
191
|
|
159
192
|
<%- instance_methods.each do |method_name, definition| %>
|
160
193
|
def test_<%= test_name_for(method_name) %>
|
161
194
|
<%- definition.method_types.each do |method_type| -%>
|
162
195
|
assert_send_type "<%= method_type %>",
|
163
|
-
<%=
|
196
|
+
<%= target %>.new, :<%= method_name %>
|
164
197
|
<%- end -%>
|
165
198
|
end
|
166
199
|
<%- end -%>
|
@@ -200,24 +233,20 @@ namespace :generate do
|
|
200
233
|
}.fetch(method_name, method_name)
|
201
234
|
end
|
202
235
|
|
203
|
-
def type_name
|
204
|
-
@type_name ||= RBS::TypeName.new(name: klass.to_sym, namespace: RBS::Namespace.new(path: [], absolute: true))
|
205
|
-
end
|
206
|
-
|
207
236
|
def class_methods
|
208
|
-
@class_methods ||= RBS::DefinitionBuilder.new(env: env).build_singleton(
|
209
|
-
definition.implemented_in ==
|
237
|
+
@class_methods ||= RBS::DefinitionBuilder.new(env: env).build_singleton(target.absolute_type_name).methods.select {|_, definition|
|
238
|
+
definition.implemented_in == target.absolute_type_name
|
210
239
|
}
|
211
240
|
end
|
212
241
|
|
213
242
|
def instance_methods
|
214
|
-
@instance_methods ||= RBS::DefinitionBuilder.new(env: env).build_instance(
|
215
|
-
definition.implemented_in ==
|
243
|
+
@instance_methods ||= RBS::DefinitionBuilder.new(env: env).build_instance(target.absolute_type_name).methods.select {|_, definition|
|
244
|
+
definition.implemented_in == target.absolute_type_name
|
216
245
|
}
|
217
246
|
end
|
218
247
|
end
|
219
248
|
|
220
|
-
path.write TestTemplateBuilder.new(
|
249
|
+
path.write TestTemplateBuilder.new(target).call
|
221
250
|
|
222
251
|
puts "Created: #{path}"
|
223
252
|
end
|
@@ -226,4 +255,6 @@ end
|
|
226
255
|
task :test_generate_stdlib do
|
227
256
|
sh "RBS_GENERATE_TEST_PATH=/tmp/Array_test.rb rake 'generate:stdlib_test[Array]'"
|
228
257
|
sh "ruby -c /tmp/Array_test.rb"
|
258
|
+
sh "RBS_GENERATE_TEST_PATH=/tmp/Thread_Mutex_test.rb rake 'generate:stdlib_test[Thread::Mutex]'"
|
259
|
+
sh "ruby -c /tmp/Thread_Mutex_test.rb"
|
229
260
|
end
|