rbs 3.1.3 → 3.2.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.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +0 -6
  3. data/CHANGELOG.md +82 -0
  4. data/Gemfile +0 -6
  5. data/Gemfile.lock +12 -21
  6. data/README.md +1 -1
  7. data/Rakefile +45 -1
  8. data/Steepfile +3 -3
  9. data/core/array.rbs +0 -8
  10. data/core/binding.rbs +7 -69
  11. data/core/builtin.rbs +33 -8
  12. data/core/constants.rbs +13 -5
  13. data/core/dir.rbs +25 -25
  14. data/core/errno.rbs +474 -590
  15. data/core/exception.rbs +1 -1
  16. data/core/global_variables.rbs +27 -27
  17. data/core/io.rbs +163 -172
  18. data/core/kernel.rbs +58 -38
  19. data/core/module.rbs +34 -32
  20. data/core/object.rbs +3 -7
  21. data/core/string_io.rbs +9 -0
  22. data/core/thread.rbs +25 -1
  23. data/core/time.rbs +3 -3
  24. data/core/warning.rbs +3 -1
  25. data/docs/CONTRIBUTING.md +1 -1
  26. data/docs/rbs_by_example.md +16 -35
  27. data/docs/repo.md +1 -1
  28. data/docs/sigs.md +7 -7
  29. data/docs/stdlib.md +2 -3
  30. data/docs/syntax.md +40 -40
  31. data/lib/rbs/cli.rb +15 -4
  32. data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
  33. data/lib/rbs/collection/installer.rb +5 -2
  34. data/lib/rbs/collection/sources/stdlib.rb +5 -1
  35. data/lib/rbs/errors.rb +8 -1
  36. data/lib/rbs/file_finder.rb +1 -1
  37. data/lib/rbs/prototype/rb.rb +64 -6
  38. data/lib/rbs/prototype/rbi.rb +2 -6
  39. data/lib/rbs/prototype/runtime.rb +29 -8
  40. data/lib/rbs/subtractor.rb +17 -0
  41. data/lib/rbs/type_name.rb +4 -4
  42. data/lib/rbs/version.rb +1 -1
  43. data/rbs.gemspec +1 -1
  44. data/schema/decls.json +1 -1
  45. data/sig/errors.rbs +54 -0
  46. data/sig/parser.rbs +2 -2
  47. data/sig/prototype/rb.rbs +9 -1
  48. data/sig/subtractor.rbs +4 -0
  49. data/stdlib/logger/0/logger.rbs +1 -1
  50. data/stdlib/observable/0/observable.rbs +219 -0
  51. data/stdlib/uri/0/common.rbs +24 -0
  52. data/stdlib/zlib/0/buf_error.rbs +79 -0
  53. data/stdlib/zlib/0/data_error.rbs +79 -0
  54. data/stdlib/zlib/0/deflate.rbs +276 -0
  55. data/stdlib/zlib/0/error.rbs +89 -0
  56. data/stdlib/zlib/0/gzip_file/crc_error.rbs +115 -0
  57. data/stdlib/zlib/0/gzip_file/error.rbs +128 -0
  58. data/stdlib/zlib/0/gzip_file/length_error.rbs +115 -0
  59. data/stdlib/zlib/0/gzip_file/no_footer.rbs +114 -0
  60. data/stdlib/zlib/0/gzip_file.rbs +228 -0
  61. data/stdlib/zlib/0/gzip_reader.rbs +362 -0
  62. data/stdlib/zlib/0/gzip_writer.rbs +237 -0
  63. data/stdlib/zlib/0/inflate.rbs +249 -0
  64. data/stdlib/zlib/0/mem_error.rbs +79 -0
  65. data/stdlib/zlib/0/need_dict.rbs +82 -0
  66. data/stdlib/zlib/0/stream_end.rbs +80 -0
  67. data/stdlib/zlib/0/stream_error.rbs +80 -0
  68. data/stdlib/zlib/0/version_error.rbs +80 -0
  69. data/stdlib/zlib/0/zstream.rbs +270 -0
  70. metadata +22 -6
  71. data/stdlib/prime/0/integer-extension.rbs +0 -41
  72. data/stdlib/prime/0/manifest.yaml +0 -2
  73. data/stdlib/prime/0/prime.rbs +0 -372
data/sig/prototype/rb.rbs CHANGED
@@ -12,12 +12,18 @@ module RBS
12
12
 
13
13
  attr_accessor namespace: Namespace
14
14
 
15
- def initialize: (module_function: bool, singleton: bool, namespace: Namespace) -> void
15
+ attr_accessor in_def: bool
16
+
17
+ def initialize: (module_function: bool, singleton: bool, namespace: Namespace, in_def: bool) -> void
16
18
 
17
19
  def method_kind: () -> method_kind
18
20
 
19
21
  def attribute_kind: () -> (:singleton | :instance)
20
22
 
23
+ def enter_namespace: (Namespace) -> Context
24
+
25
+ def update: (?module_function: bool, ?singleton: bool, ?in_def: bool) -> Context
26
+
21
27
  def self.initial: (?namespace: Namespace) -> Context
22
28
  end
23
29
 
@@ -83,6 +89,8 @@ module RBS
83
89
  def is_accessibility?: (decl) -> bool
84
90
 
85
91
  def find_def_index_by_name: (Array[decl] decls, Symbol name) -> [Integer, AST::Members::MethodDefinition | AST::Members::AttrReader | AST::Members::AttrWriter]?
92
+
93
+ def sort_members!: (Array[decl] decls) -> void
86
94
  end
87
95
  end
88
96
  end
data/sig/subtractor.rbs CHANGED
@@ -24,6 +24,10 @@ module RBS
24
24
 
25
25
  private def mixin_exist?: (TypeName owner, AST::Members::Include | AST::Members::Extend | AST::Members::Prepend, context: Resolver::context) -> boolish
26
26
 
27
+ private def filter_redundunt_access_modifiers: (Array[AST::Declarations::t | AST::Members::t]) -> Array[AST::Declarations::t | AST::Members::t]
28
+
29
+ private def access_modifier?: (AST::Declarations::t | AST::Members::t?) -> bool
30
+
27
31
  private def update_decl: (decl_with_members, members: Array[AST::Declarations::t | AST::Members::t]) -> decl_with_members
28
32
 
29
33
  private def absolute_typename: (TypeName, context: Resolver::context) -> TypeName
@@ -796,7 +796,7 @@ class Logger
796
796
  # periodic log file rotation; default is `'%Y%m%d'`. See [Periodic
797
797
  # Rotation](rdoc-ref:Logger@Periodic+Rotation).
798
798
  #
799
- def initialize: (logdev logdev, ?Numeric | String shift_age, ?Integer shift_size, ?shift_period_suffix: String, ?binmode: boolish, ?datetime_format: String, ?formatter: _Formatter, ?progname: String, ?level: Integer | String | Symbol) -> void
799
+ def initialize: (logdev? logdev, ?Numeric | String shift_age, ?Integer shift_size, ?shift_period_suffix: String, ?binmode: boolish, ?datetime_format: String, ?formatter: _Formatter, ?progname: String, ?level: Integer | String | Symbol) -> void
800
800
  end
801
801
 
802
802
  Logger::ProgName: String
@@ -0,0 +1,219 @@
1
+ # <!-- rdoc-file=lib/observer.rb -->
2
+ # The Observer pattern (also known as publish/subscribe) provides a simple
3
+ # mechanism for one object to inform a set of interested third-party objects
4
+ # when its state changes.
5
+ #
6
+ # ## Mechanism
7
+ #
8
+ # The notifying class mixes in the `Observable` module, which provides the
9
+ # methods for managing the associated observer objects.
10
+ #
11
+ # The observable object must:
12
+ # * assert that it has `#changed`
13
+ # * call `#notify_observers`
14
+ #
15
+ #
16
+ # An observer subscribes to updates using Observable#add_observer, which also
17
+ # specifies the method called via #notify_observers. The default method for
18
+ # #notify_observers is #update.
19
+ #
20
+ # ### Example
21
+ #
22
+ # The following example demonstrates this nicely. A `Ticker`, when run,
23
+ # continually receives the stock `Price` for its `@symbol`. A `Warner` is a
24
+ # general observer of the price, and two warners are demonstrated, a `WarnLow`
25
+ # and a `WarnHigh`, which print a warning if the price is below or above their
26
+ # set limits, respectively.
27
+ #
28
+ # The `update` callback allows the warners to run without being explicitly
29
+ # called. The system is set up with the `Ticker` and several observers, and the
30
+ # observers do their duty without the top-level code having to interfere.
31
+ #
32
+ # Note that the contract between publisher and subscriber (observable and
33
+ # observer) is not declared or enforced. The `Ticker` publishes a time and a
34
+ # price, and the warners receive that. But if you don't ensure that your
35
+ # contracts are correct, nothing else can warn you.
36
+ #
37
+ # require "observer"
38
+ #
39
+ # class Ticker ### Periodically fetch a stock price.
40
+ # include Observable
41
+ #
42
+ # def initialize(symbol)
43
+ # @symbol = symbol
44
+ # end
45
+ #
46
+ # def run
47
+ # last_price = nil
48
+ # loop do
49
+ # price = Price.fetch(@symbol)
50
+ # print "Current price: #{price}\n"
51
+ # if price != last_price
52
+ # changed # notify observers
53
+ # last_price = price
54
+ # notify_observers(Time.now, price)
55
+ # end
56
+ # sleep 1
57
+ # end
58
+ # end
59
+ # end
60
+ #
61
+ # class Price ### A mock class to fetch a stock price (60 - 140).
62
+ # def self.fetch(symbol)
63
+ # 60 + rand(80)
64
+ # end
65
+ # end
66
+ #
67
+ # class Warner ### An abstract observer of Ticker objects.
68
+ # def initialize(ticker, limit)
69
+ # @limit = limit
70
+ # ticker.add_observer(self)
71
+ # end
72
+ # end
73
+ #
74
+ # class WarnLow < Warner
75
+ # def update(time, price) # callback for observer
76
+ # if price < @limit
77
+ # print "--- #{time.to_s}: Price below #@limit: #{price}\n"
78
+ # end
79
+ # end
80
+ # end
81
+ #
82
+ # class WarnHigh < Warner
83
+ # def update(time, price) # callback for observer
84
+ # if price > @limit
85
+ # print "+++ #{time.to_s}: Price above #@limit: #{price}\n"
86
+ # end
87
+ # end
88
+ # end
89
+ #
90
+ # ticker = Ticker.new("MSFT")
91
+ # WarnLow.new(ticker, 80)
92
+ # WarnHigh.new(ticker, 120)
93
+ # ticker.run
94
+ #
95
+ # Produces:
96
+ #
97
+ # Current price: 83
98
+ # Current price: 75
99
+ # --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 75
100
+ # Current price: 90
101
+ # Current price: 134
102
+ # +++ Sun Jun 09 00:10:25 CDT 2002: Price above 120: 134
103
+ # Current price: 134
104
+ # Current price: 112
105
+ # Current price: 79
106
+ # --- Sun Jun 09 00:10:25 CDT 2002: Price below 80: 79
107
+ #
108
+ # ### Usage with procs
109
+ #
110
+ # The `#notify_observers` method can also be used with +proc+s by using the
111
+ # `:call` as `func` parameter.
112
+ #
113
+ # The following example illustrates the use of a lambda:
114
+ #
115
+ # require 'observer'
116
+ #
117
+ # class Ticker
118
+ # include Observable
119
+ #
120
+ # def run
121
+ # # logic to retrieve the price (here 77.0)
122
+ # changed
123
+ # notify_observers(77.0)
124
+ # end
125
+ # end
126
+ #
127
+ # ticker = Ticker.new
128
+ # warner = ->(price) { puts "New price received: #{price}" }
129
+ # ticker.add_observer(warner, :call)
130
+ # ticker.run
131
+ #
132
+ module Observable
133
+ public
134
+
135
+ # <!--
136
+ # rdoc-file=lib/observer.rb
137
+ # - add_observer(observer, func=:update)
138
+ # -->
139
+ # Add `observer` as an observer on this object. So that it will receive
140
+ # notifications.
141
+ #
142
+ # `observer`
143
+ # : the object that will be notified of changes.
144
+ # `func`
145
+ # : Symbol naming the method that will be called when this Observable has
146
+ # changes.
147
+ #
148
+ # This method must return true for `observer.respond_to?` and will receive
149
+ # `*arg` when #notify_observers is called, where `*arg` is the value passed
150
+ # to #notify_observers by this Observable
151
+ #
152
+ def add_observer: (untyped observer, ?Symbol func) -> void
153
+
154
+ # <!--
155
+ # rdoc-file=lib/observer.rb
156
+ # - changed(state=true)
157
+ # -->
158
+ # Set the changed state of this object. Notifications will be sent only if the
159
+ # changed `state` is `true`.
160
+ #
161
+ # `state`
162
+ # : Boolean indicating the changed state of this Observable.
163
+ #
164
+ def changed: (?bool state) -> void
165
+
166
+ # <!--
167
+ # rdoc-file=lib/observer.rb
168
+ # - changed?()
169
+ # -->
170
+ # Returns true if this object's state has been changed since the last
171
+ # #notify_observers call.
172
+ #
173
+ def changed?: () -> bool
174
+
175
+ # <!--
176
+ # rdoc-file=lib/observer.rb
177
+ # - count_observers()
178
+ # -->
179
+ # Return the number of observers associated with this object.
180
+ #
181
+ def count_observers: () -> Integer
182
+
183
+ # <!--
184
+ # rdoc-file=lib/observer.rb
185
+ # - delete_observer(observer)
186
+ # -->
187
+ # Remove `observer` as an observer on this object so that it will no longer
188
+ # receive notifications.
189
+ #
190
+ # `observer`
191
+ # : An observer of this Observable
192
+ #
193
+ def delete_observer: (untyped observer) -> void
194
+
195
+ # <!--
196
+ # rdoc-file=lib/observer.rb
197
+ # - delete_observers()
198
+ # -->
199
+ # Remove all observers associated with this object.
200
+ #
201
+ def delete_observers: () -> void
202
+
203
+ # <!--
204
+ # rdoc-file=lib/observer.rb
205
+ # - notify_observers(*arg)
206
+ # -->
207
+ # Notify observers of a change in state **if** this object's changed state is
208
+ # `true`.
209
+ #
210
+ # This will invoke the method named in #add_observer, passing `*arg`. The
211
+ # changed state is then set to `false`.
212
+ #
213
+ # `*arg`
214
+ # : Any arguments to pass to the observers.
215
+ #
216
+ def notify_observers: (*untyped arg) -> void
217
+
218
+ VERSION: String
219
+ end
@@ -1,3 +1,27 @@
1
+ # <!-- rdoc-file=lib/uri/common.rb -->
2
+ # Base class for all URI exceptions.
3
+ #
4
+ class URI::Error < StandardError
5
+ end
6
+
7
+ # <!-- rdoc-file=lib/uri/common.rb -->
8
+ # Not a URI.
9
+ #
10
+ class URI::InvalidURIError < URI::Error
11
+ end
12
+
13
+ # <!-- rdoc-file=lib/uri/common.rb -->
14
+ # Not a URI component.
15
+ #
16
+ class URI::InvalidComponentError < URI::Error
17
+ end
18
+
19
+ # <!-- rdoc-file=lib/uri/common.rb -->
20
+ # URI is valid, bad usage is not.
21
+ #
22
+ class URI::BadURIError < URI::Error
23
+ end
24
+
1
25
  # <!-- rdoc-file=lib/uri.rb -->
2
26
  # URI is a module providing classes to handle Uniform Resource Identifiers
3
27
  # ([RFC2396](http://tools.ietf.org/html/rfc2396)).
@@ -0,0 +1,79 @@
1
+ # <!-- rdoc-file=ext/zlib/zlib.c -->
2
+ # This module provides access to the [zlib library](http://zlib.net). Zlib is
3
+ # designed to be a portable, free, general-purpose, legally unencumbered -- that
4
+ # is, not covered by any patents -- lossless data-compression library for use on
5
+ # virtually any computer hardware and operating system.
6
+ #
7
+ # The zlib compression library provides in-memory compression and decompression
8
+ # functions, including integrity checks of the uncompressed data.
9
+ #
10
+ # The zlib compressed data format is described in RFC 1950, which is a wrapper
11
+ # around a deflate stream which is described in RFC 1951.
12
+ #
13
+ # The library also supports reading and writing files in gzip (.gz) format with
14
+ # an interface similar to that of IO. The gzip format is described in RFC 1952
15
+ # which is also a wrapper around a deflate stream.
16
+ #
17
+ # The zlib format was designed to be compact and fast for use in memory and on
18
+ # communications channels. The gzip format was designed for single-file
19
+ # compression on file systems, has a larger header than zlib to maintain
20
+ # directory information, and uses a different, slower check method than zlib.
21
+ #
22
+ # See your system's zlib.h for further information about zlib
23
+ #
24
+ # ## Sample usage
25
+ #
26
+ # Using the wrapper to compress strings with default parameters is quite simple:
27
+ #
28
+ # require "zlib"
29
+ #
30
+ # data_to_compress = File.read("don_quixote.txt")
31
+ #
32
+ # puts "Input size: #{data_to_compress.size}"
33
+ # #=> Input size: 2347740
34
+ #
35
+ # data_compressed = Zlib::Deflate.deflate(data_to_compress)
36
+ #
37
+ # puts "Compressed size: #{data_compressed.size}"
38
+ # #=> Compressed size: 887238
39
+ #
40
+ # uncompressed_data = Zlib::Inflate.inflate(data_compressed)
41
+ #
42
+ # puts "Uncompressed data is: #{uncompressed_data}"
43
+ # #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
44
+ #
45
+ # ## Class tree
46
+ #
47
+ # * Zlib::Deflate
48
+ # * Zlib::Inflate
49
+ # * Zlib::ZStream
50
+ # * Zlib::Error
51
+ # * Zlib::StreamEnd
52
+ # * Zlib::NeedDict
53
+ # * Zlib::DataError
54
+ # * Zlib::StreamError
55
+ # * Zlib::MemError
56
+ # * Zlib::BufError
57
+ # * Zlib::VersionError
58
+ # * Zlib::InProgressError
59
+ #
60
+ #
61
+ #
62
+ # (if you have GZIP_SUPPORT)
63
+ # * Zlib::GzipReader
64
+ # * Zlib::GzipWriter
65
+ # * Zlib::GzipFile
66
+ # * Zlib::GzipFile::Error
67
+ # * Zlib::GzipFile::LengthError
68
+ # * Zlib::GzipFile::CRCError
69
+ # * Zlib::GzipFile::NoFooter
70
+ #
71
+ module Zlib
72
+ # <!-- rdoc-file=ext/zlib/zlib.c -->
73
+ # Subclass of Zlib::Error when zlib returns a Z_BUF_ERROR.
74
+ #
75
+ # Usually if no progress is possible.
76
+ #
77
+ class BufError < Zlib::Error
78
+ end
79
+ end
@@ -0,0 +1,79 @@
1
+ # <!-- rdoc-file=ext/zlib/zlib.c -->
2
+ # This module provides access to the [zlib library](http://zlib.net). Zlib is
3
+ # designed to be a portable, free, general-purpose, legally unencumbered -- that
4
+ # is, not covered by any patents -- lossless data-compression library for use on
5
+ # virtually any computer hardware and operating system.
6
+ #
7
+ # The zlib compression library provides in-memory compression and decompression
8
+ # functions, including integrity checks of the uncompressed data.
9
+ #
10
+ # The zlib compressed data format is described in RFC 1950, which is a wrapper
11
+ # around a deflate stream which is described in RFC 1951.
12
+ #
13
+ # The library also supports reading and writing files in gzip (.gz) format with
14
+ # an interface similar to that of IO. The gzip format is described in RFC 1952
15
+ # which is also a wrapper around a deflate stream.
16
+ #
17
+ # The zlib format was designed to be compact and fast for use in memory and on
18
+ # communications channels. The gzip format was designed for single-file
19
+ # compression on file systems, has a larger header than zlib to maintain
20
+ # directory information, and uses a different, slower check method than zlib.
21
+ #
22
+ # See your system's zlib.h for further information about zlib
23
+ #
24
+ # ## Sample usage
25
+ #
26
+ # Using the wrapper to compress strings with default parameters is quite simple:
27
+ #
28
+ # require "zlib"
29
+ #
30
+ # data_to_compress = File.read("don_quixote.txt")
31
+ #
32
+ # puts "Input size: #{data_to_compress.size}"
33
+ # #=> Input size: 2347740
34
+ #
35
+ # data_compressed = Zlib::Deflate.deflate(data_to_compress)
36
+ #
37
+ # puts "Compressed size: #{data_compressed.size}"
38
+ # #=> Compressed size: 887238
39
+ #
40
+ # uncompressed_data = Zlib::Inflate.inflate(data_compressed)
41
+ #
42
+ # puts "Uncompressed data is: #{uncompressed_data}"
43
+ # #=> Uncompressed data is: The Project Gutenberg EBook of Don Quixote...
44
+ #
45
+ # ## Class tree
46
+ #
47
+ # * Zlib::Deflate
48
+ # * Zlib::Inflate
49
+ # * Zlib::ZStream
50
+ # * Zlib::Error
51
+ # * Zlib::StreamEnd
52
+ # * Zlib::NeedDict
53
+ # * Zlib::DataError
54
+ # * Zlib::StreamError
55
+ # * Zlib::MemError
56
+ # * Zlib::BufError
57
+ # * Zlib::VersionError
58
+ # * Zlib::InProgressError
59
+ #
60
+ #
61
+ #
62
+ # (if you have GZIP_SUPPORT)
63
+ # * Zlib::GzipReader
64
+ # * Zlib::GzipWriter
65
+ # * Zlib::GzipFile
66
+ # * Zlib::GzipFile::Error
67
+ # * Zlib::GzipFile::LengthError
68
+ # * Zlib::GzipFile::CRCError
69
+ # * Zlib::GzipFile::NoFooter
70
+ #
71
+ module Zlib
72
+ # <!-- rdoc-file=ext/zlib/zlib.c -->
73
+ # Subclass of Zlib::Error when zlib returns a Z_DATA_ERROR.
74
+ #
75
+ # Usually if a stream was prematurely freed.
76
+ #
77
+ class DataError < Zlib::Error
78
+ end
79
+ end