steep 0.11.1 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (299) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +27 -0
  3. data/.gitmodules +3 -0
  4. data/CHANGELOG.md +5 -0
  5. data/README.md +48 -90
  6. data/Rakefile +10 -6
  7. data/Steepfile +1 -0
  8. data/bin/setup +1 -0
  9. data/bin/smoke_runner.rb +9 -14
  10. data/exe/rbs +3 -0
  11. data/exe/ruby-signature +3 -0
  12. data/exe/steep +1 -0
  13. data/lib/steep.rb +32 -26
  14. data/lib/steep/annotation_parser.rb +167 -0
  15. data/lib/steep/ast/annotation/collection.rb +7 -7
  16. data/lib/steep/ast/types.rb +60 -0
  17. data/lib/steep/ast/types/any.rb +1 -1
  18. data/lib/steep/ast/types/factory.rb +535 -0
  19. data/lib/steep/ast/types/name.rb +3 -3
  20. data/lib/steep/ast/types/var.rb +1 -1
  21. data/lib/steep/cli.rb +56 -240
  22. data/lib/steep/drivers/annotations.rb +36 -19
  23. data/lib/steep/drivers/check.rb +55 -91
  24. data/lib/steep/drivers/init.rb +54 -0
  25. data/lib/steep/drivers/langserver.rb +241 -150
  26. data/lib/steep/drivers/print_project.rb +56 -0
  27. data/lib/steep/drivers/signature_error_printer.rb +25 -0
  28. data/lib/steep/drivers/trace_printer.rb +25 -0
  29. data/lib/steep/drivers/utils/driver_helper.rb +26 -0
  30. data/lib/steep/drivers/validate.rb +18 -38
  31. data/lib/steep/drivers/vendor.rb +46 -0
  32. data/lib/steep/drivers/watch.rb +78 -140
  33. data/lib/steep/errors.rb +22 -13
  34. data/lib/steep/interface/interface.rb +91 -0
  35. data/lib/steep/interface/method.rb +0 -4
  36. data/lib/steep/interface/method_type.rb +362 -2
  37. data/lib/steep/interface/substitution.rb +22 -0
  38. data/lib/steep/project.rb +25 -233
  39. data/lib/steep/project/dsl.rb +132 -0
  40. data/lib/steep/project/file.rb +93 -76
  41. data/lib/steep/project/file_loader.rb +63 -0
  42. data/lib/steep/project/options.rb +7 -0
  43. data/lib/steep/project/target.rb +190 -0
  44. data/lib/steep/signature/errors.rb +25 -77
  45. data/lib/steep/signature/validator.rb +122 -0
  46. data/lib/steep/source.rb +12 -7
  47. data/lib/steep/subtyping/check.rb +357 -633
  48. data/lib/steep/subtyping/constraints.rb +2 -2
  49. data/lib/steep/subtyping/trace.rb +23 -0
  50. data/lib/steep/type_construction.rb +509 -455
  51. data/lib/steep/type_inference/constant_env.rb +16 -24
  52. data/lib/steep/type_inference/type_env.rb +26 -18
  53. data/lib/steep/version.rb +1 -1
  54. data/sample/Steepfile +6 -0
  55. data/sample/lib/conference.rb +12 -0
  56. data/sample/sig/conference.rbs +6 -0
  57. data/smoke/alias/Steepfile +4 -0
  58. data/smoke/alias/a.rb +2 -2
  59. data/smoke/alias/{a.rbi → a.rbs} +1 -1
  60. data/smoke/and/Steepfile +4 -0
  61. data/smoke/array/Steepfile +4 -0
  62. data/smoke/array/a.rb +2 -2
  63. data/smoke/array/b.rb +4 -4
  64. data/smoke/array/c.rb +2 -2
  65. data/smoke/block/Steepfile +5 -0
  66. data/smoke/block/{a.rbi → a.rbs} +1 -1
  67. data/smoke/block/{c.rbi → c.rbs} +0 -0
  68. data/smoke/block/d.rb +6 -6
  69. data/smoke/case/Steepfile +4 -0
  70. data/smoke/case/a.rb +4 -3
  71. data/smoke/class/Steepfile +4 -0
  72. data/smoke/class/a.rb +1 -4
  73. data/smoke/class/a.rbs +24 -0
  74. data/smoke/class/h.rb +6 -2
  75. data/smoke/class/{h.rbi → h.rbs} +1 -2
  76. data/smoke/class/i.rb +1 -2
  77. data/smoke/class/i.rbs +9 -0
  78. data/smoke/const/Steepfile +4 -0
  79. data/smoke/dstr/Steepfile +4 -0
  80. data/smoke/ensure/Steepfile +4 -0
  81. data/smoke/ensure/a.rb +1 -1
  82. data/smoke/enumerator/Steepfile +4 -0
  83. data/smoke/enumerator/a.rb +7 -7
  84. data/smoke/enumerator/b.rb +6 -6
  85. data/smoke/extension/Steepfile +4 -0
  86. data/smoke/extension/{a.rbi → a.rbs} +2 -2
  87. data/smoke/extension/{e.rbi → e.rbs} +2 -2
  88. data/smoke/hash/Steepfile +4 -0
  89. data/smoke/hash/{a.rbi → a.rbs} +0 -0
  90. data/smoke/hash/b.rb +2 -2
  91. data/smoke/hash/c.rb +1 -1
  92. data/smoke/hash/e.rbs +3 -0
  93. data/smoke/hash/f.rb +1 -1
  94. data/smoke/hello/Steepfile +4 -0
  95. data/smoke/hello/hello.rbs +7 -0
  96. data/smoke/if/Steepfile +4 -0
  97. data/smoke/implements/Steepfile +4 -0
  98. data/smoke/implements/a.rbs +6 -0
  99. data/smoke/initialize/Steepfile +4 -0
  100. data/smoke/initialize/a.rbs +3 -0
  101. data/smoke/integer/Steepfile +4 -0
  102. data/smoke/integer/a.rb +5 -3
  103. data/smoke/interface/Steepfile +4 -0
  104. data/smoke/interface/{a.rbi → a.rbs} +0 -0
  105. data/smoke/kwbegin/Steepfile +4 -0
  106. data/smoke/lambda/Steepfile +4 -0
  107. data/smoke/lambda/a.rb +9 -2
  108. data/smoke/literal/Steepfile +4 -0
  109. data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
  110. data/smoke/map/Steepfile +4 -0
  111. data/smoke/map/a.rb +1 -1
  112. data/smoke/method/Steepfile +4 -0
  113. data/smoke/method/{a.rbi → a.rbs} +0 -0
  114. data/smoke/method/b.rb +1 -4
  115. data/smoke/method/d.rb +1 -0
  116. data/smoke/method/d.rbs +3 -0
  117. data/smoke/module/Steepfile +4 -0
  118. data/smoke/module/a.rb +1 -1
  119. data/smoke/module/a.rbs +16 -0
  120. data/smoke/module/c.rb +1 -1
  121. data/smoke/regexp/Steepfile +4 -0
  122. data/smoke/regexp/a.rb +2 -2
  123. data/smoke/regexp/b.rb +16 -16
  124. data/smoke/regression/Steepfile +5 -0
  125. data/smoke/regression/array.rb +2 -2
  126. data/smoke/regression/hash.rb +2 -2
  127. data/smoke/regression/poly_new.rb +2 -0
  128. data/smoke/regression/poly_new.rbs +4 -0
  129. data/smoke/regression/set_divide.rb +2 -2
  130. data/smoke/rescue/Steepfile +4 -0
  131. data/smoke/rescue/a.rb +1 -1
  132. data/smoke/self/Steepfile +4 -0
  133. data/smoke/self/a.rbs +4 -0
  134. data/smoke/skip/Steepfile +4 -0
  135. data/smoke/stdout/Steepfile +4 -0
  136. data/smoke/stdout/{a.rbi → a.rbs} +1 -1
  137. data/smoke/super/Steepfile +4 -0
  138. data/smoke/super/a.rbs +10 -0
  139. data/smoke/type_case/Steepfile +4 -0
  140. data/smoke/type_case/a.rb +1 -1
  141. data/smoke/yield/Steepfile +4 -0
  142. data/smoke/yield/a.rb +2 -2
  143. data/steep.gemspec +14 -7
  144. data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
  145. data/vendor/ruby-signature/.gitignore +12 -0
  146. data/vendor/ruby-signature/.rubocop.yml +15 -0
  147. data/vendor/ruby-signature/BSDL +22 -0
  148. data/vendor/ruby-signature/COPYING +56 -0
  149. data/vendor/ruby-signature/Gemfile +6 -0
  150. data/vendor/ruby-signature/README.md +93 -0
  151. data/vendor/ruby-signature/Rakefile +66 -0
  152. data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
  153. data/vendor/ruby-signature/bin/console +14 -0
  154. data/vendor/ruby-signature/bin/query-rdoc +103 -0
  155. data/vendor/ruby-signature/bin/setup +10 -0
  156. data/vendor/ruby-signature/bin/sort +88 -0
  157. data/vendor/ruby-signature/bin/test_runner.rb +17 -0
  158. data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
  159. data/vendor/ruby-signature/docs/sigs.md +148 -0
  160. data/vendor/ruby-signature/docs/stdlib.md +152 -0
  161. data/vendor/ruby-signature/docs/syntax.md +528 -0
  162. data/vendor/ruby-signature/exe/rbs +3 -0
  163. data/vendor/ruby-signature/exe/ruby-signature +7 -0
  164. data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
  165. data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
  166. data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
  167. data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
  168. data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
  169. data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
  170. data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
  171. data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
  172. data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
  173. data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
  174. data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
  175. data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
  176. data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
  177. data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
  178. data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
  179. data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
  180. data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
  181. data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
  182. data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
  183. data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
  184. data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
  185. data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
  186. data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
  187. data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
  188. data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
  189. data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
  190. data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
  191. data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
  192. data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
  193. data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
  194. data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
  195. data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
  196. data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
  197. data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
  198. data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
  199. data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
  200. data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
  201. data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
  202. data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
  203. data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
  204. data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
  205. data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
  206. data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
  207. data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
  208. data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
  209. data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
  210. data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
  211. data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
  212. data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
  213. data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
  214. data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
  215. data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
  216. data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
  217. data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
  218. data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
  219. data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
  220. data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
  221. data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
  222. data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
  223. data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
  224. data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
  225. data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
  226. data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
  227. data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
  228. data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
  229. data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
  230. data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
  231. data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
  232. data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
  233. data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
  234. data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
  235. data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
  236. data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
  237. data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
  238. data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
  239. data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
  240. data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
  241. data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
  242. data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
  243. data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
  244. data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
  245. data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
  246. data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
  247. data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
  248. data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
  249. data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
  250. data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
  251. data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
  252. data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
  253. data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
  254. data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
  255. data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
  256. data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
  257. data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
  258. data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
  259. data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
  260. data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
  261. data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
  262. data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
  263. data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
  264. data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
  265. data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
  266. data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
  267. data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
  268. metadata +244 -54
  269. data/.travis.yml +0 -7
  270. data/lib/steep/ast/signature/alias.rb +0 -19
  271. data/lib/steep/ast/signature/class.rb +0 -33
  272. data/lib/steep/ast/signature/const.rb +0 -17
  273. data/lib/steep/ast/signature/env.rb +0 -138
  274. data/lib/steep/ast/signature/extension.rb +0 -21
  275. data/lib/steep/ast/signature/gvar.rb +0 -17
  276. data/lib/steep/ast/signature/interface.rb +0 -31
  277. data/lib/steep/ast/signature/members.rb +0 -115
  278. data/lib/steep/ast/signature/module.rb +0 -21
  279. data/lib/steep/drivers/print_interface.rb +0 -94
  280. data/lib/steep/drivers/scaffold.rb +0 -321
  281. data/lib/steep/drivers/utils/each_signature.rb +0 -31
  282. data/lib/steep/interface/abstract.rb +0 -68
  283. data/lib/steep/interface/builder.rb +0 -637
  284. data/lib/steep/interface/instantiated.rb +0 -163
  285. data/lib/steep/interface/ivar_chain.rb +0 -26
  286. data/lib/steep/parser.y +0 -1278
  287. data/lib/steep/project/listener.rb +0 -53
  288. data/smoke/class/a.rbi +0 -24
  289. data/smoke/class/d.rb +0 -9
  290. data/smoke/class/e.rb +0 -12
  291. data/smoke/class/i.rbi +0 -9
  292. data/smoke/hash/e.rbi +0 -3
  293. data/smoke/hello/hello.rbi +0 -7
  294. data/smoke/implements/a.rbi +0 -6
  295. data/smoke/initialize/a.rbi +0 -3
  296. data/smoke/module/a.rbi +0 -16
  297. data/smoke/self/a.rbi +0 -4
  298. data/smoke/super/a.rbi +0 -10
  299. data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,683 @@
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