steep 0.13.0 → 0.16.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +0 -3
  3. data/CHANGELOG.md +28 -0
  4. data/Rakefile +0 -13
  5. data/bin/setup +0 -2
  6. data/bin/smoke_runner.rb +0 -1
  7. data/exe/steep +0 -1
  8. data/lib/steep.rb +33 -1
  9. data/lib/steep/annotation_parser.rb +4 -4
  10. data/lib/steep/ast/buffer.rb +11 -7
  11. data/lib/steep/ast/builtin.rb +8 -0
  12. data/lib/steep/ast/types/factory.rb +124 -89
  13. data/lib/steep/cli.rb +16 -1
  14. data/lib/steep/drivers/annotations.rb +1 -1
  15. data/lib/steep/drivers/check.rb +20 -4
  16. data/lib/steep/drivers/init.rb +5 -5
  17. data/lib/steep/drivers/langserver.rb +13 -287
  18. data/lib/steep/drivers/utils/driver_helper.rb +1 -1
  19. data/lib/steep/drivers/vendor.rb +2 -2
  20. data/lib/steep/drivers/watch.rb +97 -85
  21. data/lib/steep/drivers/worker.rb +51 -0
  22. data/lib/steep/project.rb +9 -5
  23. data/lib/steep/project/completion_provider.rb +298 -0
  24. data/lib/steep/project/dsl.rb +14 -0
  25. data/lib/steep/project/file.rb +54 -47
  26. data/lib/steep/project/hover_content.rb +17 -8
  27. data/lib/steep/project/options.rb +25 -3
  28. data/lib/steep/project/target.rb +40 -24
  29. data/lib/steep/server/base_worker.rb +56 -0
  30. data/lib/steep/server/code_worker.rb +151 -0
  31. data/lib/steep/server/interaction_worker.rb +281 -0
  32. data/lib/steep/server/master.rb +196 -0
  33. data/lib/steep/server/signature_worker.rb +148 -0
  34. data/lib/steep/server/utils.rb +36 -0
  35. data/lib/steep/server/worker_process.rb +62 -0
  36. data/lib/steep/signature/errors.rb +1 -1
  37. data/lib/steep/signature/validator.rb +13 -13
  38. data/lib/steep/source.rb +1 -1
  39. data/lib/steep/type_construction.rb +1004 -727
  40. data/lib/steep/type_inference/constant_env.rb +3 -11
  41. data/lib/steep/type_inference/context.rb +8 -3
  42. data/lib/steep/type_inference/context_array.rb +111 -0
  43. data/lib/steep/type_inference/local_variable_type_env.rb +226 -0
  44. data/lib/steep/type_inference/logic.rb +130 -0
  45. data/lib/steep/type_inference/type_env.rb +5 -69
  46. data/lib/steep/typing.rb +91 -23
  47. data/lib/steep/version.rb +1 -1
  48. data/smoke/alias/Steepfile +1 -0
  49. data/smoke/alias/a.rb +1 -1
  50. data/smoke/and/Steepfile +1 -0
  51. data/smoke/array/Steepfile +1 -0
  52. data/smoke/array/b.rb +0 -2
  53. data/smoke/block/Steepfile +1 -0
  54. data/smoke/case/Steepfile +1 -0
  55. data/smoke/class/Steepfile +1 -0
  56. data/smoke/const/Steepfile +1 -0
  57. data/smoke/dstr/Steepfile +1 -0
  58. data/smoke/ensure/Steepfile +1 -0
  59. data/smoke/enumerator/Steepfile +1 -0
  60. data/smoke/extension/Steepfile +1 -0
  61. data/smoke/extension/c.rb +1 -0
  62. data/smoke/hash/Steepfile +1 -0
  63. data/smoke/hello/Steepfile +1 -0
  64. data/smoke/if/Steepfile +1 -0
  65. data/smoke/if/a.rb +1 -1
  66. data/smoke/implements/Steepfile +1 -0
  67. data/smoke/initialize/Steepfile +1 -0
  68. data/smoke/integer/Steepfile +1 -0
  69. data/smoke/interface/Steepfile +1 -0
  70. data/smoke/kwbegin/Steepfile +1 -0
  71. data/smoke/lambda/Steepfile +1 -0
  72. data/smoke/literal/Steepfile +1 -0
  73. data/smoke/map/Steepfile +1 -0
  74. data/smoke/method/Steepfile +1 -0
  75. data/smoke/module/Steepfile +1 -0
  76. data/smoke/regexp/Steepfile +1 -0
  77. data/smoke/regexp/b.rb +4 -4
  78. data/smoke/regression/Steepfile +1 -0
  79. data/smoke/rescue/Steepfile +1 -0
  80. data/smoke/rescue/a.rb +1 -1
  81. data/smoke/self/Steepfile +1 -0
  82. data/smoke/skip/Steepfile +1 -0
  83. data/smoke/stdout/Steepfile +1 -0
  84. data/smoke/super/Steepfile +1 -0
  85. data/smoke/type_case/Steepfile +1 -0
  86. data/smoke/yield/Steepfile +1 -0
  87. data/steep.gemspec +8 -8
  88. metadata +38 -138
  89. data/exe/rbs +0 -3
  90. data/exe/ruby-signature +0 -3
  91. data/vendor/ruby-signature/.github/workflows/ruby.yml +0 -27
  92. data/vendor/ruby-signature/.gitignore +0 -12
  93. data/vendor/ruby-signature/.rubocop.yml +0 -15
  94. data/vendor/ruby-signature/BSDL +0 -22
  95. data/vendor/ruby-signature/COPYING +0 -56
  96. data/vendor/ruby-signature/Gemfile +0 -6
  97. data/vendor/ruby-signature/README.md +0 -93
  98. data/vendor/ruby-signature/Rakefile +0 -66
  99. data/vendor/ruby-signature/bin/annotate-with-rdoc +0 -156
  100. data/vendor/ruby-signature/bin/console +0 -14
  101. data/vendor/ruby-signature/bin/query-rdoc +0 -103
  102. data/vendor/ruby-signature/bin/setup +0 -10
  103. data/vendor/ruby-signature/bin/sort +0 -88
  104. data/vendor/ruby-signature/bin/test_runner.rb +0 -17
  105. data/vendor/ruby-signature/docs/CONTRIBUTING.md +0 -97
  106. data/vendor/ruby-signature/docs/sigs.md +0 -148
  107. data/vendor/ruby-signature/docs/stdlib.md +0 -152
  108. data/vendor/ruby-signature/docs/syntax.md +0 -528
  109. data/vendor/ruby-signature/exe/rbs +0 -3
  110. data/vendor/ruby-signature/exe/ruby-signature +0 -7
  111. data/vendor/ruby-signature/lib/ruby/signature.rb +0 -64
  112. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +0 -29
  113. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +0 -29
  114. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +0 -391
  115. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +0 -364
  116. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +0 -52
  117. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +0 -54
  118. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +0 -534
  119. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +0 -28
  120. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +0 -152
  121. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +0 -172
  122. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +0 -921
  123. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +0 -283
  124. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +0 -138
  125. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +0 -126
  126. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +0 -189
  127. data/vendor/ruby-signature/lib/ruby/signature/location.rb +0 -104
  128. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +0 -125
  129. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +0 -93
  130. data/vendor/ruby-signature/lib/ruby/signature/parser.y +0 -1343
  131. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +0 -441
  132. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +0 -579
  133. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +0 -383
  134. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +0 -48
  135. data/vendor/ruby-signature/lib/ruby/signature/test.rb +0 -28
  136. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +0 -63
  137. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +0 -290
  138. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +0 -58
  139. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +0 -324
  140. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +0 -185
  141. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +0 -256
  142. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +0 -72
  143. data/vendor/ruby-signature/lib/ruby/signature/types.rb +0 -932
  144. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +0 -140
  145. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +0 -49
  146. data/vendor/ruby-signature/lib/ruby/signature/version.rb +0 -5
  147. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +0 -271
  148. data/vendor/ruby-signature/ruby-signature.gemspec +0 -45
  149. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +0 -3
  150. data/vendor/ruby-signature/stdlib/base64/base64.rbs +0 -15
  151. data/vendor/ruby-signature/stdlib/builtin/array.rbs +0 -1997
  152. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +0 -280
  153. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +0 -177
  154. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +0 -35
  155. data/vendor/ruby-signature/stdlib/builtin/class.rbs +0 -145
  156. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +0 -116
  157. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +0 -400
  158. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +0 -37
  159. data/vendor/ruby-signature/stdlib/builtin/data.rbs +0 -5
  160. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +0 -2
  161. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +0 -419
  162. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +0 -606
  163. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +0 -404
  164. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +0 -260
  165. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +0 -781
  166. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +0 -582
  167. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +0 -193
  168. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +0 -40
  169. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +0 -68
  170. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +0 -12
  171. data/vendor/ruby-signature/stdlib/builtin/file.rbs +0 -476
  172. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +0 -59
  173. data/vendor/ruby-signature/stdlib/builtin/float.rbs +0 -696
  174. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +0 -121
  175. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +0 -1029
  176. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +0 -710
  177. data/vendor/ruby-signature/stdlib/builtin/io.rbs +0 -683
  178. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +0 -574
  179. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +0 -135
  180. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +0 -141
  181. data/vendor/ruby-signature/stdlib/builtin/math.rbs +0 -66
  182. data/vendor/ruby-signature/stdlib/builtin/method.rbs +0 -182
  183. data/vendor/ruby-signature/stdlib/builtin/module.rbs +0 -248
  184. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +0 -82
  185. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +0 -409
  186. data/vendor/ruby-signature/stdlib/builtin/object.rbs +0 -824
  187. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +0 -426
  188. data/vendor/ruby-signature/stdlib/builtin/process.rbs +0 -354
  189. data/vendor/ruby-signature/stdlib/builtin/random.rbs +0 -93
  190. data/vendor/ruby-signature/stdlib/builtin/range.rbs +0 -226
  191. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +0 -424
  192. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +0 -10
  193. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +0 -131
  194. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +0 -14
  195. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +0 -55
  196. data/vendor/ruby-signature/stdlib/builtin/string.rbs +0 -770
  197. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +0 -13
  198. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +0 -40
  199. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +0 -230
  200. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +0 -1112
  201. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +0 -23
  202. data/vendor/ruby-signature/stdlib/builtin/time.rbs +0 -739
  203. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +0 -91
  204. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +0 -46
  205. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +0 -159
  206. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +0 -17
  207. data/vendor/ruby-signature/stdlib/erb/erb.rbs +0 -18
  208. data/vendor/ruby-signature/stdlib/find/find.rbs +0 -44
  209. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +0 -21
  210. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +0 -23
  211. data/vendor/ruby-signature/stdlib/prime/prime.rbs +0 -188
  212. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +0 -9
  213. data/vendor/ruby-signature/stdlib/set/set.rbs +0 -77
  214. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +0 -53
@@ -1,683 +0,0 @@
1
- # The [IO](IO) class is the basis for all input and
2
- # output in Ruby. An I/O stream may be *duplexed* (that is,
3
- # bidirectional), and so may use more than one native operating system
4
- # stream.
5
- #
6
- # Many of the examples in this section use the
7
- # [File](https://ruby-doc.org/core-2.6.3/File.html) class, the only
8
- # standard subclass of [IO](IO). The two classes are
9
- # closely associated. Like the
10
- # [File](https://ruby-doc.org/core-2.6.3/File.html) class, the Socket
11
- # library subclasses from [IO](IO) (such as TCPSocket
12
- # or UDPSocket).
13
- #
14
- # The
15
- # [Kernel\#open](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-open)
16
- # method can create an [IO](IO) (or
17
- # [File](https://ruby-doc.org/core-2.6.3/File.html) ) object for these
18
- # types of arguments:
19
- #
20
- # - A plain string represents a filename suitable for the underlying
21
- # operating system.
22
- #
23
- # - A string starting with `"|"` indicates a subprocess. The remainder
24
- # of the string following the `"|"` is invoked as a process with
25
- # appropriate input/output channels connected to it.
26
- #
27
- # - A string equal to `"|-"` will create another Ruby instance as a
28
- # subprocess.
29
- #
30
- # The [IO](IO) may be opened with different file modes
31
- # (read-only, write-only) and encodings for proper conversion. See
32
- # [::new](IO#method-c-new) for these options. See
33
- # [Kernel\#open](https://ruby-doc.org/core-2.6.3/Kernel.html#method-i-open)
34
- # for details of the various command formats described above.
35
- #
36
- # [::popen](IO#method-c-popen), the Open3 library, or
37
- # Process\#spawn may also be used to communicate with subprocesses through
38
- # an [IO](IO).
39
- #
40
- # Ruby will convert pathnames between different operating system
41
- # conventions if possible. For instance, on a Windows system the filename
42
- # `"/gumby/ruby/test.rb"` will be opened as `"\gumby\ruby\test.rb"` . When
43
- # specifying a Windows-style filename in a Ruby string, remember to escape
44
- # the backslashes:
45
- #
46
- # ```ruby
47
- # "C:\\gumby\\ruby\\test.rb"
48
- # ```
49
- #
50
- # Our examples here will use the Unix-style forward slashes;
51
- # File::ALT\_SEPARATOR can be used to get the platform-specific separator
52
- # character.
53
- #
54
- # The global constant [ARGF](https://ruby-doc.org/core-2.6.3/ARGF.html)
55
- # (also accessible as `$<` ) provides an IO-like stream which allows
56
- # access to all files mentioned on the command line (or STDIN if no files
57
- # are mentioned).
58
- # [ARGF\#path](https://ruby-doc.org/core-2.6.3/ARGF.html#method-i-path)
59
- # and its alias
60
- # [ARGF\#filename](https://ruby-doc.org/core-2.6.3/ARGF.html#method-i-filename)
61
- # are provided to access the name of the file currently being read.
62
- #
63
- #
64
- # The io/console extension provides methods for interacting with the
65
- # console. The console can be accessed from IO.console or the standard
66
- # input/output/error [IO](IO) objects.
67
- #
68
- # Requiring io/console adds the following methods:
69
- #
70
- # - IO::console
71
- #
72
- # - IO\#raw
73
- #
74
- # - IO\#raw\!
75
- #
76
- # - IO\#cooked
77
- #
78
- # - IO\#cooked\!
79
- #
80
- # - IO\#getch
81
- #
82
- # - IO\#echo=
83
- #
84
- # - IO\#echo?
85
- #
86
- # - IO\#noecho
87
- #
88
- # - IO\#winsize
89
- #
90
- # - IO\#winsize=
91
- #
92
- # - IO\#iflush
93
- #
94
- # - IO\#ioflush
95
- #
96
- # - IO\#oflush
97
- #
98
- # Example:
99
- #
100
- # ```ruby
101
- # require 'io/console'
102
- # rows, columns = $stdout.winsize
103
- # puts "Your screen is #{columns} wide and #{rows} tall"
104
- # ```
105
- class IO < Object
106
- include File::Constants
107
-
108
- include Enumerable[String, IO]
109
-
110
- def <<: (untyped arg0) -> self
111
-
112
- def advise: (Symbol arg0, ?Integer offset, ?Integer len) -> NilClass
113
-
114
- def autoclose=: (bool arg0) -> bool
115
-
116
- # Returns `true` if the underlying file descriptor of *ios* will be closed
117
- # automatically at its finalization, otherwise `false` .
118
- def autoclose?: () -> bool
119
-
120
- # Puts *ios* into binary mode. Once a stream is in binary mode, it cannot
121
- # be reset to nonbinary mode.
122
- #
123
- # - newline conversion disabled
124
- #
125
- # - encoding conversion disabled
126
- #
127
- # - content is treated as ASCII-8BIT
128
- def binmode: () -> self
129
-
130
- # Returns `true` if *ios* is binmode.
131
- def binmode?: () -> bool
132
-
133
- # Closes *ios* and flushes any pending writes to the operating system. The
134
- # stream is unavailable for any further data operations; an `IOError` is
135
- # raised if such an attempt is made. I/O streams are automatically closed
136
- # when they are claimed by the garbage collector.
137
- #
138
- # If *ios* is opened by `IO.popen`, `close` sets `$?` .
139
- #
140
- # Calling this method on closed [IO](IO.downloaded.ruby_doc) object is
141
- # just ignored since Ruby 2.3.
142
- def close: () -> NilClass
143
-
144
- def close_on_exec=: (bool arg0) -> bool
145
-
146
- # Returns `true` if *ios* will be closed on exec.
147
- #
148
- # ```ruby
149
- # f = open("/dev/null")
150
- # f.close_on_exec? #=> false
151
- # f.close_on_exec = true
152
- # f.close_on_exec? #=> true
153
- # f.close_on_exec = false
154
- # f.close_on_exec? #=> false
155
- # ```
156
- def close_on_exec?: () -> bool
157
-
158
- # Closes the read end of a duplex I/O stream (i.e., one that contains both
159
- # a read and a write stream, such as a pipe). Will raise an `IOError` if
160
- # the stream is not duplexed.
161
- #
162
- # ```ruby
163
- # f = IO.popen("/bin/sh","r+")
164
- # f.close_read
165
- # f.readlines
166
- # ```
167
- #
168
- # *produces:*
169
- #
170
- # prog.rb:3:in `readlines': not opened for reading (IOError)
171
- # from prog.rb:3
172
- #
173
- # Calling this method on closed [IO](IO.downloaded.ruby_doc) object is
174
- # just ignored since Ruby 2.3.
175
- def close_read: () -> NilClass
176
-
177
- # Closes the write end of a duplex I/O stream (i.e., one that contains
178
- # both a read and a write stream, such as a pipe). Will raise an `IOError`
179
- # if the stream is not duplexed.
180
- #
181
- # ```ruby
182
- # f = IO.popen("/bin/sh","r+")
183
- # f.close_write
184
- # f.print "nowhere"
185
- # ```
186
- #
187
- # *produces:*
188
- #
189
- # prog.rb:3:in `write': not opened for writing (IOError)
190
- # from prog.rb:3:in `print'
191
- # from prog.rb:3
192
- #
193
- # Calling this method on closed [IO](IO.downloaded.ruby_doc) object is
194
- # just ignored since Ruby 2.3.
195
- def close_write: () -> NilClass
196
-
197
- # Returns `true` if *ios* is completely closed (for duplex streams, both
198
- # reader and writer), `false` otherwise.
199
- #
200
- # ```ruby
201
- # f = File.new("testfile")
202
- # f.close #=> nil
203
- # f.closed? #=> true
204
- # f = IO.popen("/bin/sh","r+")
205
- # f.close_write #=> nil
206
- # f.closed? #=> false
207
- # f.close_read #=> nil
208
- # f.closed? #=> true
209
- # ```
210
- def closed?: () -> bool
211
-
212
- def each: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
213
- | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
214
-
215
- def each_byte: () { (Integer arg0) -> untyped } -> self
216
- | () -> ::Enumerator[Integer, self]
217
-
218
- def each_char: () { (String arg0) -> untyped } -> self
219
- | () -> ::Enumerator[String, self]
220
-
221
- def each_codepoint: () { (Integer arg0) -> untyped } -> self
222
- | () -> ::Enumerator[Integer, self]
223
-
224
- # Returns true if *ios* is at end of file that means there are no more
225
- # data to read. The stream must be opened for reading or an `IOError` will
226
- # be raised.
227
- #
228
- # ```ruby
229
- # f = File.new("testfile")
230
- # dummy = f.readlines
231
- # f.eof #=> true
232
- # ```
233
- #
234
- # If *ios* is a stream such as pipe or socket, `IO#eof?` blocks until the
235
- # other end sends some data or closes it.
236
- #
237
- # ```ruby
238
- # r, w = IO.pipe
239
- # Thread.new { sleep 1; w.close }
240
- # r.eof? #=> true after 1 second blocking
241
- #
242
- # r, w = IO.pipe
243
- # Thread.new { sleep 1; w.puts "a" }
244
- # r.eof? #=> false after 1 second blocking
245
- #
246
- # r, w = IO.pipe
247
- # r.eof? # blocks forever
248
- # ```
249
- #
250
- # Note that `IO#eof?` reads data to the input byte buffer. So `IO#sysread`
251
- # may not behave as you intend with `IO#eof?`, unless you call
252
- # `IO#rewind` first (which is not available for some streams).
253
- def eof: () -> bool
254
-
255
- def fcntl: (Integer integer_cmd, String | Integer arg) -> Integer
256
-
257
- # Immediately writes all buffered data in *ios* to disk.
258
- #
259
- # If the underlying operating system does not support *fdatasync(2)* ,
260
- # `IO#fsync` is called instead (which might raise a `NotImplementedError`
261
- # ).
262
- def fdatasync: () -> Integer?
263
-
264
- # Returns an integer representing the numeric file descriptor for *ios* .
265
- #
266
- # ```ruby
267
- # $stdin.fileno #=> 0
268
- # $stdout.fileno #=> 1
269
- # ```
270
- #
271
- #
272
- #
273
- # Also aliased as: [to\_i](IO.downloaded.ruby_doc#method-i-to_i)
274
- def fileno: () -> Integer
275
-
276
- # Flushes any buffered data within *ios* to the underlying operating
277
- # system (note that this is Ruby internal buffering only; the OS may
278
- # buffer the data as well).
279
- #
280
- # ```ruby
281
- # $stdout.print "no newline"
282
- # $stdout.flush
283
- # ```
284
- #
285
- # *produces:*
286
- #
287
- # ```ruby
288
- # no newline
289
- # ```
290
- def flush: () -> self
291
-
292
- # Immediately writes all buffered data in *ios* to disk. Note that `fsync`
293
- # differs from using `IO#sync=` . The latter ensures that data is flushed
294
- # from Ruby’s buffers, but does not guarantee that the underlying
295
- # operating system actually writes it to disk.
296
- #
297
- # `NotImplementedError` is raised if the underlying operating system does
298
- # not support *fsync(2)* .
299
- def fsync: () -> Integer?
300
-
301
- # Gets the next 8-bit byte (0..255) from *ios* . Returns `nil` if called
302
- # at end of file.
303
- #
304
- # ```ruby
305
- # f = File.new("testfile")
306
- # f.getbyte #=> 84
307
- # f.getbyte #=> 104
308
- # ```
309
- def getbyte: () -> Integer?
310
-
311
- # Reads a one-character string from *ios* . Returns `nil` if called at end
312
- # of file.
313
- #
314
- # ```ruby
315
- # f = File.new("testfile")
316
- # f.getc #=> "h"
317
- # f.getc #=> "e"
318
- # ```
319
- def getc: () -> String?
320
-
321
- def gets: (?String sep, ?Integer limit) -> String?
322
-
323
- def initialize: (Integer fd, ?Integer mode, ?Integer opt) -> void
324
-
325
- # Return a string describing this [IO](IO.downloaded.ruby_doc) object.
326
- def inspect: () -> String
327
-
328
- # Returns the [Encoding](https://ruby-doc.org/core-2.6.3/Encoding.html) of
329
- # the internal string if conversion is specified. Otherwise returns `nil`
330
- # .
331
- def internal_encoding: () -> Encoding
332
-
333
- def ioctl: (Integer integer_cmd, String | Integer arg) -> Integer
334
-
335
- # Returns `true` if *ios* is associated with a terminal device (tty),
336
- # `false` otherwise.
337
- #
338
- # ```ruby
339
- # File.new("testfile").isatty #=> false
340
- # File.new("/dev/tty").isatty #=> true
341
- # ```
342
- def isatty: () -> bool
343
-
344
- # Returns the current line number in *ios* . The stream must be opened for
345
- # reading. `lineno` counts the number of times
346
- # [gets](IO.downloaded.ruby_doc#method-i-gets) is called rather than the
347
- # number of newlines encountered. The two values will differ if
348
- # [gets](IO.downloaded.ruby_doc#method-i-gets) is called with a separator
349
- # other than newline.
350
- #
351
- # Methods that use `$/` like [each](IO.downloaded.ruby_doc#method-i-each)
352
- # , [lines](IO.downloaded.ruby_doc#method-i-lines) and
353
- # [readline](IO.downloaded.ruby_doc#method-i-readline) will also increment
354
- # `lineno` .
355
- #
356
- # See also the `$.` variable.
357
- #
358
- # ```ruby
359
- # f = File.new("testfile")
360
- # f.lineno #=> 0
361
- # f.gets #=> "This is line one\n"
362
- # f.lineno #=> 1
363
- # f.gets #=> "This is line two\n"
364
- # f.lineno #=> 2
365
- # ```
366
- def lineno: () -> Integer
367
-
368
- def lineno=: (Integer arg0) -> Integer
369
-
370
- # Returns the process ID of a child process associated with *ios* . This
371
- # will be set by `IO.popen` .
372
- #
373
- # ```ruby
374
- # pipe = IO.popen("-")
375
- # if pipe
376
- # $stderr.puts "In parent, child pid is #{pipe.pid}"
377
- # else
378
- # $stderr.puts "In child, pid is #{$$}"
379
- # end
380
- # ```
381
- #
382
- # *produces:*
383
- #
384
- # In child, pid is 26209
385
- # In parent, child pid is 26209
386
- def pid: () -> Integer
387
-
388
- # Returns the current offset (in bytes) of *ios* .
389
- #
390
- # ```ruby
391
- # f = File.new("testfile")
392
- # f.pos #=> 0
393
- # f.gets #=> "This is line one\n"
394
- # f.pos #=> 17
395
- # ```
396
- def pos: () -> Integer
397
-
398
- def pos=: (Integer arg0) -> Integer
399
-
400
- def print: (*untyped arg0) -> NilClass
401
-
402
- def printf: (String format_string, *untyped arg0) -> NilClass
403
-
404
- def putc: (Numeric | String arg0) -> untyped
405
-
406
- def puts: (*untyped arg0) -> NilClass
407
-
408
- def read: (?Integer length, ?String outbuf) -> String?
409
-
410
- def read_nonblock: (Integer len) -> String
411
- | (Integer len, ?String buf) -> String
412
-
413
- # Reads a byte as with `IO#getbyte`, but raises an `EOFError` on end of
414
- # file.
415
- def readbyte: () -> Integer
416
-
417
- # Reads a one-character string from *ios* . Raises an `EOFError` on end of
418
- # file.
419
- #
420
- # ```ruby
421
- # f = File.new("testfile")
422
- # f.readchar #=> "h"
423
- # f.readchar #=> "e"
424
- # ```
425
- def readchar: () -> String
426
-
427
- def readline: (?String sep, ?Integer limit) -> String
428
-
429
- def readlines: (?String sep, ?Integer limit) -> ::Array[String]
430
-
431
- def readpartial: (Integer maxlen) -> String
432
- | (Integer maxlen, ?String outbuf) -> String
433
-
434
- def reopen: (IO other_IO_or_path) -> IO
435
- | (String other_IO_or_path, ?String mode_str) -> IO
436
-
437
- # Positions *ios* to the beginning of input, resetting `lineno` to zero.
438
- #
439
- # ```ruby
440
- # f = File.new("testfile")
441
- # f.readline #=> "This is line one\n"
442
- # f.rewind #=> 0
443
- # f.lineno #=> 0
444
- # f.readline #=> "This is line one\n"
445
- # ```
446
- #
447
- # Note that it cannot be used with streams such as pipes, ttys, and
448
- # sockets.
449
- def rewind: () -> Integer
450
-
451
- def seek: (Integer amount, ?Integer whence) -> Integer
452
-
453
- def set_encoding: (?String | Encoding ext_or_ext_int_enc) -> self
454
- | (?String | Encoding ext_or_ext_int_enc, ?String | Encoding int_enc) -> self
455
-
456
- # Returns status information for *ios* as an object of type `File::Stat` .
457
- #
458
- # ```ruby
459
- # f = File.new("testfile")
460
- # s = f.stat
461
- # "%o" % s.mode #=> "100644"
462
- # s.blksize #=> 4096
463
- # s.atime #=> Wed Apr 09 08:53:54 CDT 2003
464
- # ```
465
- def stat: () -> File::Stat
466
-
467
- # Returns the current “sync mode” of *ios* . When sync mode is true, all
468
- # output is immediately flushed to the underlying operating system and is
469
- # not buffered by Ruby internally. See also `IO#fsync` .
470
- #
471
- # ```ruby
472
- # f = File.new("testfile")
473
- # f.sync #=> false
474
- # ```
475
- def sync: () -> bool
476
-
477
- def sync=: (bool arg0) -> bool
478
-
479
- def sysread: (Integer maxlen, String outbuf) -> String
480
-
481
- def sysseek: (Integer amount, ?Integer whence) -> Integer
482
-
483
- def syswrite: (String arg0) -> Integer
484
-
485
- # Returns the current offset (in bytes) of *ios* .
486
- #
487
- # ```ruby
488
- # f = File.new("testfile")
489
- # f.pos #=> 0
490
- # f.gets #=> "This is line one\n"
491
- # f.pos #=> 17
492
- # ```
493
- def tell: () -> Integer
494
-
495
- # Returns *ios* .
496
- def to_io: () -> self
497
-
498
- # Returns `true` if *ios* is associated with a terminal device (tty),
499
- # `false` otherwise.
500
- #
501
- # ```ruby
502
- # File.new("testfile").isatty #=> false
503
- # File.new("/dev/tty").isatty #=> true
504
- # ```
505
- def tty?: () -> bool
506
-
507
- def ungetbyte: (String | Integer arg0) -> NilClass
508
-
509
- def ungetc: (String arg0) -> NilClass
510
-
511
- def write: (String arg0) -> Integer
512
-
513
- def self.binread: (String name, ?Integer length, ?Integer offset) -> String
514
-
515
- def self.binwrite: (String name, String arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
516
-
517
- def self.copy_stream: (String | IO src, String | IO dst, ?Integer copy_length, ?Integer src_offset) -> Integer
518
-
519
- def self.popen: (*untyped args) -> untyped
520
-
521
- def self.read: (String name, ?Integer length, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> String
522
-
523
- def self.readlines: (String name, ?String sep, ?Integer limit, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> ::Array[String]
524
-
525
- def self.select: (::Array[IO]? read_array, ?::Array[IO]? write_array, ?::Array[IO]? error_array, ?Integer? timeout) -> ::Array[::Array[IO]]?
526
-
527
- def self.sysopen: (String path, ?String mode, ?String perm) -> Integer
528
-
529
- def self.try_convert: (untyped arg0) -> IO?
530
-
531
- def self.write: (String name, String arg0, ?Integer offset, ?external_encoding: String external_encoding, ?internal_encoding: String internal_encoding, ?encoding: String encoding, ?textmode: untyped textmode, ?binmode: untyped binmode, ?autoclose: untyped autoclose, ?mode: String mode) -> Integer
532
-
533
- def self.for_fd: (Integer fd, ?Integer mode, ?Integer opt) -> self
534
-
535
- def bytes: () { (Integer arg0) -> untyped } -> self
536
- | () -> ::Enumerator[Integer, self]
537
-
538
- def chars: () { (String arg0) -> untyped } -> self
539
- | () -> ::Enumerator[String, self]
540
-
541
- def codepoints: () { (Integer arg0) -> untyped } -> self
542
- | () -> ::Enumerator[Integer, self]
543
-
544
- def each_line: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
545
- | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
546
-
547
- # Returns true if *ios* is at end of file that means there are no more
548
- # data to read. The stream must be opened for reading or an `IOError` will
549
- # be raised.
550
- #
551
- # ```ruby
552
- # f = File.new("testfile")
553
- # dummy = f.readlines
554
- # f.eof #=> true
555
- # ```
556
- #
557
- # If *ios* is a stream such as pipe or socket, `IO#eof?` blocks until the
558
- # other end sends some data or closes it.
559
- #
560
- # ```ruby
561
- # r, w = IO.pipe
562
- # Thread.new { sleep 1; w.close }
563
- # r.eof? #=> true after 1 second blocking
564
- #
565
- # r, w = IO.pipe
566
- # Thread.new { sleep 1; w.puts "a" }
567
- # r.eof? #=> false after 1 second blocking
568
- #
569
- # r, w = IO.pipe
570
- # r.eof? # blocks forever
571
- # ```
572
- #
573
- # Note that `IO#eof?` reads data to the input byte buffer. So `IO#sysread`
574
- # may not behave as you intend with `IO#eof?`, unless you call
575
- # `IO#rewind` first (which is not available for some streams).
576
- def eof?: () -> bool
577
-
578
- def lines: (?String sep, ?Integer limit) { (String arg0) -> untyped } -> self
579
- | (?String sep, ?Integer limit) -> ::Enumerator[String, self]
580
-
581
- # Alias for: [fileno](IO.downloaded.ruby_doc#method-i-fileno)
582
- def to_i: () -> Integer
583
- end
584
-
585
- IO::APPEND: Integer
586
-
587
- IO::BINARY: Integer
588
-
589
- IO::CREAT: Integer
590
-
591
- IO::DIRECT: Integer
592
-
593
- IO::DSYNC: Integer
594
-
595
- IO::EXCL: Integer
596
-
597
- IO::FNM_CASEFOLD: Integer
598
-
599
- IO::FNM_DOTMATCH: Integer
600
-
601
- IO::FNM_EXTGLOB: Integer
602
-
603
- IO::FNM_NOESCAPE: Integer
604
-
605
- IO::FNM_PATHNAME: Integer
606
-
607
- IO::FNM_SHORTNAME: Integer
608
-
609
- IO::FNM_SYSCASE: Integer
610
-
611
- IO::LOCK_EX: Integer
612
-
613
- IO::LOCK_NB: Integer
614
-
615
- IO::LOCK_SH: Integer
616
-
617
- IO::LOCK_UN: Integer
618
-
619
- IO::NOATIME: Integer
620
-
621
- IO::NOCTTY: Integer
622
-
623
- IO::NOFOLLOW: Integer
624
-
625
- IO::NONBLOCK: Integer
626
-
627
- IO::NULL: String
628
-
629
- IO::RDONLY: Integer
630
-
631
- IO::RDWR: Integer
632
-
633
- IO::RSYNC: Integer
634
-
635
- IO::SEEK_CUR: Integer
636
-
637
- IO::SEEK_DATA: Integer
638
-
639
- IO::SEEK_END: Integer
640
-
641
- IO::SEEK_HOLE: Integer
642
-
643
- IO::SEEK_SET: Integer
644
-
645
- IO::SHARE_DELETE: Integer
646
-
647
- IO::SYNC: Integer
648
-
649
- IO::TMPFILE: Integer
650
-
651
- IO::TRUNC: Integer
652
-
653
- IO::WRONLY: Integer
654
-
655
- class IO::EAGAINWaitReadable < Errno::EAGAIN
656
- include IO::WaitReadable
657
- end
658
-
659
- IO::EAGAINWaitReadable::Errno: Integer
660
-
661
- class IO::EAGAINWaitWritable < Errno::EAGAIN
662
- include IO::WaitWritable
663
- end
664
-
665
- IO::EAGAINWaitWritable::Errno: Integer
666
-
667
- class IO::EINPROGRESSWaitReadable < Errno::EINPROGRESS
668
- include IO::WaitReadable
669
- end
670
-
671
- IO::EINPROGRESSWaitReadable::Errno: Integer
672
-
673
- class IO::EINPROGRESSWaitWritable < Errno::EINPROGRESS
674
- include IO::WaitWritable
675
- end
676
-
677
- IO::EINPROGRESSWaitWritable::Errno: Integer
678
-
679
- module IO::WaitReadable
680
- end
681
-
682
- module IO::WaitWritable
683
- end