rbs 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +10 -4
  3. data/CHANGELOG.md +47 -0
  4. data/Gemfile +6 -2
  5. data/README.md +1 -1
  6. data/Rakefile +3 -4
  7. data/bin/test_runner.rb +4 -5
  8. data/core/array.rbs +2 -2
  9. data/core/complex.rbs +1 -1
  10. data/core/encoding.rbs +1 -1
  11. data/core/enumerable.rbs +15 -1
  12. data/core/file.rbs +3 -1
  13. data/core/integer.rbs +2 -1
  14. data/core/io.rbs +75 -4
  15. data/core/kernel.rbs +56 -56
  16. data/core/module.rbs +3 -3
  17. data/core/rational.rbs +2 -1
  18. data/core/string.rbs +2 -1
  19. data/core/symbol.rbs +2 -1
  20. data/core/time.rbs +2 -1
  21. data/core/unbound_method.rbs +16 -0
  22. data/docs/CONTRIBUTING.md +2 -2
  23. data/docs/stdlib.md +50 -12
  24. data/goodcheck.yml +1 -1
  25. data/lib/rbs/ast/members.rb +13 -0
  26. data/lib/rbs/definition_builder.rb +36 -25
  27. data/lib/rbs/definition_builder/method_builder.rb +9 -2
  28. data/lib/rbs/errors.rb +3 -0
  29. data/lib/rbs/parser.rb +347 -333
  30. data/lib/rbs/parser.y +12 -2
  31. data/lib/rbs/prototype/rb.rb +14 -4
  32. data/lib/rbs/test/setup_helper.rb +0 -1
  33. data/lib/rbs/version.rb +1 -1
  34. data/rbs.gemspec +1 -0
  35. data/sig/definition_builder.rbs +3 -2
  36. data/sig/members.rbs +2 -0
  37. data/stdlib/bigdecimal/0/big_decimal.rbs +1 -1
  38. data/stdlib/date/0/date.rbs +1 -1
  39. data/stdlib/fileutils/0/fileutils.rbs +585 -0
  40. data/stdlib/json/0/json.rbs +64 -0
  41. data/stdlib/pathname/0/pathname.rbs +3 -2
  42. data/stdlib/prettyprint/0/prettyprint.rbs +366 -0
  43. data/stdlib/set/0/set.rbs +7 -0
  44. data/stdlib/timeout/0/timeout.rbs +57 -0
  45. data/stdlib/uri/0/common.rbs +1 -1
  46. data/stdlib/uri/0/rfc2396_parser.rbs +144 -7
  47. data/steep/Gemfile.lock +17 -19
  48. metadata +7 -5
  49. data/core/data.rbs +0 -5
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
@@ -397,5 +397,5 @@ module Kernel
397
397
 
398
398
  # Returns `uri` converted to an URI object.
399
399
  #
400
- def URI: (URI::Generic | String uri) -> URI::Generic
400
+ def self?.URI: (URI::Generic | String uri) -> URI::Generic
401
401
  end
@@ -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.0
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-24 00:00:00.000000000 Z
11
+ date: 2021-02-12 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.
@@ -46,7 +46,6 @@ files:
46
46
  - core/comparable.rbs
47
47
  - core/complex.rbs
48
48
  - core/constants.rbs
49
- - core/data.rbs
50
49
  - core/deprecated.rbs
51
50
  - core/dir.rbs
52
51
  - core/encoding.rbs
@@ -203,6 +202,7 @@ files:
203
202
  - stdlib/dbm/0/dbm.rbs
204
203
  - stdlib/erb/0/erb.rbs
205
204
  - stdlib/fiber/0/fiber.rbs
205
+ - stdlib/fileutils/0/fileutils.rbs
206
206
  - stdlib/find/0/find.rbs
207
207
  - stdlib/forwardable/0/forwardable.rbs
208
208
  - stdlib/ipaddr/0/ipaddr.rbs
@@ -215,6 +215,7 @@ files:
215
215
  - stdlib/monitor/0/monitor.rbs
216
216
  - stdlib/mutex_m/0/mutex_m.rbs
217
217
  - stdlib/pathname/0/pathname.rbs
218
+ - stdlib/prettyprint/0/prettyprint.rbs
218
219
  - stdlib/prime/0/integer-extension.rbs
219
220
  - stdlib/prime/0/prime.rbs
220
221
  - stdlib/pstore/0/pstore.rbs
@@ -223,6 +224,7 @@ files:
223
224
  - stdlib/set/0/set.rbs
224
225
  - stdlib/singleton/0/singleton.rbs
225
226
  - stdlib/time/0/time.rbs
227
+ - stdlib/timeout/0/timeout.rbs
226
228
  - stdlib/tmpdir/0/tmpdir.rbs
227
229
  - stdlib/tsort/0/cyclic.rbs
228
230
  - stdlib/tsort/0/interfaces.rbs
@@ -257,14 +259,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
257
259
  requirements:
258
260
  - - ">="
259
261
  - !ruby/object:Gem::Version
260
- version: '0'
262
+ version: '2.6'
261
263
  required_rubygems_version: !ruby/object:Gem::Requirement
262
264
  requirements:
263
265
  - - ">="
264
266
  - !ruby/object:Gem::Version
265
267
  version: '0'
266
268
  requirements: []
267
- rubygems_version: 3.1.2
269
+ rubygems_version: 3.2.3
268
270
  signing_key:
269
271
  specification_version: 4
270
272
  summary: Type signature for Ruby.
data/core/data.rbs DELETED
@@ -1,5 +0,0 @@
1
- # This is a deprecated class, base class for C extensions using Data_Make_Struct
2
- # or Data_Wrap_Struct.
3
- #
4
- class Data < Object
5
- end