rbs 2.8.4 → 3.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (434) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +12 -4
  3. data/.github/workflows/comments.yml +11 -11
  4. data/.github/workflows/dependabot.yml +30 -0
  5. data/.github/workflows/ruby.yml +40 -49
  6. data/.github/workflows/typecheck.yml +36 -0
  7. data/.github/workflows/windows.yml +28 -0
  8. data/.gitignore +1 -0
  9. data/.rubocop.yml +42 -2
  10. data/CHANGELOG.md +845 -1
  11. data/README.md +64 -4
  12. data/Rakefile +198 -18
  13. data/Steepfile +11 -11
  14. data/config.yml +311 -0
  15. data/core/array.rbs +2189 -1914
  16. data/core/basic_object.rbs +59 -84
  17. data/core/binding.rbs +7 -69
  18. data/core/builtin.rbs +210 -11
  19. data/core/class.rbs +37 -0
  20. data/core/comparable.rbs +23 -25
  21. data/core/complex.rbs +449 -227
  22. data/core/constants.rbs +29 -21
  23. data/core/data.rbs +415 -0
  24. data/core/dir.rbs +698 -415
  25. data/core/encoding.rbs +468 -843
  26. data/core/enumerable.rbs +495 -455
  27. data/core/enumerator/product.rbs +92 -0
  28. data/core/enumerator.rbs +106 -9
  29. data/core/env.rbs +1 -1
  30. data/core/errno.rbs +506 -605
  31. data/core/errors.rbs +15 -17
  32. data/core/exception.rbs +361 -145
  33. data/core/false_class.rbs +39 -26
  34. data/core/fiber.rbs +121 -14
  35. data/core/file.rbs +1262 -320
  36. data/core/file_test.rbs +62 -45
  37. data/core/float.rbs +187 -208
  38. data/core/gc.rbs +446 -196
  39. data/core/global_variables.rbs +29 -29
  40. data/core/hash.rbs +242 -349
  41. data/core/integer.rbs +246 -308
  42. data/core/io/buffer.rbs +373 -122
  43. data/core/io/wait.rbs +29 -17
  44. data/core/io.rbs +1881 -1518
  45. data/core/kernel.rbs +2116 -1538
  46. data/core/marshal.rbs +24 -14
  47. data/core/match_data.rbs +413 -166
  48. data/core/math.rbs +531 -291
  49. data/core/method.rbs +101 -32
  50. data/core/module.rbs +228 -64
  51. data/core/nil_class.rbs +106 -47
  52. data/core/numeric.rbs +206 -292
  53. data/core/object.rbs +73 -1168
  54. data/core/object_space/weak_key_map.rbs +166 -0
  55. data/core/object_space.rbs +5 -3
  56. data/core/proc.rbs +280 -39
  57. data/core/process.rbs +1318 -658
  58. data/core/ractor.rbs +200 -134
  59. data/core/random.rbs +21 -4
  60. data/core/range.rbs +309 -153
  61. data/core/rational.rbs +4 -12
  62. data/core/rb_config.rbs +64 -43
  63. data/core/rbs/unnamed/argf.rbs +411 -147
  64. data/core/rbs/unnamed/env_class.rbs +137 -253
  65. data/core/rbs/unnamed/random.rbs +49 -26
  66. data/core/refinement.rbs +16 -1
  67. data/core/regexp.rbs +1568 -862
  68. data/core/ruby_vm.rbs +719 -7
  69. data/core/rubygems/config_file.rbs +3 -0
  70. data/core/rubygems/errors.rbs +69 -6
  71. data/core/rubygems/rubygems.rbs +71 -17
  72. data/core/rubygems/version.rbs +11 -7
  73. data/{stdlib/set/0 → core}/set.rbs +80 -91
  74. data/core/signal.rbs +14 -8
  75. data/core/string.rbs +1732 -1607
  76. data/core/struct.rbs +467 -95
  77. data/core/symbol.rbs +215 -245
  78. data/core/thread.rbs +133 -89
  79. data/core/thread_group.rbs +9 -9
  80. data/core/time.rbs +1141 -841
  81. data/core/trace_point.rbs +181 -121
  82. data/core/true_class.rbs +58 -32
  83. data/core/unbound_method.rbs +103 -30
  84. data/core/warning.rbs +50 -5
  85. data/docs/CONTRIBUTING.md +1 -1
  86. data/docs/architecture.md +110 -0
  87. data/docs/collection.md +59 -5
  88. data/docs/data_and_struct.md +86 -0
  89. data/docs/gem.md +57 -0
  90. data/docs/rbs_by_example.md +16 -35
  91. data/docs/repo.md +1 -1
  92. data/docs/sigs.md +7 -7
  93. data/docs/stdlib.md +63 -5
  94. data/docs/syntax.md +255 -61
  95. data/docs/tools.md +1 -0
  96. data/ext/rbs_extension/extconf.rb +10 -0
  97. data/ext/rbs_extension/lexer.c +1741 -1548
  98. data/ext/rbs_extension/lexer.h +11 -1
  99. data/ext/rbs_extension/lexer.re +12 -6
  100. data/ext/rbs_extension/lexstate.c +26 -3
  101. data/ext/rbs_extension/location.c +119 -111
  102. data/ext/rbs_extension/location.h +32 -7
  103. data/ext/rbs_extension/main.c +3 -0
  104. data/ext/rbs_extension/parser.c +883 -481
  105. data/ext/rbs_extension/parserstate.c +65 -25
  106. data/ext/rbs_extension/parserstate.h +13 -3
  107. data/ext/rbs_extension/rbs_extension.h +1 -10
  108. data/ext/rbs_extension/unescape.c +7 -47
  109. data/goodcheck.yml +2 -2
  110. data/{ext/rbs_extension → include/rbs}/constants.h +26 -15
  111. data/include/rbs/ruby_objs.h +72 -0
  112. data/include/rbs.h +7 -0
  113. data/lib/rbs/annotate/annotations.rb +3 -3
  114. data/lib/rbs/annotate/formatter.rb +13 -3
  115. data/lib/rbs/annotate/rdoc_annotator.rb +1 -1
  116. data/lib/rbs/annotate/rdoc_source.rb +12 -3
  117. data/lib/rbs/ast/declarations.rb +85 -2
  118. data/lib/rbs/ast/directives.rb +39 -0
  119. data/lib/rbs/ast/members.rb +49 -15
  120. data/lib/rbs/ast/type_param.rb +104 -15
  121. data/lib/rbs/ast/visitor.rb +137 -0
  122. data/lib/rbs/buffer.rb +5 -0
  123. data/lib/rbs/cli/colored_io.rb +48 -0
  124. data/lib/rbs/cli/diff.rb +83 -0
  125. data/lib/rbs/cli/validate.rb +356 -0
  126. data/lib/rbs/cli.rb +253 -143
  127. data/lib/rbs/collection/cleaner.rb +8 -1
  128. data/lib/rbs/collection/config/lockfile.rb +92 -0
  129. data/lib/rbs/collection/config/lockfile_generator.rb +154 -65
  130. data/lib/rbs/collection/config.rb +19 -46
  131. data/lib/rbs/collection/installer.rb +12 -13
  132. data/lib/rbs/collection/sources/base.rb +2 -2
  133. data/lib/rbs/collection/sources/git.rb +146 -69
  134. data/lib/rbs/collection/sources/local.rb +81 -0
  135. data/lib/rbs/collection/sources/rubygems.rb +10 -12
  136. data/lib/rbs/collection/sources/stdlib.rb +14 -13
  137. data/lib/rbs/collection/sources.rb +15 -2
  138. data/lib/rbs/collection.rb +2 -1
  139. data/lib/rbs/definition.rb +13 -16
  140. data/lib/rbs/definition_builder/ancestor_builder.rb +100 -24
  141. data/lib/rbs/definition_builder/method_builder.rb +4 -4
  142. data/lib/rbs/definition_builder.rb +489 -584
  143. data/lib/rbs/diff.rb +125 -0
  144. data/lib/rbs/environment/use_map.rb +77 -0
  145. data/lib/rbs/environment.rb +406 -105
  146. data/lib/rbs/environment_loader.rb +48 -44
  147. data/lib/rbs/environment_walker.rb +1 -1
  148. data/lib/rbs/errors.rb +175 -56
  149. data/lib/rbs/file_finder.rb +28 -0
  150. data/lib/rbs/location_aux.rb +8 -7
  151. data/lib/rbs/locator.rb +37 -15
  152. data/lib/rbs/method_type.rb +23 -0
  153. data/lib/rbs/namespace.rb +1 -0
  154. data/lib/rbs/parser/lex_result.rb +15 -0
  155. data/lib/rbs/parser/token.rb +23 -0
  156. data/lib/rbs/parser_aux.rb +22 -13
  157. data/lib/rbs/prototype/helpers.rb +48 -22
  158. data/lib/rbs/prototype/node_usage.rb +99 -0
  159. data/lib/rbs/prototype/rb.rb +125 -31
  160. data/lib/rbs/prototype/rbi.rb +49 -36
  161. data/lib/rbs/prototype/runtime/helpers.rb +59 -0
  162. data/lib/rbs/prototype/runtime/reflection.rb +19 -0
  163. data/lib/rbs/prototype/runtime/value_object_generator.rb +279 -0
  164. data/lib/rbs/prototype/runtime.rb +273 -159
  165. data/lib/rbs/resolver/constant_resolver.rb +24 -8
  166. data/lib/rbs/resolver/type_name_resolver.rb +41 -7
  167. data/lib/rbs/sorter.rb +153 -123
  168. data/lib/rbs/substitution.rb +19 -0
  169. data/lib/rbs/subtractor.rb +201 -0
  170. data/lib/rbs/test/errors.rb +24 -11
  171. data/lib/rbs/test/guaranteed.rb +30 -0
  172. data/lib/rbs/test/hook.rb +45 -40
  173. data/lib/rbs/test/setup.rb +1 -1
  174. data/lib/rbs/test/tester.rb +1 -1
  175. data/lib/rbs/test/type_check.rb +120 -23
  176. data/lib/rbs/test.rb +6 -3
  177. data/lib/rbs/type_alias_dependency.rb +13 -3
  178. data/lib/rbs/type_alias_regularity.rb +21 -14
  179. data/lib/rbs/type_name.rb +18 -13
  180. data/lib/rbs/types.rb +352 -18
  181. data/lib/rbs/unit_test/convertibles.rb +176 -0
  182. data/lib/rbs/unit_test/spy.rb +136 -0
  183. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  184. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  185. data/lib/rbs/unit_test.rb +6 -0
  186. data/lib/rbs/validator.rb +55 -30
  187. data/lib/rbs/variance_calculator.rb +26 -23
  188. data/lib/rbs/vendorer.rb +3 -3
  189. data/lib/rbs/version.rb +1 -1
  190. data/lib/rbs/writer.rb +69 -22
  191. data/lib/rbs.rb +7 -2
  192. data/lib/rdoc/discover.rb +1 -1
  193. data/lib/rdoc_plugin/parser.rb +5 -5
  194. data/rbs.gemspec +12 -2
  195. data/schema/decls.json +1 -1
  196. data/schema/members.json +15 -10
  197. data/sig/ancestor_builder.rbs +4 -0
  198. data/sig/ancestor_graph.rbs +22 -2
  199. data/sig/annotate/formatter.rbs +2 -2
  200. data/sig/annotate/rdoc_annotater.rbs +1 -1
  201. data/sig/cli/colored_io.rbs +15 -0
  202. data/sig/cli/diff.rbs +21 -0
  203. data/sig/cli/validate.rbs +43 -0
  204. data/sig/cli.rbs +4 -0
  205. data/sig/collection/config/lockfile.rbs +74 -0
  206. data/sig/collection/config/lockfile_generator.rbs +66 -0
  207. data/sig/collection/config.rbs +5 -48
  208. data/sig/collection/installer.rbs +1 -1
  209. data/sig/collection/sources.rbs +105 -33
  210. data/sig/constant.rbs +1 -1
  211. data/sig/declarations.rbs +42 -3
  212. data/sig/definition.rbs +26 -10
  213. data/sig/definition_builder.rbs +103 -81
  214. data/sig/diff.rbs +28 -0
  215. data/sig/directives.rbs +61 -0
  216. data/sig/environment.rbs +175 -29
  217. data/sig/environment_loader.rbs +20 -18
  218. data/sig/errors.rbs +123 -2
  219. data/sig/file_finder.rbs +28 -0
  220. data/sig/location.rbs +0 -3
  221. data/sig/locator.rbs +14 -2
  222. data/sig/manifest.yaml +0 -1
  223. data/sig/members.rbs +32 -9
  224. data/sig/method_types.rbs +10 -4
  225. data/sig/namespace.rbs +2 -3
  226. data/sig/parser.rbs +55 -16
  227. data/sig/prototype/helpers.rbs +4 -0
  228. data/sig/prototype/node_usage.rbs +20 -0
  229. data/sig/prototype/rb.rbs +10 -2
  230. data/sig/prototype/rbi.rbs +2 -0
  231. data/sig/prototype/runtime.rbs +182 -0
  232. data/sig/rbs.rbs +1 -1
  233. data/sig/rdoc/rbs.rbs +4 -0
  234. data/sig/repository.rbs +7 -5
  235. data/sig/resolver/constant_resolver.rbs +3 -4
  236. data/sig/resolver/context.rbs +1 -1
  237. data/sig/resolver/type_name_resolver.rbs +5 -1
  238. data/sig/shims/bundler.rbs +38 -0
  239. data/sig/shims/rubygems.rbs +19 -0
  240. data/sig/sorter.rbs +23 -5
  241. data/sig/substitution.rbs +6 -0
  242. data/sig/subtractor.rbs +37 -0
  243. data/sig/test/errors.rbs +52 -0
  244. data/sig/test/guranteed.rbs +9 -0
  245. data/sig/test/type_check.rbs +19 -0
  246. data/sig/test.rbs +82 -0
  247. data/sig/type_alias_dependency.rbs +31 -0
  248. data/sig/type_alias_regularity.rbs +12 -6
  249. data/sig/type_param.rbs +45 -9
  250. data/sig/typename.rbs +8 -5
  251. data/sig/types.rbs +119 -12
  252. data/sig/unit_test/convertibles.rbs +154 -0
  253. data/sig/unit_test/spy.rbs +28 -0
  254. data/sig/unit_test/type_assertions.rbs +194 -0
  255. data/sig/unit_test/with_aliases.rbs +136 -0
  256. data/sig/use_map.rbs +35 -0
  257. data/sig/validator.rbs +12 -5
  258. data/sig/variance_calculator.rbs +3 -1
  259. data/sig/vendorer.rbs +1 -1
  260. data/sig/visitor.rbs +47 -0
  261. data/sig/writer.rbs +6 -2
  262. data/src/constants.c +153 -0
  263. data/src/ruby_objs.c +793 -0
  264. data/stdlib/base64/0/base64.rbs +298 -45
  265. data/stdlib/benchmark/0/benchmark.rbs +12 -3
  266. data/stdlib/bigdecimal/0/big_decimal.rbs +62 -198
  267. data/stdlib/cgi/0/core.rbs +68 -15
  268. data/stdlib/cgi/0/manifest.yaml +1 -0
  269. data/stdlib/coverage/0/coverage.rbs +50 -11
  270. data/stdlib/csv/0/csv.rbs +90 -119
  271. data/stdlib/csv/0/manifest.yaml +1 -0
  272. data/stdlib/date/0/date.rbs +806 -735
  273. data/stdlib/date/0/date_time.rbs +70 -211
  274. data/stdlib/dbm/0/dbm.rbs +0 -2
  275. data/stdlib/delegate/0/delegator.rbs +184 -0
  276. data/stdlib/delegate/0/kernel.rbs +47 -0
  277. data/stdlib/delegate/0/simple_delegator.rbs +96 -0
  278. data/stdlib/did_you_mean/0/did_you_mean.rbs +3 -8
  279. data/stdlib/digest/0/digest.rbs +48 -35
  280. data/stdlib/erb/0/erb.rbs +15 -39
  281. data/stdlib/etc/0/etc.rbs +174 -54
  282. data/stdlib/fileutils/0/fileutils.rbs +1234 -385
  283. data/stdlib/forwardable/0/forwardable.rbs +4 -4
  284. data/stdlib/io-console/0/io-console.rbs +82 -17
  285. data/stdlib/ipaddr/0/ipaddr.rbs +11 -6
  286. data/stdlib/json/0/json.rbs +434 -151
  287. data/stdlib/kconv/0/kconv.rbs +166 -0
  288. data/stdlib/logger/0/formatter.rbs +0 -2
  289. data/stdlib/logger/0/log_device.rbs +1 -3
  290. data/stdlib/logger/0/logger.rbs +465 -328
  291. data/stdlib/minitest/0/kernel.rbs +2 -2
  292. data/stdlib/minitest/0/minitest/abstract_reporter.rbs +4 -1
  293. data/stdlib/minitest/0/minitest/assertion.rbs +1 -0
  294. data/stdlib/minitest/0/minitest/assertions.rbs +58 -13
  295. data/stdlib/minitest/0/minitest/backtrace_filter.rbs +7 -0
  296. data/stdlib/minitest/0/minitest/bench_spec.rbs +8 -8
  297. data/stdlib/minitest/0/minitest/benchmark.rbs +17 -16
  298. data/stdlib/minitest/0/minitest/compress.rbs +13 -0
  299. data/stdlib/minitest/0/minitest/error_on_warning.rbs +3 -0
  300. data/stdlib/minitest/0/minitest/mock.rbs +9 -5
  301. data/stdlib/minitest/0/minitest/parallel/executor.rbs +4 -0
  302. data/stdlib/minitest/0/minitest/parallel/test/class_methods.rbs +0 -1
  303. data/stdlib/minitest/0/minitest/pride_io.rbs +8 -0
  304. data/stdlib/minitest/0/minitest/pride_lol.rbs +2 -0
  305. data/stdlib/minitest/0/minitest/progress_reporter.rbs +1 -1
  306. data/stdlib/minitest/0/minitest/reportable.rbs +2 -0
  307. data/stdlib/minitest/0/minitest/runnable.rbs +33 -1
  308. data/stdlib/minitest/0/minitest/spec/dsl/instance_methods.rbs +1 -1
  309. data/stdlib/minitest/0/minitest/spec/dsl.rbs +10 -6
  310. data/stdlib/minitest/0/minitest/spec.rbs +1 -1
  311. data/stdlib/minitest/0/minitest/statistics_reporter.rbs +5 -0
  312. data/stdlib/minitest/0/minitest/summary_reporter.rbs +0 -7
  313. data/stdlib/minitest/0/minitest/test/lifecycle_hooks.rbs +7 -7
  314. data/stdlib/minitest/0/minitest/test.rbs +7 -14
  315. data/stdlib/minitest/0/minitest/unexpected_error.rbs +2 -0
  316. data/stdlib/minitest/0/minitest/unexpected_warning.rbs +6 -0
  317. data/stdlib/minitest/0/minitest/unit.rbs +1 -2
  318. data/stdlib/minitest/0/minitest.rbs +41 -892
  319. data/stdlib/monitor/0/monitor.rbs +91 -10
  320. data/stdlib/mutex_m/0/mutex_m.rbs +0 -2
  321. data/stdlib/net-http/0/manifest.yaml +1 -1
  322. data/stdlib/net-http/0/net-http.rbs +3858 -964
  323. data/stdlib/net-protocol/0/manifest.yaml +2 -0
  324. data/stdlib/net-protocol/0/net-protocol.rbs +56 -0
  325. data/stdlib/net-smtp/0/manifest.yaml +2 -0
  326. data/stdlib/net-smtp/0/net-smtp.rbs +55 -0
  327. data/stdlib/nkf/0/nkf.rbs +35 -5
  328. data/stdlib/objspace/0/objspace.rbs +40 -18
  329. data/stdlib/observable/0/observable.rbs +217 -0
  330. data/stdlib/open-uri/0/manifest.yaml +4 -0
  331. data/stdlib/open-uri/0/open-uri.rbs +393 -0
  332. data/stdlib/open3/0/open3.rbs +147 -0
  333. data/stdlib/openssl/0/manifest.yaml +1 -0
  334. data/stdlib/openssl/0/openssl.rbs +681 -316
  335. data/stdlib/optparse/0/optparse.rbs +100 -65
  336. data/stdlib/pathname/0/pathname.rbs +24 -15
  337. data/stdlib/pp/0/manifest.yaml +2 -0
  338. data/stdlib/pp/0/pp.rbs +300 -0
  339. data/stdlib/prettyprint/0/prettyprint.rbs +2 -6
  340. data/stdlib/pstore/0/pstore.rbs +370 -156
  341. data/stdlib/psych/0/core_ext.rbs +12 -0
  342. data/stdlib/{yaml → psych}/0/dbm.rbs +3 -3
  343. data/stdlib/psych/0/manifest.yaml +3 -0
  344. data/stdlib/psych/0/psych.rbs +402 -0
  345. data/stdlib/{yaml → psych}/0/store.rbs +2 -2
  346. data/stdlib/pty/0/pty.rbs +63 -11
  347. data/stdlib/rdoc/0/code_object.rbs +51 -0
  348. data/stdlib/rdoc/0/comment.rbs +59 -0
  349. data/stdlib/rdoc/0/context.rbs +153 -0
  350. data/stdlib/rdoc/0/markup.rbs +117 -0
  351. data/stdlib/rdoc/0/parser.rbs +56 -0
  352. data/stdlib/rdoc/0/rdoc.rbs +13 -380
  353. data/stdlib/rdoc/0/ri.rbs +17 -0
  354. data/stdlib/rdoc/0/store.rbs +48 -0
  355. data/stdlib/rdoc/0/top_level.rbs +97 -0
  356. data/stdlib/resolv/0/resolv.rbs +16 -79
  357. data/stdlib/ripper/0/ripper.rbs +1648 -0
  358. data/stdlib/securerandom/0/securerandom.rbs +7 -2
  359. data/stdlib/shellwords/0/shellwords.rbs +11 -12
  360. data/stdlib/singleton/0/singleton.rbs +0 -3
  361. data/stdlib/socket/0/addrinfo.rbs +13 -18
  362. data/stdlib/socket/0/basic_socket.rbs +5 -10
  363. data/stdlib/socket/0/ip_socket.rbs +0 -2
  364. data/stdlib/socket/0/socket.rbs +77 -46
  365. data/stdlib/socket/0/tcp_server.rbs +0 -5
  366. data/stdlib/socket/0/tcp_socket.rbs +36 -3
  367. data/stdlib/socket/0/udp_socket.rbs +4 -5
  368. data/stdlib/socket/0/unix_server.rbs +0 -5
  369. data/stdlib/socket/0/unix_socket.rbs +2 -4
  370. data/{core/string_io.rbs → stdlib/stringio/0/stringio.rbs} +188 -107
  371. data/stdlib/strscan/0/string_scanner.rbs +1269 -425
  372. data/stdlib/tempfile/0/tempfile.rbs +224 -61
  373. data/stdlib/time/0/time.rbs +48 -35
  374. data/stdlib/timeout/0/timeout.rbs +17 -8
  375. data/stdlib/tmpdir/0/tmpdir.rbs +10 -3
  376. data/stdlib/tsort/0/tsort.rbs +0 -4
  377. data/stdlib/uri/0/common.rbs +271 -144
  378. data/stdlib/uri/0/file.rbs +5 -0
  379. data/stdlib/uri/0/ftp.rbs +1 -1
  380. data/stdlib/uri/0/generic.rbs +26 -22
  381. data/stdlib/uri/0/http.rbs +4 -4
  382. data/stdlib/uri/0/ldap.rbs +1 -1
  383. data/stdlib/uri/0/mailto.rbs +84 -0
  384. data/stdlib/uri/0/rfc2396_parser.rbs +3 -0
  385. data/stdlib/yaml/0/manifest.yaml +1 -2
  386. data/stdlib/yaml/0/yaml.rbs +1 -199
  387. data/stdlib/zlib/0/buf_error.rbs +10 -0
  388. data/stdlib/zlib/0/data_error.rbs +10 -0
  389. data/stdlib/zlib/0/deflate.rbs +210 -0
  390. data/stdlib/zlib/0/error.rbs +20 -0
  391. data/stdlib/zlib/0/gzip_file/crc_error.rbs +12 -0
  392. data/stdlib/zlib/0/gzip_file/error.rbs +23 -0
  393. data/stdlib/zlib/0/gzip_file/length_error.rbs +12 -0
  394. data/stdlib/zlib/0/gzip_file/no_footer.rbs +11 -0
  395. data/stdlib/zlib/0/gzip_file.rbs +156 -0
  396. data/stdlib/zlib/0/gzip_reader.rbs +293 -0
  397. data/stdlib/zlib/0/gzip_writer.rbs +166 -0
  398. data/stdlib/zlib/0/inflate.rbs +180 -0
  399. data/stdlib/zlib/0/mem_error.rbs +10 -0
  400. data/stdlib/zlib/0/need_dict.rbs +13 -0
  401. data/stdlib/zlib/0/stream_end.rbs +11 -0
  402. data/stdlib/zlib/0/stream_error.rbs +11 -0
  403. data/stdlib/zlib/0/version_error.rbs +11 -0
  404. data/stdlib/zlib/0/zlib.rbs +1 -3
  405. data/stdlib/zlib/0/zstream.rbs +200 -0
  406. data/templates/include/rbs/constants.h.erb +20 -0
  407. data/templates/include/rbs/ruby_objs.h.erb +10 -0
  408. data/templates/src/constants.c.erb +36 -0
  409. data/templates/src/ruby_objs.c.erb +27 -0
  410. data/templates/template.rb +122 -0
  411. metadata +136 -36
  412. data/Gemfile +0 -33
  413. data/Gemfile.lock +0 -118
  414. data/core/deprecated.rbs +0 -9
  415. data/ext/rbs_extension/constants.c +0 -135
  416. data/ext/rbs_extension/ruby_objs.c +0 -525
  417. data/ext/rbs_extension/ruby_objs.h +0 -43
  418. data/lib/rbs/constant_table.rb +0 -167
  419. data/lib/rbs/parser_compat/lexer_error.rb +0 -6
  420. data/lib/rbs/parser_compat/located_value.rb +0 -7
  421. data/lib/rbs/parser_compat/semantics_error.rb +0 -6
  422. data/lib/rbs/parser_compat/syntax_error.rb +0 -6
  423. data/lib/rbs/test/spy.rb +0 -6
  424. data/lib/rbs/type_name_resolver.rb +0 -67
  425. data/sig/constant_table.rbs +0 -30
  426. data/sig/shims/abstract_syntax_tree.rbs +0 -25
  427. data/sig/shims/pp.rbs +0 -3
  428. data/sig/shims/ripper.rbs +0 -8
  429. data/sig/shims.rbs +0 -69
  430. data/sig/type_name_resolver.rbs +0 -26
  431. data/stdlib/minitest/0/manifest.yaml +0 -2
  432. data/stdlib/prime/0/integer-extension.rbs +0 -41
  433. data/stdlib/prime/0/manifest.yaml +0 -2
  434. data/stdlib/prime/0/prime.rbs +0 -372
data/core/file.rbs CHANGED
@@ -1,330 +1,853 @@
1
1
  # <!-- rdoc-file=file.c -->
2
- # A File is an abstraction of any file object accessible by the program and is
3
- # closely associated with class IO. File includes the methods of module
4
- # FileTest as class methods, allowing you to write (for example)
5
- # `File.exist?("foo")`.
6
- #
7
- # In the description of File methods, *permission bits* are a platform-specific
8
- # set of bits that indicate permissions of a file. On Unix-based systems,
9
- # permissions are viewed as a set of three octets, for the owner, the group, and
10
- # the rest of the world. For each of these entities, permissions may be set to
11
- # read, write, or execute the file:
12
- #
13
- # The permission bits `0644` (in octal) would thus be interpreted as read/write
14
- # for owner, and read-only for group and other. Higher-order bits may also be
15
- # used to indicate the type of file (plain, directory, pipe, socket, and so on)
16
- # and various other special features. If the permissions are for a directory,
17
- # the meaning of the execute bit changes; when set the directory can be
18
- # searched.
19
- #
20
- # On non-Posix operating systems, there may be only the ability to make a file
21
- # read-only or read-write. In this case, the remaining permission bits will be
22
- # synthesized to resemble typical values. For instance, on Windows NT the
23
- # default permission bits are `0644`, which means read/write for owner,
24
- # read-only for all others. The only change that can be made is to make the file
25
- # read-only, which is reported as `0444`.
26
- #
27
- # Various constants for the methods in File can be found in File::Constants.
2
+ # A File object is a representation of a file in the underlying platform.
28
3
  #
29
- # ## What's Here
4
+ # Class File extends module FileTest, supporting such singleton methods as
5
+ # `File.exist?`.
30
6
  #
31
- # First, what's elsewhere. Class File:
7
+ # ## About the Examples
32
8
  #
33
- # * Inherits from [class IO](IO.html#class-IO-label-What-27s+Here), in
34
- # particular, methods for creating, reading, and writing files
35
- # * Includes [module
36
- # FileTest](FileTest.html#module-FileTest-label-What-27s+Here). which
37
- # provides dozens of additional methods.
9
+ # Many examples here use these variables:
38
10
  #
11
+ # # English text with newlines.
12
+ # text = <<~EOT
13
+ # First line
14
+ # Second line
39
15
  #
40
- # Here, class File provides methods that are useful for:
16
+ # Fourth line
17
+ # Fifth line
18
+ # EOT
41
19
  #
42
- # * [Creating](#class-File-label-Creating)
43
- # * [Querying](#class-File-label-Querying)
44
- # * [Settings](#class-File-label-Settings)
45
- # * [Other](#class-File-label-Other)
20
+ # # Russian text.
21
+ # russian = "\u{442 435 441 442}" # => "тест"
46
22
  #
23
+ # # Binary data.
24
+ # data = "\u9990\u9991\u9992\u9993\u9994"
47
25
  #
48
- # ### Creating
26
+ # # Text file.
27
+ # File.write('t.txt', text)
49
28
  #
50
- # ::new
51
- # : Opens the file at the given path; returns the file.
29
+ # # File with Russian text.
30
+ # File.write('t.rus', russian)
52
31
  #
53
- # ::open
54
- # : Same as ::new, but when given a block will yield the file to the
55
- # block, and close the file upon exiting the block.
32
+ # # File with binary data.
33
+ # f = File.new('t.dat', 'wb:UTF-16')
34
+ # f.write(data)
35
+ # f.close
56
36
  #
57
- # ::link
58
- # : Creates a new name for an existing file using a hard link.
37
+ # ## Access Modes
59
38
  #
60
- # ::mkfifo
61
- # : Returns the FIFO file created at the given path.
39
+ # Methods File.new and File.open each create a File object for a given file
40
+ # path.
62
41
  #
63
- # ::symlink
64
- # : Creates a symbolic link for the given file path.
42
+ # ### String Access Modes
65
43
  #
44
+ # Methods File.new and File.open each may take string argument `mode`, which:
66
45
  #
46
+ # * Begins with a 1- or 2-character [read/write
47
+ # mode](rdoc-ref:File@Read-2FWrite+Mode).
48
+ # * May also contain a 1-character [data mode](rdoc-ref:File@Data+Mode).
49
+ # * May also contain a 1-character [file-create
50
+ # mode](rdoc-ref:File@File-Create+Mode).
67
51
  #
68
- # ### Querying
52
+ # #### Read/Write Mode
69
53
  #
70
- # *Paths*
54
+ # The read/write `mode` determines:
71
55
  #
72
- # ::absolute_path
73
- # : Returns the absolute file path for the given path.
56
+ # * Whether the file is to be initially truncated.
74
57
  #
75
- # ::absolute_path?
76
- # : Returns whether the given path is the absolute file path.
58
+ # * Whether reading is allowed, and if so:
77
59
  #
78
- # ::basename
79
- # : Returns the last component of the given file path.
60
+ # * The initial read position in the file.
61
+ # * Where in the file reading can occur.
80
62
  #
81
- # ::dirname
82
- # : Returns all but the last component of the given file path.
63
+ # * Whether writing is allowed, and if so:
83
64
  #
84
- # ::expand_path
85
- # : Returns the absolute file path for the given path, expanding `~` for a
86
- # home directory.
65
+ # * The initial write position in the file.
66
+ # * Where in the file writing can occur.
87
67
  #
88
- # ::extname
89
- # : Returns the file extension for the given file path.
68
+ # These tables summarize:
90
69
  #
91
- # ::fnmatch? (aliased as ::fnmatch)
92
- # : Returns whether the given file path matches the given pattern.
70
+ # Read/Write Modes for Existing File
93
71
  #
94
- # ::join
95
- # : Joins path components into a single path string.
72
+ # |------|-----------|----------|----------|----------|-----------|
73
+ # | R/W | Initial | | Initial | | Initial |
74
+ # | Mode | Truncate? | Read | Read Pos | Write | Write Pos |
75
+ # |------|-----------|----------|----------|----------|-----------|
76
+ # | 'r' | No | Anywhere | 0 | Error | - |
77
+ # | 'w' | Yes | Error | - | Anywhere | 0 |
78
+ # | 'a' | No | Error | - | End only | End |
79
+ # | 'r+' | No | Anywhere | 0 | Anywhere | 0 |
80
+ # | 'w+' | Yes | Anywhere | 0 | Anywhere | 0 |
81
+ # | 'a+' | No | Anywhere | End | End only | End |
82
+ # |------|-----------|----------|----------|----------|-----------|
96
83
  #
97
- # ::path
98
- # : Returns the string representation of the given path.
84
+ # Read/Write Modes for \File To Be Created
99
85
  #
100
- # ::readlink
101
- # : Returns the path to the file at the given symbolic link.
86
+ # |------|----------|----------|----------|-----------|
87
+ # | R/W | | Initial | | Initial |
88
+ # | Mode | Read | Read Pos | Write | Write Pos |
89
+ # |------|----------|----------|----------|-----------|
90
+ # | 'w' | Error | - | Anywhere | 0 |
91
+ # | 'a' | Error | - | End only | 0 |
92
+ # | 'w+' | Anywhere | 0 | Anywhere | 0 |
93
+ # | 'a+' | Anywhere | 0 | End only | End |
94
+ # |------|----------|----------|----------|-----------|
102
95
  #
103
- # ::realdirpath
104
- # : Returns the real path for the given file path, where the last
105
- # component need not exist.
96
+ # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
97
+ # (exception raised).
106
98
  #
107
- # ::realpath
108
- # : Returns the real path for the given file path, where all components
109
- # must exist.
99
+ # In the tables:
110
100
  #
111
- # ::split
112
- # : Returns an array of two strings: the directory name and basename of
113
- # the file at the given path.
101
+ # * `Anywhere` means that methods IO#rewind, IO#pos=, and IO#seek may be used
102
+ # to change the file's position, so that allowed reading or writing may
103
+ # occur anywhere in the file.
104
+ # * `End only` means that writing can occur only at end-of-file, and that
105
+ # methods IO#rewind, IO#pos=, and IO#seek do not affect writing.
106
+ # * `Error` means that an exception is raised if disallowed reading or writing
107
+ # is attempted.
114
108
  #
115
- # #path (aliased as #to_path)
116
- # : Returns the string representation of the given path.
109
+ # ##### Read/Write Modes for Existing File
117
110
  #
111
+ # * `'r'`:
118
112
  #
113
+ # * File is not initially truncated:
119
114
  #
120
- # *Times*
115
+ # f = File.new('t.txt') # => #<File:t.txt>
116
+ # f.size == 0 # => false
121
117
  #
122
- # ::atime
123
- # : Returns a Time for the most recent access to the given file.
118
+ # * File's initial read position is 0:
124
119
  #
125
- # ::birthtime
126
- # : Returns a Time for the creation of the given file.
120
+ # f.pos # => 0
127
121
  #
128
- # ::ctime
129
- # : Returns a Time for the metadata change of the given file.
122
+ # * File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:
130
123
  #
131
- # ::mtime
132
- # : Returns a Time for the most recent data modification to the content of
133
- # the given file.
124
+ # f.readline # => "First line\n"
125
+ # f.readline # => "Second line\n"
134
126
  #
135
- # #atime
136
- # : Returns a Time for the most recent access to `self`.
127
+ # f.rewind
128
+ # f.readline # => "First line\n"
137
129
  #
138
- # #birthtime
139
- # : Returns a Time the creation for `self`.
130
+ # f.pos = 1
131
+ # f.readline # => "irst line\n"
140
132
  #
141
- # #ctime
142
- # : Returns a Time for the metadata change of `self`.
133
+ # f.seek(1, :CUR)
134
+ # f.readline # => "econd line\n"
143
135
  #
144
- # #mtime
145
- # : Returns a Time for the most recent data modification to the content of
146
- # `self`.
136
+ # * Writing is not allowed:
147
137
  #
138
+ # f.write('foo') # Raises IOError.
148
139
  #
140
+ # * `'w'`:
149
141
  #
150
- # *Types*
142
+ # * File is initially truncated:
151
143
  #
152
- # ::blockdev?
153
- # : Returns whether the file at the given path is a block device.
144
+ # path = 't.tmp'
145
+ # File.write(path, text)
146
+ # f = File.new(path, 'w')
147
+ # f.size == 0 # => true
154
148
  #
155
- # ::chardev?
156
- # : Returns whether the file at the given path is a character device.
149
+ # * File's initial write position is 0:
157
150
  #
158
- # ::directory?
159
- # : Returns whether the file at the given path is a diretory.
151
+ # f.pos # => 0
160
152
  #
161
- # ::executable?
162
- # : Returns whether the file at the given path is executable by the
163
- # effective user and group of the current process.
153
+ # * File may be written anywhere (even past end-of-file); see IO#rewind,
154
+ # IO#pos=, IO#seek:
164
155
  #
165
- # ::executable_real?
166
- # : Returns whether the file at the given path is executable by the real
167
- # user and group of the current process.
156
+ # f.write('foo')
157
+ # f.flush
158
+ # File.read(path) # => "foo"
159
+ # f.pos # => 3
168
160
  #
169
- # ::exist?
170
- # : Returns whether the file at the given path exists.
161
+ # f.write('bar')
162
+ # f.flush
163
+ # File.read(path) # => "foobar"
164
+ # f.pos # => 6
171
165
  #
172
- # ::file?
173
- # : Returns whether the file at the given path is a regular file.
166
+ # f.rewind
167
+ # f.write('baz')
168
+ # f.flush
169
+ # File.read(path) # => "bazbar"
170
+ # f.pos # => 3
174
171
  #
175
- # ::ftype
176
- # : Returns a string giving the type of the file at the given path.
172
+ # f.pos = 3
173
+ # f.write('foo')
174
+ # f.flush
175
+ # File.read(path) # => "bazfoo"
176
+ # f.pos # => 6
177
177
  #
178
- # ::grpowned?
179
- # : Returns whether the effective group of the current process owns the
180
- # file at the given path.
178
+ # f.seek(-3, :END)
179
+ # f.write('bam')
180
+ # f.flush
181
+ # File.read(path) # => "bazbam"
182
+ # f.pos # => 6
181
183
  #
182
- # ::identical?
183
- # : Returns whether the files at two given paths are identical.
184
+ # f.pos = 8
185
+ # f.write('bah') # Zero padding as needed.
186
+ # f.flush
187
+ # File.read(path) # => "bazbam\u0000\u0000bah"
188
+ # f.pos # => 11
184
189
  #
185
- # ::lstat
186
- # : Returns the File::Stat object for the last symbolic link in the given
187
- # path.
190
+ # * Reading is not allowed:
188
191
  #
189
- # ::owned?
190
- # : Returns whether the effective user of the current process owns the
191
- # file at the given path.
192
+ # f.read # Raises IOError.
192
193
  #
193
- # ::pipe?
194
- # : Returns whether the file at the given path is a pipe.
194
+ # * `'a'`:
195
195
  #
196
- # ::readable?
197
- # : Returns whether the file at the given path is readable by the
198
- # effective user and group of the current process.
196
+ # * File is not initially truncated:
199
197
  #
200
- # ::readable_real?
201
- # : Returns whether the file at the given path is readable by the real
202
- # user and group of the current process.
198
+ # path = 't.tmp'
199
+ # File.write(path, 'foo')
200
+ # f = File.new(path, 'a')
201
+ # f.size == 0 # => false
203
202
  #
204
- # ::setgid?
205
- # : Returns whether the setgid bit is set for the file at the given path.
203
+ # * File's initial position is 0 (but is ignored):
206
204
  #
207
- # ::setuid?
208
- # : Returns whether the setuid bit is set for the file at the given path.
205
+ # f.pos # => 0
209
206
  #
210
- # ::socket?
211
- # : Returns whether the file at the given path is a socket.
207
+ # * File may be written only at end-of-file; IO#rewind, IO#pos=, IO#seek
208
+ # do not affect writing:
212
209
  #
213
- # ::stat
214
- # : Returns the File::Stat object for the file at the given path.
210
+ # f.write('bar')
211
+ # f.flush
212
+ # File.read(path) # => "foobar"
213
+ # f.write('baz')
214
+ # f.flush
215
+ # File.read(path) # => "foobarbaz"
215
216
  #
216
- # ::sticky?
217
- # : Returns whether the file at the given path has its sticky bit set.
217
+ # f.rewind
218
+ # f.write('bat')
219
+ # f.flush
220
+ # File.read(path) # => "foobarbazbat"
218
221
  #
219
- # ::symlink?
220
- # : Returns whether the file at the given path is a symbolic link.
222
+ # * Reading is not allowed:
221
223
  #
222
- # ::umask
223
- # : Returns the umask value for the current process.
224
+ # f.read # Raises IOError.
224
225
  #
225
- # ::world_readable?
226
- # : Returns whether the file at the given path is readable by others.
226
+ # * `'r+'`:
227
227
  #
228
- # ::world_writable?
229
- # : Returns whether the file at the given path is writable by others.
228
+ # * File is not initially truncated:
230
229
  #
231
- # ::writable?
232
- # : Returns whether the file at the given path is writable by the
233
- # effective user and group of the current process.
230
+ # path = 't.tmp'
231
+ # File.write(path, text)
232
+ # f = File.new(path, 'r+')
233
+ # f.size == 0 # => false
234
234
  #
235
- # ::writable_real?
236
- # : Returns whether the file at the given path is writable by the real
237
- # user and group of the current process.
235
+ # * File's initial read position is 0:
238
236
  #
239
- # #lstat
240
- # : Returns the File::Stat object for the last symbolic link in the path
241
- # for `self`.
237
+ # f.pos # => 0
242
238
  #
239
+ # * File may be read or written anywhere (even past end-of-file); see
240
+ # IO#rewind, IO#pos=, IO#seek:
243
241
  #
242
+ # f.readline # => "First line\n"
243
+ # f.readline # => "Second line\n"
244
244
  #
245
- # *Contents*
245
+ # f.rewind
246
+ # f.readline # => "First line\n"
246
247
  #
247
- # ::empty? (aliased as ::zero?)
248
- # : Returns whether the file at the given path exists and is empty.
248
+ # f.pos = 1
249
+ # f.readline # => "irst line\n"
249
250
  #
250
- # ::size
251
- # : Returns the size (bytes) of the file at the given path.
251
+ # f.seek(1, :CUR)
252
+ # f.readline # => "econd line\n"
252
253
  #
253
- # ::size?
254
- # : Returns `nil` if there is no file at the given path, or if that file
255
- # is empty; otherwise returns the file size (bytes).
254
+ # f.rewind
255
+ # f.write('WWW')
256
+ # f.flush
257
+ # File.read(path)
258
+ # # => "WWWst line\nSecond line\nFourth line\nFifth line\n"
256
259
  #
257
- # #size
258
- # : Returns the size (bytes) of `self`.
260
+ # f.pos = 10
261
+ # f.write('XXX')
262
+ # f.flush
263
+ # File.read(path)
264
+ # # => "WWWst lineXXXecond line\nFourth line\nFifth line\n"
259
265
  #
266
+ # f.seek(-6, :END)
267
+ # # => 0
268
+ # f.write('YYY')
269
+ # # => 3
270
+ # f.flush
271
+ # # => #<File:t.tmp>
272
+ # File.read(path)
273
+ # # => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n"
260
274
  #
275
+ # f.seek(2, :END)
276
+ # f.write('ZZZ') # Zero padding as needed.
277
+ # f.flush
278
+ # File.read(path)
279
+ # # => "WWWst lineXXXecond line\nFourth line\nFifth YYYe\n\u0000\u0000ZZZ"
261
280
  #
262
- # ### Settings
281
+ # * `'a+'`:
263
282
  #
264
- # ::chmod
265
- # : Changes permissions of the file at the given path.
283
+ # * File is not initially truncated:
266
284
  #
267
- # ::chown
268
- # : Change ownership of the file at the given path.
285
+ # path = 't.tmp'
286
+ # File.write(path, 'foo')
287
+ # f = File.new(path, 'a+')
288
+ # f.size == 0 # => false
269
289
  #
270
- # ::lchmod
271
- # : Changes permissions of the last symbolic link in the given path.
290
+ # * File's initial read position is 0:
272
291
  #
273
- # ::lchown
274
- # : Change ownership of the last symbolic in the given path.
292
+ # f.pos # => 0
275
293
  #
276
- # ::lutime
277
- # : For each given file path, sets the access time and modification time
278
- # of the last symbolic link in the path.
294
+ # * File may be written only at end-of-file; IO#rewind, IO#pos=, IO#seek
295
+ # do not affect writing:
279
296
  #
280
- # ::rename
281
- # : Moves the file at one given path to another given path.
297
+ # f.write('bar')
298
+ # f.flush
299
+ # File.read(path) # => "foobar"
300
+ # f.write('baz')
301
+ # f.flush
302
+ # File.read(path) # => "foobarbaz"
282
303
  #
283
- # ::utime
284
- # : Sets the access time and modification time of each file at the given
285
- # paths.
304
+ # f.rewind
305
+ # f.write('bat')
306
+ # f.flush
307
+ # File.read(path) # => "foobarbazbat"
286
308
  #
287
- # #flock
288
- # : Locks or unlocks `self`.
309
+ # * File may be read anywhere; see IO#rewind, IO#pos=, IO#seek:
289
310
  #
311
+ # f.rewind
312
+ # f.read # => "foobarbazbat"
290
313
  #
314
+ # f.pos = 3
315
+ # f.read # => "barbazbat"
291
316
  #
292
- # ### Other
317
+ # f.seek(-3, :END)
318
+ # f.read # => "bat"
319
+ #
320
+ # ##### Read/Write Modes for File To Be Created
321
+ #
322
+ # Note that modes `'r'` and `'r+'` are not allowed for a non-existent file
323
+ # (exception raised).
324
+ #
325
+ # * `'w'`:
326
+ #
327
+ # * File's initial write position is 0:
328
+ #
329
+ # path = 't.tmp'
330
+ # FileUtils.rm_f(path)
331
+ # f = File.new(path, 'w')
332
+ # f.pos # => 0
333
+ #
334
+ # * File may be written anywhere (even past end-of-file); see IO#rewind,
335
+ # IO#pos=, IO#seek:
336
+ #
337
+ # f.write('foo')
338
+ # f.flush
339
+ # File.read(path) # => "foo"
340
+ # f.pos # => 3
341
+ #
342
+ # f.write('bar')
343
+ # f.flush
344
+ # File.read(path) # => "foobar"
345
+ # f.pos # => 6
346
+ #
347
+ # f.rewind
348
+ # f.write('baz')
349
+ # f.flush
350
+ # File.read(path) # => "bazbar"
351
+ # f.pos # => 3
352
+ #
353
+ # f.pos = 3
354
+ # f.write('foo')
355
+ # f.flush
356
+ # File.read(path) # => "bazfoo"
357
+ # f.pos # => 6
358
+ #
359
+ # f.seek(-3, :END)
360
+ # f.write('bam')
361
+ # f.flush
362
+ # File.read(path) # => "bazbam"
363
+ # f.pos # => 6
364
+ #
365
+ # f.pos = 8
366
+ # f.write('bah') # Zero padding as needed.
367
+ # f.flush
368
+ # File.read(path) # => "bazbam\u0000\u0000bah"
369
+ # f.pos # => 11
370
+ #
371
+ # * Reading is not allowed:
372
+ #
373
+ # f.read # Raises IOError.
374
+ #
375
+ # * `'a'`:
376
+ #
377
+ # * File's initial write position is 0:
378
+ #
379
+ # path = 't.tmp'
380
+ # FileUtils.rm_f(path)
381
+ # f = File.new(path, 'a')
382
+ # f.pos # => 0
383
+ #
384
+ # * Writing occurs only at end-of-file:
385
+ #
386
+ # f.write('foo')
387
+ # f.pos # => 3
388
+ # f.write('bar')
389
+ # f.pos # => 6
390
+ # f.flush
391
+ # File.read(path) # => "foobar"
392
+ #
393
+ # f.rewind
394
+ # f.write('baz')
395
+ # f.flush
396
+ # File.read(path) # => "foobarbaz"
397
+ #
398
+ # * Reading is not allowed:
399
+ #
400
+ # f.read # Raises IOError.
401
+ #
402
+ # * `'w+'`:
403
+ #
404
+ # * File's initial position is 0:
405
+ #
406
+ # path = 't.tmp'
407
+ # FileUtils.rm_f(path)
408
+ # f = File.new(path, 'w+')
409
+ # f.pos # => 0
410
+ #
411
+ # * File may be written anywhere (even past end-of-file); see IO#rewind,
412
+ # IO#pos=, IO#seek:
413
+ #
414
+ # f.write('foo')
415
+ # f.flush
416
+ # File.read(path) # => "foo"
417
+ # f.pos # => 3
418
+ #
419
+ # f.write('bar')
420
+ # f.flush
421
+ # File.read(path) # => "foobar"
422
+ # f.pos # => 6
423
+ #
424
+ # f.rewind
425
+ # f.write('baz')
426
+ # f.flush
427
+ # File.read(path) # => "bazbar"
428
+ # f.pos # => 3
429
+ #
430
+ # f.pos = 3
431
+ # f.write('foo')
432
+ # f.flush
433
+ # File.read(path) # => "bazfoo"
434
+ # f.pos # => 6
435
+ #
436
+ # f.seek(-3, :END)
437
+ # f.write('bam')
438
+ # f.flush
439
+ # File.read(path) # => "bazbam"
440
+ # f.pos # => 6
441
+ #
442
+ # f.pos = 8
443
+ # f.write('bah') # Zero padding as needed.
444
+ # f.flush
445
+ # File.read(path) # => "bazbam\u0000\u0000bah"
446
+ # f.pos # => 11
447
+ #
448
+ # * File may be read anywhere (even past end-of-file); see IO#rewind,
449
+ # IO#pos=, IO#seek:
450
+ #
451
+ # f.rewind
452
+ # # => 0
453
+ # f.read
454
+ # # => "bazbam\u0000\u0000bah"
455
+ #
456
+ # f.pos = 3
457
+ # # => 3
458
+ # f.read
459
+ # # => "bam\u0000\u0000bah"
460
+ #
461
+ # f.seek(-3, :END)
462
+ # # => 0
463
+ # f.read
464
+ # # => "bah"
465
+ #
466
+ # * `'a+'`:
467
+ #
468
+ # * File's initial write position is 0:
469
+ #
470
+ # path = 't.tmp'
471
+ # FileUtils.rm_f(path)
472
+ # f = File.new(path, 'a+')
473
+ # f.pos # => 0
474
+ #
475
+ # * Writing occurs only at end-of-file:
476
+ #
477
+ # f.write('foo')
478
+ # f.pos # => 3
479
+ # f.write('bar')
480
+ # f.pos # => 6
481
+ # f.flush
482
+ # File.read(path) # => "foobar"
483
+ #
484
+ # f.rewind
485
+ # f.write('baz')
486
+ # f.flush
487
+ # File.read(path) # => "foobarbaz"
488
+ #
489
+ # * File may be read anywhere (even past end-of-file); see IO#rewind,
490
+ # IO#pos=, IO#seek:
491
+ #
492
+ # f.rewind
493
+ # f.read # => "foobarbaz"
494
+ #
495
+ # f.pos = 3
496
+ # f.read # => "barbaz"
497
+ #
498
+ # f.seek(-3, :END)
499
+ # f.read # => "baz"
500
+ #
501
+ # f.pos = 800
502
+ # f.read # => ""
503
+ #
504
+ # #### Data Mode
505
+ #
506
+ # To specify whether data is to be treated as text or as binary data, either of
507
+ # the following may be suffixed to any of the string read/write modes above:
508
+ #
509
+ # * `'t'`: Text data; sets the default external encoding to `Encoding::UTF_8`;
510
+ # on Windows, enables conversion between EOL and CRLF and enables
511
+ # interpreting `0x1A` as an end-of-file marker.
512
+ # * `'b'`: Binary data; sets the default external encoding to
513
+ # `Encoding::ASCII_8BIT`; on Windows, suppresses conversion between EOL and
514
+ # CRLF and disables interpreting `0x1A` as an end-of-file marker.
515
+ #
516
+ # If neither is given, the stream defaults to text data.
517
+ #
518
+ # Examples:
519
+ #
520
+ # File.new('t.txt', 'rt')
521
+ # File.new('t.dat', 'rb')
522
+ #
523
+ # When the data mode is specified, the read/write mode may not be omitted, and
524
+ # the data mode must precede the file-create mode, if given:
525
+ #
526
+ # File.new('t.dat', 'b') # Raises an exception.
527
+ # File.new('t.dat', 'rxb') # Raises an exception.
528
+ #
529
+ # #### File-Create Mode
530
+ #
531
+ # The following may be suffixed to any writable string mode above:
532
+ #
533
+ # * `'x'`: Creates the file if it does not exist; raises an exception if the
534
+ # file exists.
535
+ #
536
+ # Example:
537
+ #
538
+ # File.new('t.tmp', 'wx')
539
+ #
540
+ # When the file-create mode is specified, the read/write mode may not be
541
+ # omitted, and the file-create mode must follow the data mode:
542
+ #
543
+ # File.new('t.dat', 'x') # Raises an exception.
544
+ # File.new('t.dat', 'rxb') # Raises an exception.
545
+ #
546
+ # ### Integer Access Modes
547
+ #
548
+ # When mode is an integer it must be one or more of the following constants,
549
+ # which may be combined by the bitwise OR operator `|`:
550
+ #
551
+ # * `File::RDONLY`: Open for reading only.
552
+ # * `File::WRONLY`: Open for writing only.
553
+ # * `File::RDWR`: Open for reading and writing.
554
+ # * `File::APPEND`: Open for appending only.
555
+ #
556
+ # Examples:
557
+ #
558
+ # File.new('t.txt', File::RDONLY)
559
+ # File.new('t.tmp', File::RDWR | File::CREAT | File::EXCL)
560
+ #
561
+ # Note: Method IO#set_encoding does not allow the mode to be specified as an
562
+ # integer.
563
+ #
564
+ # ### File-Create Mode Specified as an Integer
565
+ #
566
+ # These constants may also be ORed into the integer mode:
567
+ #
568
+ # * `File::CREAT`: Create file if it does not exist.
569
+ # * `File::EXCL`: Raise an exception if `File::CREAT` is given and the file
570
+ # exists.
571
+ #
572
+ # ### Data Mode Specified as an Integer
573
+ #
574
+ # Data mode cannot be specified as an integer. When the stream access mode is
575
+ # given as an integer, the data mode is always text, never binary.
293
576
  #
294
- # ::truncate
295
- # : Truncates the file at the given file path to the given size.
577
+ # Note that although there is a constant `File::BINARY`, setting its value in an
578
+ # integer stream mode has no effect; this is because, as documented in
579
+ # File::Constants, the `File::BINARY` value disables line code conversion, but
580
+ # does not change the external encoding.
296
581
  #
297
- # ::unlink (aliased as ::delete)
298
- # : Deletes the file for each given file path.
582
+ # ### Encodings
299
583
  #
300
- # #truncate
301
- # : Truncates `self` to the given size.
584
+ # Any of the string modes above may specify encodings - either external encoding
585
+ # only or both external and internal encodings - by appending one or both
586
+ # encoding names, separated by colons:
587
+ #
588
+ # f = File.new('t.dat', 'rb')
589
+ # f.external_encoding # => #<Encoding:ASCII-8BIT>
590
+ # f.internal_encoding # => nil
591
+ # f = File.new('t.dat', 'rb:UTF-16')
592
+ # f.external_encoding # => #<Encoding:UTF-16 (dummy)>
593
+ # f.internal_encoding # => nil
594
+ # f = File.new('t.dat', 'rb:UTF-16:UTF-16')
595
+ # f.external_encoding # => #<Encoding:UTF-16 (dummy)>
596
+ # f.internal_encoding # => #<Encoding:UTF-16>
597
+ # f.close
598
+ #
599
+ # The numerous encoding names are available in array Encoding.name_list:
600
+ #
601
+ # Encoding.name_list.take(3) # => ["ASCII-8BIT", "UTF-8", "US-ASCII"]
602
+ #
603
+ # When the external encoding is set, strings read are tagged by that encoding
604
+ # when reading, and strings written are converted to that encoding when writing.
605
+ #
606
+ # When both external and internal encodings are set, strings read are converted
607
+ # from external to internal encoding, and strings written are converted from
608
+ # internal to external encoding. For further details about transcoding input and
609
+ # output, see [Encodings](rdoc-ref:encodings.rdoc@Encodings).
610
+ #
611
+ # If the external encoding is `'BOM|UTF-8'`, `'BOM|UTF-16LE'` or
612
+ # `'BOM|UTF16-BE'`, Ruby checks for a Unicode BOM in the input document to help
613
+ # determine the encoding. For UTF-16 encodings the file open mode must be
614
+ # binary. If the BOM is found, it is stripped and the external encoding from the
615
+ # BOM is used.
616
+ #
617
+ # Note that the BOM-style encoding option is case insensitive, so `'bom|utf-8'`
618
+ # is also valid.
619
+ #
620
+ # ## File Permissions
621
+ #
622
+ # A File object has *permissions*, an octal integer representing the permissions
623
+ # of an actual file in the underlying platform.
624
+ #
625
+ # Note that file permissions are quite different from the *mode* of a file
626
+ # stream (File object).
627
+ #
628
+ # In a File object, the permissions are available thus, where method `mode`,
629
+ # despite its name, returns permissions:
630
+ #
631
+ # f = File.new('t.txt')
632
+ # f.lstat.mode.to_s(8) # => "100644"
633
+ #
634
+ # On a Unix-based operating system, the three low-order octal digits represent
635
+ # the permissions for owner (6), group (4), and world (4). The triplet of bits
636
+ # in each octal digit represent, respectively, read, write, and execute
637
+ # permissions.
638
+ #
639
+ # Permissions `0644` thus represent read-write access for owner and read-only
640
+ # access for group and world. See man pages
641
+ # [open(2)](https://www.unix.com/man-page/bsd/2/open) and
642
+ # [chmod(2)](https://www.unix.com/man-page/bsd/2/chmod).
643
+ #
644
+ # For a directory, the meaning of the execute bit changes: when set, the
645
+ # directory can be searched.
646
+ #
647
+ # Higher-order bits in permissions may indicate the type of file (plain,
648
+ # directory, pipe, socket, etc.) and various other special features.
649
+ #
650
+ # On non-Posix operating systems, permissions may include only read-only or
651
+ # read-write, in which case, the remaining permission will resemble typical
652
+ # values. On Windows, for instance, the default permissions are `0644`; The only
653
+ # change that can be made is to make the file read-only, which is reported as
654
+ # `0444`.
655
+ #
656
+ # For a method that actually creates a file in the underlying platform (as
657
+ # opposed to merely creating a File object), permissions may be specified:
658
+ #
659
+ # File.new('t.tmp', File::CREAT, 0644)
660
+ # File.new('t.tmp', File::CREAT, 0444)
661
+ #
662
+ # Permissions may also be changed:
663
+ #
664
+ # f = File.new('t.tmp', File::CREAT, 0444)
665
+ # f.chmod(0644)
666
+ # f.chmod(0444)
667
+ #
668
+ # ## File Constants
669
+ #
670
+ # Various constants for use in File and IO methods may be found in module
671
+ # File::Constants; an array of their names is returned by
672
+ # `File::Constants.constants`.
673
+ #
674
+ # ## What's Here
675
+ #
676
+ # First, what's elsewhere. Class File:
677
+ #
678
+ # * Inherits from [class IO](rdoc-ref:IO@What-27s+Here), in particular,
679
+ # methods for creating, reading, and writing files
680
+ # * Includes module FileTest, which provides dozens of additional methods.
681
+ #
682
+ # Here, class File provides methods that are useful for:
683
+ #
684
+ # * [Creating](rdoc-ref:File@Creating)
685
+ # * [Querying](rdoc-ref:File@Querying)
686
+ # * [Settings](rdoc-ref:File@Settings)
687
+ # * [Other](rdoc-ref:File@Other)
688
+ #
689
+ # ### Creating
690
+ #
691
+ # * ::new: Opens the file at the given path; returns the file.
692
+ # * ::open: Same as ::new, but when given a block will yield the file to the
693
+ # block, and close the file upon exiting the block.
694
+ # * ::link: Creates a new name for an existing file using a hard link.
695
+ # * ::mkfifo: Returns the FIFO file created at the given path.
696
+ # * ::symlink: Creates a symbolic link for the given file path.
697
+ #
698
+ # ### Querying
699
+ #
700
+ # *Paths*
701
+ #
702
+ # * ::absolute_path: Returns the absolute file path for the given path.
703
+ # * ::absolute_path?: Returns whether the given path is the absolute file
704
+ # path.
705
+ # * ::basename: Returns the last component of the given file path.
706
+ # * ::dirname: Returns all but the last component of the given file path.
707
+ # * ::expand_path: Returns the absolute file path for the given path,
708
+ # expanding `~` for a home directory.
709
+ # * ::extname: Returns the file extension for the given file path.
710
+ # * ::fnmatch? (aliased as ::fnmatch): Returns whether the given file path
711
+ # matches the given pattern.
712
+ # * ::join: Joins path components into a single path string.
713
+ # * ::path: Returns the string representation of the given path.
714
+ # * ::readlink: Returns the path to the file at the given symbolic link.
715
+ # * ::realdirpath: Returns the real path for the given file path, where the
716
+ # last component need not exist.
717
+ # * ::realpath: Returns the real path for the given file path, where all
718
+ # components must exist.
719
+ # * ::split: Returns an array of two strings: the directory name and basename
720
+ # of the file at the given path.
721
+ # * #path (aliased as #to_path): Returns the string representation of the
722
+ # given path.
723
+ #
724
+ # *Times*
725
+ #
726
+ # * ::atime: Returns a Time for the most recent access to the given file.
727
+ # * ::birthtime: Returns a Time for the creation of the given file.
728
+ # * ::ctime: Returns a Time for the metadata change of the given file.
729
+ # * ::mtime: Returns a Time for the most recent data modification to the
730
+ # content of the given file.
731
+ # * #atime: Returns a Time for the most recent access to `self`.
732
+ # * #birthtime: Returns a Time the creation for `self`.
733
+ # * #ctime: Returns a Time for the metadata change of `self`.
734
+ # * #mtime: Returns a Time for the most recent data modification to the
735
+ # content of `self`.
736
+ #
737
+ # *Types*
738
+ #
739
+ # * ::blockdev?: Returns whether the file at the given path is a block device.
740
+ # * ::chardev?: Returns whether the file at the given path is a character
741
+ # device.
742
+ # * ::directory?: Returns whether the file at the given path is a directory.
743
+ # * ::executable?: Returns whether the file at the given path is executable by
744
+ # the effective user and group of the current process.
745
+ # * ::executable_real?: Returns whether the file at the given path is
746
+ # executable by the real user and group of the current process.
747
+ # * ::exist?: Returns whether the file at the given path exists.
748
+ # * ::file?: Returns whether the file at the given path is a regular file.
749
+ # * ::ftype: Returns a string giving the type of the file at the given path.
750
+ # * ::grpowned?: Returns whether the effective group of the current process
751
+ # owns the file at the given path.
752
+ # * ::identical?: Returns whether the files at two given paths are identical.
753
+ # * ::lstat: Returns the File::Stat object for the last symbolic link in the
754
+ # given path.
755
+ # * ::owned?: Returns whether the effective user of the current process owns
756
+ # the file at the given path.
757
+ # * ::pipe?: Returns whether the file at the given path is a pipe.
758
+ # * ::readable?: Returns whether the file at the given path is readable by the
759
+ # effective user and group of the current process.
760
+ # * ::readable_real?: Returns whether the file at the given path is readable
761
+ # by the real user and group of the current process.
762
+ # * ::setgid?: Returns whether the setgid bit is set for the file at the given
763
+ # path.
764
+ # * ::setuid?: Returns whether the setuid bit is set for the file at the given
765
+ # path.
766
+ # * ::socket?: Returns whether the file at the given path is a socket.
767
+ # * ::stat: Returns the File::Stat object for the file at the given path.
768
+ # * ::sticky?: Returns whether the file at the given path has its sticky bit
769
+ # set.
770
+ # * ::symlink?: Returns whether the file at the given path is a symbolic link.
771
+ # * ::umask: Returns the umask value for the current process.
772
+ # * ::world_readable?: Returns whether the file at the given path is readable
773
+ # by others.
774
+ # * ::world_writable?: Returns whether the file at the given path is writable
775
+ # by others.
776
+ # * ::writable?: Returns whether the file at the given path is writable by the
777
+ # effective user and group of the current process.
778
+ # * ::writable_real?: Returns whether the file at the given path is writable
779
+ # by the real user and group of the current process.
780
+ # * #lstat: Returns the File::Stat object for the last symbolic link in the
781
+ # path for `self`.
782
+ #
783
+ # *Contents*
784
+ #
785
+ # * ::empty? (aliased as ::zero?): Returns whether the file at the given path
786
+ # exists and is empty.
787
+ # * ::size: Returns the size (bytes) of the file at the given path.
788
+ # * ::size?: Returns `nil` if there is no file at the given path, or if that
789
+ # file is empty; otherwise returns the file size (bytes).
790
+ # * #size: Returns the size (bytes) of `self`.
791
+ #
792
+ # ### Settings
793
+ #
794
+ # * ::chmod: Changes permissions of the file at the given path.
795
+ # * ::chown: Change ownership of the file at the given path.
796
+ # * ::lchmod: Changes permissions of the last symbolic link in the given path.
797
+ # * ::lchown: Change ownership of the last symbolic in the given path.
798
+ # * ::lutime: For each given file path, sets the access time and modification
799
+ # time of the last symbolic link in the path.
800
+ # * ::rename: Moves the file at one given path to another given path.
801
+ # * ::utime: Sets the access time and modification time of each file at the
802
+ # given paths.
803
+ # * #flock: Locks or unlocks `self`.
804
+ #
805
+ # ### Other
806
+ #
807
+ # * ::truncate: Truncates the file at the given file path to the given size.
808
+ # * ::unlink (aliased as ::delete): Deletes the file for each given file path.
809
+ # * #truncate: Truncates `self` to the given size.
302
810
  #
303
811
  class File < IO
304
812
  # <!--
305
813
  # rdoc-file=io.c
306
- # - File.new(filename, mode="r" [, opt]) -> file
307
- # - File.new(filename [, mode [, perm]] [, opt]) -> file
814
+ # - File.new(path, mode = 'r', perm = 0666, **opts) -> file
308
815
  # -->
309
- # Opens the file named by `filename` according to the given `mode` and returns a
310
- # new File object.
816
+ # Opens the file at the given `path` according to the given `mode`; creates and
817
+ # returns a new File object for that file.
311
818
  #
312
- # See IO.new for a description of `mode` and `opt`.
819
+ # The new File object is buffered mode (or non-sync mode), unless `filename` is
820
+ # a tty. See IO#flush, IO#fsync, IO#fdatasync, and IO#sync=.
313
821
  #
314
- # If a file is being created, permission bits may be given in `perm`. These
315
- # mode and permission bits are platform dependent; on Unix systems, see open(2)
316
- # and chmod(2) man pages for details.
822
+ # Argument `path` must be a valid file path:
317
823
  #
318
- # The new File object is buffered mode (or non-sync mode), unless `filename` is
319
- # a tty. See IO#flush, IO#fsync, IO#fdatasync, and IO#sync= about sync mode.
824
+ # f = File.new('/etc/fstab')
825
+ # f.close
826
+ # f = File.new('t.txt')
827
+ # f.close
828
+ #
829
+ # Optional argument `mode` (defaults to 'r') must specify a valid mode; see
830
+ # [Access Modes](rdoc-ref:File@Access+Modes):
831
+ #
832
+ # f = File.new('t.tmp', 'w')
833
+ # f.close
834
+ # f = File.new('t.tmp', File::RDONLY)
835
+ # f.close
320
836
  #
321
- # ### Examples
837
+ # Optional argument `perm` (defaults to 0666) must specify valid permissions see
838
+ # [File Permissions](rdoc-ref:File@File+Permissions):
322
839
  #
323
- # f = File.new("testfile", "r")
324
- # f = File.new("newfile", "w+")
325
- # f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
840
+ # f = File.new('t.tmp', File::CREAT, 0644)
841
+ # f.close
842
+ # f = File.new('t.tmp', File::CREAT, 0444)
843
+ # f.close
326
844
  #
327
- def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> File
845
+ # Optional keyword arguments `opts` specify:
846
+ #
847
+ # * [Open Options](rdoc-ref:IO@Open+Options).
848
+ # * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
849
+ #
850
+ def initialize: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> void
328
851
 
329
852
  # <!--
330
853
  # rdoc-file=file.c
@@ -380,28 +903,37 @@ class File < IO
380
903
 
381
904
  # <!--
382
905
  # rdoc-file=file.c
383
- # - birthtime(p1)
906
+ # - File.birthtime(file_name) -> time
384
907
  # -->
908
+ # Returns the birth time for the named file.
909
+ #
910
+ # *file_name* can be an IO object.
911
+ #
912
+ # File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
913
+ #
914
+ # If the platform doesn't have birthtime, raises NotImplementedError.
385
915
  #
386
916
  def self.birthtime: (string | _ToPath | IO file_name) -> Time
387
917
 
388
918
  # <!--
389
919
  # rdoc-file=file.c
390
- # - File.blockdev?(file_name) -> true or false
920
+ # - File.blockdev?(filepath) -> true or false
391
921
  # -->
392
- # Returns `true` if the named file is a block device.
922
+ # Returns `true` if `filepath` points to a block device, `false` otherwise:
393
923
  #
394
- # *file_name* can be an IO object.
924
+ # File.blockdev?('/dev/sda1') # => true
925
+ # File.blockdev?(File.new('t.tmp')) # => false
395
926
  #
396
927
  def self.blockdev?: (string | _ToPath | IO file_name) -> bool
397
928
 
398
929
  # <!--
399
930
  # rdoc-file=file.c
400
- # - File.chardev?(file_name) -> true or false
931
+ # - File.chardev?(filepath) -> true or false
401
932
  # -->
402
- # Returns `true` if the named file is a character device.
933
+ # Returns `true` if `filepath` points to a character device, `false` otherwise.
403
934
  #
404
- # *file_name* can be an IO object.
935
+ # File.chardev?($stdin) # => true
936
+ # File.chardev?('t.txt') # => false
405
937
  #
406
938
  def self.chardev?: (string | _ToPath | IO file_name) -> bool
407
939
 
@@ -464,14 +996,19 @@ class File < IO
464
996
 
465
997
  # <!--
466
998
  # rdoc-file=file.c
467
- # - File.directory?(file_name) -> true or false
999
+ # - File.directory?(path) -> true or false
468
1000
  # -->
469
- # Returns `true` if the named file is a directory, or a symlink that points at a
470
- # directory, and `false` otherwise.
1001
+ # With string `object` given, returns `true` if `path` is a string path leading
1002
+ # to a directory, or to a symbolic link to a directory; `false` otherwise:
471
1003
  #
472
- # *file_name* can be an IO object.
1004
+ # File.directory?('.') # => true
1005
+ # File.directory?('foo') # => false
1006
+ # File.symlink('.', 'dirlink') # => 0
1007
+ # File.directory?('dirlink') # => true
1008
+ # File.symlink('t,txt', 'filelink') # => 0
1009
+ # File.directory?('filelink') # => false
473
1010
  #
474
- # File.directory?(".")
1011
+ # Argument `path` can be an IO object.
475
1012
  #
476
1013
  def self.directory?: (string | _ToPath | IO path) -> bool
477
1014
 
@@ -628,10 +1165,13 @@ class File < IO
628
1165
  #
629
1166
  # `*`
630
1167
  # : Matches all regular files
1168
+ #
631
1169
  # `c*`
632
1170
  # : Matches all files beginning with `c`
1171
+ #
633
1172
  # `*c`
634
1173
  # : Matches all files ending with `c`
1174
+ #
635
1175
  # `*c*`
636
1176
  # : Matches all files that have `c` in them (including at the beginning or
637
1177
  # end).
@@ -640,19 +1180,24 @@ class File < IO
640
1180
  # To match hidden files (that start with a `.`) set the File::FNM_DOTMATCH
641
1181
  # flag.
642
1182
  #
1183
+ #
643
1184
  # `**`
644
1185
  # : Matches directories recursively or files expansively.
645
1186
  #
1187
+ #
646
1188
  # `?`
647
1189
  # : Matches any one character. Equivalent to `/.{1}/` in regexp.
648
1190
  #
1191
+ #
649
1192
  # `[set]`
650
1193
  # : Matches any one character in `set`. Behaves exactly like character sets
651
1194
  # in Regexp, including set negation (`[^a-z]`).
652
1195
  #
1196
+ #
653
1197
  # `\`
654
1198
  # : Escapes the next metacharacter.
655
1199
  #
1200
+ #
656
1201
  # `{a,b}`
657
1202
  # : Matches pattern a and pattern b if File::FNM_EXTGLOB flag is enabled.
658
1203
  # Behaves like a Regexp union (`(?:a|b)`).
@@ -769,7 +1314,7 @@ class File < IO
769
1314
  #
770
1315
  # File.join("usr", "mail", "gumby") #=> "usr/mail/gumby"
771
1316
  #
772
- def self.join: (*string) -> String
1317
+ def self.join: (*path) -> String
773
1318
 
774
1319
  # <!--
775
1320
  # rdoc-file=file.c
@@ -806,15 +1351,14 @@ class File < IO
806
1351
 
807
1352
  # <!--
808
1353
  # rdoc-file=file.c
809
- # - File.lstat(file_name) -> stat
1354
+ # - File.lstat(filepath) -> stat
810
1355
  # -->
811
- # Same as File::stat, but does not follow the last symbolic link. Instead,
812
- # reports on the link itself.
1356
+ # Like File::stat, but does not follow the last symbolic link; instead, returns
1357
+ # a File::Stat object for the link itself.
813
1358
  #
814
- # File.symlink("testfile", "link2test") #=> 0
815
- # File.stat("testfile").size #=> 66
816
- # File.lstat("link2test").size #=> 8
817
- # File.stat("link2test").size #=> 66
1359
+ # File.symlink('t.txt', 'symlink')
1360
+ # File.stat('symlink').size # => 47
1361
+ # File.lstat('symlink').size # => 5
818
1362
  #
819
1363
  def self.lstat: (string | _ToPath file_name) -> File::Stat
820
1364
 
@@ -853,20 +1397,15 @@ class File < IO
853
1397
 
854
1398
  # <!--
855
1399
  # rdoc-file=io.c
856
- # - File.open(filename, mode="r" [, opt]) -> file
857
- # - File.open(filename [, mode [, perm]] [, opt]) -> file
858
- # - File.open(filename, mode="r" [, opt]) {|file| block } -> obj
859
- # - File.open(filename [, mode [, perm]] [, opt]) {|file| block } -> obj
1400
+ # - File.open(path, mode = 'r', perm = 0666, **opts) -> file
1401
+ # - File.open(path, mode = 'r', perm = 0666, **opts) {|f| ... } -> object
860
1402
  # -->
861
- # With no associated block, File.open is a synonym for File.new. If the optional
862
- # code block is given, it will be passed the opened `file` as an argument and
863
- # the File object will automatically be closed when the block terminates. The
864
- # value of the block will be returned from File.open.
1403
+ # Creates a new File object, via File.new with the given arguments.
865
1404
  #
866
- # If a file is being created, its initial permissions may be set using the
867
- # `perm` parameter. See File.new for further discussion.
1405
+ # With no block given, returns the File object.
868
1406
  #
869
- # See IO.new for a description of the `mode` and `opt` parameters.
1407
+ # With a block given, calls the block with the File object and returns the
1408
+ # block's value.
870
1409
  #
871
1410
  def self.open: (string | _ToPath | int file_name, ?string | int mode, ?int perm) -> instance
872
1411
  | [T] (string | _ToPath | int file_name, ?string | int mode, ?int perm) { (File) -> T } -> T
@@ -888,18 +1427,20 @@ class File < IO
888
1427
  # -->
889
1428
  # Returns the string representation of the path
890
1429
  #
891
- # File.path("/dev/null") #=> "/dev/null"
1430
+ # File.path(File::NULL) #=> "/dev/null"
892
1431
  # File.path(Pathname.new("/tmp")) #=> "/tmp"
893
1432
  #
894
1433
  def self.path: (string | _ToPath path) -> String
895
1434
 
896
1435
  # <!--
897
1436
  # rdoc-file=file.c
898
- # - File.pipe?(file_name) -> true or false
1437
+ # - File.pipe?(filepath) -> true or false
899
1438
  # -->
900
- # Returns `true` if the named file is a pipe.
1439
+ # Returns `true` if `filepath` points to a pipe, `false` otherwise:
901
1440
  #
902
- # *file_name* can be an IO object.
1441
+ # File.mkfifo('tmp/fifo')
1442
+ # File.pipe?('tmp/fifo') # => true
1443
+ # File.pipe?('t.txt') # => false
903
1444
  #
904
1445
  def self.pipe?: (string | _ToPath | IO file_name) -> bool
905
1446
 
@@ -1021,11 +1562,13 @@ class File < IO
1021
1562
 
1022
1563
  # <!--
1023
1564
  # rdoc-file=file.c
1024
- # - File.socket?(file_name) -> true or false
1565
+ # - File.socket?(filepath) -> true or false
1025
1566
  # -->
1026
- # Returns `true` if the named file is a socket.
1567
+ # Returns `true` if `filepath` points to a socket, `false` otherwise:
1027
1568
  #
1028
- # *file_name* can be an IO object.
1569
+ # require 'socket'
1570
+ # File.socket?(Socket.new(:INET, :STREAM)) # => true
1571
+ # File.socket?(File.new('t.txt')) # => false
1029
1572
  #
1030
1573
  def self.socket?: (string | _ToPath | IO file_name) -> bool
1031
1574
 
@@ -1042,11 +1585,11 @@ class File < IO
1042
1585
 
1043
1586
  # <!--
1044
1587
  # rdoc-file=file.c
1045
- # - File.stat(file_name) -> stat
1588
+ # - File.stat(filepath) -> stat
1046
1589
  # -->
1047
- # Returns a File::Stat object for the named file (see File::Stat).
1590
+ # Returns a File::Stat object for the file at `filepath` (see File::Stat):
1048
1591
  #
1049
- # File.stat("testfile").mtime #=> Tue Apr 08 12:58:04 CDT 2003
1592
+ # File.stat('t.txt').class # => File::Stat
1050
1593
  #
1051
1594
  def self.stat: (string | _ToPath file_name) -> File::Stat
1052
1595
 
@@ -1074,9 +1617,13 @@ class File < IO
1074
1617
 
1075
1618
  # <!--
1076
1619
  # rdoc-file=file.c
1077
- # - File.symlink?(file_name) -> true or false
1620
+ # - File.symlink?(filepath) -> true or false
1078
1621
  # -->
1079
- # Returns `true` if the named file is a symbolic link.
1622
+ # Returns `true` if `filepath` points to a symbolic link, `false` otherwise:
1623
+ #
1624
+ # symlink = File.symlink('t.txt', 'symlink')
1625
+ # File.symlink?('symlink') # => true
1626
+ # File.symlink?('t.txt') # => false
1080
1627
  #
1081
1628
  def self.symlink?: (string | _ToPath file_name) -> bool
1082
1629
 
@@ -1202,8 +1749,6 @@ class File < IO
1202
1749
  #
1203
1750
  def self.zero?: (string | _ToPath | IO file_name) -> bool
1204
1751
 
1205
- public
1206
-
1207
1752
  # <!--
1208
1753
  # rdoc-file=file.c
1209
1754
  # - file.atime -> time
@@ -1269,58 +1814,51 @@ class File < IO
1269
1814
 
1270
1815
  # <!--
1271
1816
  # rdoc-file=file.c
1272
- # - file.flock(locking_constant) -> 0 or false
1817
+ # - flock(locking_constant) -> 0 or false
1273
1818
  # -->
1274
- # Locks or unlocks a file according to *locking_constant* (a logical *or* of the
1275
- # values in the table below). Returns `false` if File::LOCK_NB is specified and
1276
- # the operation would otherwise have blocked. Not available on all platforms.
1277
- #
1278
- # Locking constants (in class File):
1279
- #
1280
- # LOCK_EX | Exclusive lock. Only one process may hold an
1281
- # | exclusive lock for a given file at a time.
1282
- # ----------+------------------------------------------------
1283
- # LOCK_NB | Don't block when locking. May be combined
1284
- # | with other lock options using logical or.
1285
- # ----------+------------------------------------------------
1286
- # LOCK_SH | Shared lock. Multiple processes may each hold a
1287
- # | shared lock for a given file at the same time.
1288
- # ----------+------------------------------------------------
1289
- # LOCK_UN | Unlock.
1290
- #
1819
+ # Locks or unlocks file `self` according to the given `locking_constant`,
1820
+ # a bitwise OR of the values in the table below.
1821
+ # Not available on all platforms.
1822
+ # Returns `false` if `File::LOCK_NB` is specified and the operation would have
1823
+ # blocked;
1824
+ # otherwise returns `0`.
1825
+ # Constant | Lock | Effect
1826
+ # ---------------|------------|--------------------------------------------------------------------------------------------------------------
1827
+ # +File::LOCK_EX+| Exclusive | Only one process may hold an exclusive lock for +self+ at a time.
1828
+ # +File::LOCK_NB+|Non-blocking|No blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <tt>|</tt>.
1829
+ # +File::LOCK_SH+| Shared | Multiple processes may each hold a shared lock for +self+ at the same time.
1830
+ # +File::LOCK_UN+| Unlock | Remove an existing lock held by this process.
1291
1831
  # Example:
1292
- #
1293
- # # update a counter using write lock
1294
- # # don't use "w" because it truncates the file before lock.
1295
- # File.open("counter", File::RDWR|File::CREAT, 0644) {|f|
1296
- # f.flock(File::LOCK_EX)
1297
- # value = f.read.to_i + 1
1298
- # f.rewind
1299
- # f.write("#{value}\n")
1300
- # f.flush
1301
- # f.truncate(f.pos)
1302
- # }
1303
- #
1304
- # # read the counter using read lock
1305
- # File.open("counter", "r") {|f|
1306
- # f.flock(File::LOCK_SH)
1307
- # p f.read
1308
- # }
1832
+ # # Update a counter using an exclusive lock.
1833
+ # # Don't use File::WRONLY because it truncates the file.
1834
+ # File.open('counter', File::RDWR | File::CREAT, 0644) do |f|
1835
+ # f.flock(File::LOCK_EX)
1836
+ # value = f.read.to_i + 1
1837
+ # f.rewind
1838
+ # f.write("#{value}\n")
1839
+ # f.flush
1840
+ # f.truncate(f.pos)
1841
+ # end
1842
+ #
1843
+ # # Read the counter using a shared lock.
1844
+ # File.open('counter', 'r') do |f|
1845
+ # f.flock(File::LOCK_SH)
1846
+ # f.read
1847
+ # end
1309
1848
  #
1310
1849
  def flock: (int locking_constant) -> (0 | false)
1311
1850
 
1312
1851
  # <!--
1313
1852
  # rdoc-file=file.c
1314
- # - file.lstat -> stat
1853
+ # - lstat -> stat
1315
1854
  # -->
1316
- # Same as IO#stat, but does not follow the last symbolic link. Instead, reports
1317
- # on the link itself.
1855
+ # Like File#stat, but does not follow the last symbolic link; instead, returns a
1856
+ # File::Stat object for the link itself:
1318
1857
  #
1319
- # File.symlink("testfile", "link2test") #=> 0
1320
- # File.stat("testfile").size #=> 66
1321
- # f = File.new("link2test")
1322
- # f.lstat.size #=> 8
1323
- # f.stat.size #=> 66
1858
+ # File.symlink('t.txt', 'symlink')
1859
+ # f = File.new('symlink')
1860
+ # f.stat.size # => 47
1861
+ # f.lstat.size # => 11
1324
1862
  #
1325
1863
  def lstat: () -> (File::Stat | nil)
1326
1864
 
@@ -1355,8 +1893,11 @@ class File < IO
1355
1893
 
1356
1894
  # <!--
1357
1895
  # rdoc-file=file.c
1358
- # - size()
1896
+ # - file.size -> integer
1359
1897
  # -->
1898
+ # Returns the size of *file* in bytes.
1899
+ #
1900
+ # File.new("testfile").size #=> 66
1360
1901
  #
1361
1902
  def size: () -> Integer
1362
1903
 
@@ -1411,67 +1952,468 @@ File::SEPARATOR: String
1411
1952
  #
1412
1953
  File::Separator: String
1413
1954
 
1955
+ # <!-- rdoc-file=file.c -->
1956
+ # Module `File::Constants` defines file-related constants.
1957
+ #
1958
+ # There are two families of constants here:
1959
+ #
1960
+ # * Those having to do with [file
1961
+ # access](rdoc-ref:File::Constants@File+Access).
1962
+ # * Those having to do with [filename
1963
+ # globbing](rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A-
1964
+ # 3AFNM_-2A-29).
1965
+ #
1966
+ # File constants defined for the local process may be retrieved with method
1967
+ # File::Constants.constants:
1968
+ #
1969
+ # File::Constants.constants.take(5)
1970
+ # # => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT]
1971
+ #
1972
+ # ## File Access
1973
+ #
1974
+ # File-access constants may be used with optional argument `mode` in calls to
1975
+ # the following methods:
1976
+ #
1977
+ # * File.new.
1978
+ # * File.open.
1979
+ # * IO.for_fd.
1980
+ # * IO.new.
1981
+ # * IO.open.
1982
+ # * IO.popen.
1983
+ # * IO.reopen.
1984
+ # * IO.sysopen.
1985
+ # * StringIO.new.
1986
+ # * StringIO.open.
1987
+ # * StringIO#reopen.
1988
+ #
1989
+ # ### Read/Write Access
1990
+ #
1991
+ # Read-write access for a stream may be specified by a file-access constant.
1992
+ #
1993
+ # The constant may be specified as part of a bitwise OR of other such constants.
1994
+ #
1995
+ # Any combination of the constants in this section may be specified.
1996
+ #
1997
+ # #### File::RDONLY
1998
+ #
1999
+ # Flag File::RDONLY specifies the stream should be opened for reading only:
2000
+ #
2001
+ # filepath = '/tmp/t.tmp'
2002
+ # f = File.new(filepath, File::RDONLY)
2003
+ # f.write('Foo') # Raises IOError (not opened for writing).
2004
+ #
2005
+ # #### File::WRONLY
2006
+ #
2007
+ # Flag File::WRONLY specifies that the stream should be opened for writing only:
2008
+ #
2009
+ # f = File.new(filepath, File::WRONLY)
2010
+ # f.read # Raises IOError (not opened for reading).
2011
+ #
2012
+ # #### File::RDWR
2013
+ #
2014
+ # Flag File::RDWR specifies that the stream should be opened for both reading
2015
+ # and writing:
2016
+ #
2017
+ # f = File.new(filepath, File::RDWR)
2018
+ # f.write('Foo') # => 3
2019
+ # f.rewind # => 0
2020
+ # f.read # => "Foo"
2021
+ #
2022
+ # ### File Positioning
2023
+ #
2024
+ # #### File::APPEND
2025
+ #
2026
+ # Flag File::APPEND specifies that the stream should be opened in append mode.
2027
+ #
2028
+ # Before each write operation, the position is set to end-of-stream. The
2029
+ # modification of the position and the following write operation are performed
2030
+ # as a single atomic step.
2031
+ #
2032
+ # #### File::TRUNC
2033
+ #
2034
+ # Flag File::TRUNC specifies that the stream should be truncated at its
2035
+ # beginning. If the file exists and is successfully opened for writing, it is to
2036
+ # be truncated to position zero; its ctime and mtime are updated.
2037
+ #
2038
+ # There is no effect on a FIFO special file or a terminal device. The effect on
2039
+ # other file types is implementation-defined. The result of using File::TRUNC
2040
+ # with File::RDONLY is undefined.
2041
+ #
2042
+ # ### Creating and Preserving
2043
+ #
2044
+ # #### File::CREAT
2045
+ #
2046
+ # Flag File::CREAT specifies that the stream should be created if it does not
2047
+ # already exist.
2048
+ #
2049
+ # If the file exists:
2050
+ #
2051
+ # - Raise an exception if File::EXCL is also specified.
2052
+ # - Otherwise, do nothing.
2053
+ #
2054
+ # If the file does not exist, then it is created. Upon successful completion,
2055
+ # the atime, ctime, and mtime of the file are updated, and the ctime and mtime
2056
+ # of the parent directory are updated.
2057
+ #
2058
+ # #### File::EXCL
2059
+ #
2060
+ # Flag File::EXCL specifies that the stream should not already exist; If flags
2061
+ # File::CREAT and File::EXCL are both specified and the stream already exists,
2062
+ # an exception is raised.
2063
+ #
2064
+ # The check for the existence and creation of the file is performed as an atomic
2065
+ # operation.
2066
+ #
2067
+ # If both File::EXCL and File::CREAT are specified and the path names a symbolic
2068
+ # link, an exception is raised regardless of the contents of the symbolic link.
2069
+ #
2070
+ # If File::EXCL is specified and File::CREAT is not specified, the result is
2071
+ # undefined.
2072
+ #
2073
+ # ### POSIX File Constants
2074
+ #
2075
+ # Some file-access constants are defined only on POSIX-compliant systems; those
2076
+ # are:
2077
+ #
2078
+ # * File::SYNC.
2079
+ # * File::DSYNC.
2080
+ # * File::RSYNC.
2081
+ # * File::DIRECT.
2082
+ # * File::NOATIME.
2083
+ # * File::NOCTTY.
2084
+ # * File::NOFOLLOW.
2085
+ # * File::TMPFILE.
2086
+ #
2087
+ # #### File::SYNC, File::RSYNC, and File::DSYNC
2088
+ #
2089
+ # Flag File::SYNC, File::RSYNC, or File::DSYNC specifies synchronization of I/O
2090
+ # operations with the underlying file system.
2091
+ #
2092
+ # These flags are valid only for POSIX-compliant systems.
2093
+ #
2094
+ # * File::SYNC specifies that all write operations (both data and metadata)
2095
+ # are immediately to be flushed to the underlying storage device. This means
2096
+ # that the data is written to the storage device, and the file's metadata
2097
+ # (e.g., file size, timestamps, permissions) are also synchronized. This
2098
+ # guarantees that data is safely stored on the storage medium before
2099
+ # returning control to the calling program. This flag can have a significant
2100
+ # impact on performance since it requires synchronous writes, which can be
2101
+ # slower compared to asynchronous writes.
2102
+ #
2103
+ # * File::RSYNC specifies that any read operations on the file will not return
2104
+ # until all outstanding write operations (those that have been issued but
2105
+ # not completed) are also synchronized. This is useful when you want to read
2106
+ # the most up-to-date data, which may still be in the process of being
2107
+ # written.
2108
+ #
2109
+ # * File::DSYNC specifies that all *data* write operations are immediately to
2110
+ # be flushed to the underlying storage device; this differs from File::SYNC,
2111
+ # which requires that *metadata* also be synchronized.
2112
+ #
2113
+ # Note that the behavior of these flags may vary slightly depending on the
2114
+ # operating system and filesystem being used. Additionally, using these flags
2115
+ # can have an impact on performance due to the synchronous nature of the I/O
2116
+ # operations, so they should be used judiciously, especially in
2117
+ # performance-critical applications.
2118
+ #
2119
+ # #### File::NOCTTY
2120
+ #
2121
+ # Flag File::NOCTTY specifies that if the stream is a terminal device, that
2122
+ # device does not become the controlling terminal for the process.
2123
+ #
2124
+ # Defined only for POSIX-compliant systems.
2125
+ #
2126
+ # #### File::DIRECT
2127
+ #
2128
+ # Flag File::DIRECT requests that cache effects of the I/O to and from the
2129
+ # stream be minimized.
2130
+ #
2131
+ # Defined only for POSIX-compliant systems.
2132
+ #
2133
+ # #### File::NOATIME
2134
+ #
2135
+ # Flag File::NOATIME specifies that act of opening the stream should not modify
2136
+ # its access time (atime).
2137
+ #
2138
+ # Defined only for POSIX-compliant systems.
2139
+ #
2140
+ # #### File::NOFOLLOW
2141
+ #
2142
+ # Flag File::NOFOLLOW specifies that if path is a symbolic link, it should not
2143
+ # be followed.
2144
+ #
2145
+ # Defined only for POSIX-compliant systems.
2146
+ #
2147
+ # #### File::TMPFILE
2148
+ #
2149
+ # Flag File::TMPFILE specifies that the opened stream should be a new temporary
2150
+ # file.
2151
+ #
2152
+ # Defined only for POSIX-compliant systems.
2153
+ #
2154
+ # ### Other File-Access Constants
2155
+ #
2156
+ # #### File::NONBLOCK
2157
+ #
2158
+ # When possible, the file is opened in nonblocking mode. Neither the open
2159
+ # operation nor any subsequent I/O operations on the file will cause the calling
2160
+ # process to wait.
2161
+ #
2162
+ # #### File::BINARY
2163
+ #
2164
+ # Flag File::BINARY specifies that the stream is to be accessed in binary mode.
2165
+ #
2166
+ # #### File::SHARE_DELETE
2167
+ #
2168
+ # Flag File::SHARE_DELETE enables other processes to open the stream with delete
2169
+ # access.
2170
+ #
2171
+ # Windows only.
2172
+ #
2173
+ # If the stream is opened for (local) delete access without File::SHARE_DELETE,
2174
+ # and another process attempts to open it with delete access, the attempt fails
2175
+ # and the stream is not opened for that process.
2176
+ #
2177
+ # ## Locking
2178
+ #
2179
+ # Four file constants relate to stream locking; see File#flock:
2180
+ #
2181
+ # #### File::LOCK_EX
2182
+ #
2183
+ # Flag File::LOCK_EX specifies an exclusive lock; only one process a a time may
2184
+ # lock the stream.
2185
+ #
2186
+ # #### File::LOCK_NB
2187
+ #
2188
+ # Flag File::LOCK_NB specifies non-blocking locking for the stream; may be
2189
+ # combined with File::LOCK_EX or File::LOCK_SH.
2190
+ #
2191
+ # #### File::LOCK_SH
2192
+ #
2193
+ # Flag File::LOCK_SH specifies that multiple processes may lock the stream at
2194
+ # the same time.
2195
+ #
2196
+ # #### File::LOCK_UN
2197
+ #
2198
+ # Flag File::LOCK_UN specifies that the stream is not to be locked.
2199
+ #
2200
+ # ## Filename Globbing Constants (File::FNM_*)
2201
+ #
2202
+ # Filename-globbing constants may be used with optional argument `flags` in
2203
+ # calls to the following methods:
2204
+ #
2205
+ # * Dir.glob.
2206
+ # * File.fnmatch.
2207
+ # * Pathname#fnmatch.
2208
+ # * Pathname.glob.
2209
+ # * Pathname#glob.
2210
+ #
2211
+ # The constants are:
2212
+ #
2213
+ # #### File::FNM_CASEFOLD
2214
+ #
2215
+ # Flag File::FNM_CASEFOLD makes patterns case insensitive for File.fnmatch (but
2216
+ # not Dir.glob).
2217
+ #
2218
+ # #### File::FNM_DOTMATCH
2219
+ #
2220
+ # Flag File::FNM_DOTMATCH makes the `'*'` pattern match a filename starting with
2221
+ # `'.'`.
2222
+ #
2223
+ # #### File::FNM_EXTGLOB
2224
+ #
2225
+ # Flag File::FNM_EXTGLOB enables pattern `'{*a*,*b*}'`, which matches pattern
2226
+ # '*a*' and pattern '*b*'; behaves like a [regexp union](rdoc-ref:Regexp.union)
2227
+ # (e.g., `'(?:*a*|*b*)'`):
2228
+ #
2229
+ # pattern = '{LEGAL,BSDL}'
2230
+ # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
2231
+ # Pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
2232
+ # pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
2233
+ #
2234
+ # #### File::FNM_NOESCAPE
2235
+ #
2236
+ # Flag File::FNM_NOESCAPE disables `'\'` escaping.
2237
+ #
2238
+ # #### File::FNM_PATHNAME
2239
+ #
2240
+ # Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match
2241
+ # the directory separator (the value of constant File::SEPARATOR).
2242
+ #
2243
+ # #### File::FNM_SHORTNAME
2244
+ #
2245
+ # Flag File::FNM_SHORTNAME allows patterns to match short names if they exist.
2246
+ #
2247
+ # Windows only.
2248
+ #
2249
+ # #### File::FNM_SYSCASE
2250
+ #
2251
+ # Flag File::FNM_SYSCASE specifies that case sensitivity is the same as in the
2252
+ # underlying operating system; effective for File.fnmatch, but not Dir.glob.
2253
+ #
2254
+ # ## Other Constants
2255
+ #
2256
+ # #### File::NULL
2257
+ #
2258
+ # Flag File::NULL contains the string value of the null device:
2259
+ #
2260
+ # * On a Unix-like OS, `'/dev/null'`.
2261
+ # * On Windows, `'NUL'`.
2262
+ #
1414
2263
  module File::Constants
1415
2264
  end
1416
2265
 
2266
+ # <!-- rdoc-file=file.c -->
2267
+ # [File::APPEND](rdoc-ref:File::Constants@File-3A-3AAPPEND)
2268
+ #
1417
2269
  File::Constants::APPEND: Integer
1418
2270
 
2271
+ # <!-- rdoc-file=file.c -->
2272
+ # [File::BINARY](rdoc-ref:File::Constants@File-3A-3ABINARY)
2273
+ #
1419
2274
  File::Constants::BINARY: Integer
1420
2275
 
2276
+ # <!-- rdoc-file=file.c -->
2277
+ # [File::CREAT](rdoc-ref:File::Constants@File-3A-3ACREAT)
2278
+ #
1421
2279
  File::Constants::CREAT: Integer
1422
2280
 
2281
+ # <!-- rdoc-file=file.c -->
2282
+ # [File::DIRECT](rdoc-ref:File::Constants@File-3A-3ADIRECT)
2283
+ #
1423
2284
  File::Constants::DIRECT: Integer
1424
2285
 
2286
+ # <!-- rdoc-file=file.c -->
2287
+ # [File::DSYNC](rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+an
2288
+ # d+File-3A-3ADSYNC)
2289
+ #
1425
2290
  File::Constants::DSYNC: Integer
1426
2291
 
2292
+ # <!-- rdoc-file=file.c -->
2293
+ # [File::EXCL](rdoc-ref:File::Constants@File-3A-3AEXCL)
2294
+ #
1427
2295
  File::Constants::EXCL: Integer
1428
2296
 
2297
+ # <!-- rdoc-file=dir.c -->
2298
+ # [File::FNM_CASEFOLD](rdoc-ref:File::Constants@File-3A-3AFNM_CASEFOLD)
2299
+ #
1429
2300
  File::Constants::FNM_CASEFOLD: Integer
1430
2301
 
2302
+ # <!-- rdoc-file=dir.c -->
2303
+ # [File::FNM_DOTMATCH](rdoc-ref:File::Constants@File-3A-3AFNM_DOTMATCH)
2304
+ #
1431
2305
  File::Constants::FNM_DOTMATCH: Integer
1432
2306
 
2307
+ # <!-- rdoc-file=dir.c -->
2308
+ # [File::FNM_EXTGLOB](rdoc-ref:File::Constants@File-3A-3AFNM_EXTGLOB)
2309
+ #
1433
2310
  File::Constants::FNM_EXTGLOB: Integer
1434
2311
 
2312
+ # <!-- rdoc-file=dir.c -->
2313
+ # [File::FNM_NOESCAPE](rdoc-ref:File::Constants@File-3A-3AFNM_NOESCAPE)
2314
+ #
1435
2315
  File::Constants::FNM_NOESCAPE: Integer
1436
2316
 
2317
+ # <!-- rdoc-file=dir.c -->
2318
+ # [File::FNM_PATHNAME](rdoc-ref:File::Constants@File-3A-3AFNM_PATHNAME)
2319
+ #
1437
2320
  File::Constants::FNM_PATHNAME: Integer
1438
2321
 
2322
+ # <!-- rdoc-file=dir.c -->
2323
+ # [File::FNM_SHORTNAME](rdoc-ref:File::Constants@File-3A-3AFNM_SHORTNAME)
2324
+ #
1439
2325
  File::Constants::FNM_SHORTNAME: Integer
1440
2326
 
2327
+ # <!-- rdoc-file=dir.c -->
2328
+ # [File::FNM_SYSCASE](rdoc-ref:File::Constants@File-3A-3AFNM_SYSCASE)
2329
+ #
1441
2330
  File::Constants::FNM_SYSCASE: Integer
1442
2331
 
2332
+ # <!-- rdoc-file=file.c -->
2333
+ # [File::LOCK_EX](rdoc-ref:File::Constants@File-3A-3ALOCK_EX)
2334
+ #
1443
2335
  File::Constants::LOCK_EX: Integer
1444
2336
 
2337
+ # <!-- rdoc-file=file.c -->
2338
+ # [File::LOCK_NB](rdoc-ref:File::Constants@File-3A-3ALOCK_NB)
2339
+ #
1445
2340
  File::Constants::LOCK_NB: Integer
1446
2341
 
2342
+ # <!-- rdoc-file=file.c -->
2343
+ # [File::LOCK_SH](rdoc-ref:File::Constants@File-3A-3ALOCK_SH)
2344
+ #
1447
2345
  File::Constants::LOCK_SH: Integer
1448
2346
 
2347
+ # <!-- rdoc-file=file.c -->
2348
+ # [File::LOCK_UN](rdoc-ref:File::Constants@File-3A-3ALOCK_UN)
2349
+ #
1449
2350
  File::Constants::LOCK_UN: Integer
1450
2351
 
2352
+ # <!-- rdoc-file=file.c -->
2353
+ # [File::NOATIME](rdoc-ref:File::Constants@File-3A-3ANOATIME)
2354
+ #
1451
2355
  File::Constants::NOATIME: Integer
1452
2356
 
2357
+ # <!-- rdoc-file=file.c -->
2358
+ # [File::NOCTTY](rdoc-ref:File::Constants@File-3A-3ANOCTTY)
2359
+ #
1453
2360
  File::Constants::NOCTTY: Integer
1454
2361
 
2362
+ # <!-- rdoc-file=file.c -->
2363
+ # [File::NOFOLLOW](rdoc-ref:File::Constants@File-3A-3ANOFOLLOW)
2364
+ #
1455
2365
  File::Constants::NOFOLLOW: Integer
1456
2366
 
2367
+ # <!-- rdoc-file=file.c -->
2368
+ # [File::NONBLOCK](rdoc-ref:File::Constants@File-3A-3ANONBLOCK)
2369
+ #
1457
2370
  File::Constants::NONBLOCK: Integer
1458
2371
 
2372
+ # <!-- rdoc-file=file.c -->
2373
+ # [File::NULL](rdoc-ref:File::Constants@File-3A-3ANULL)
2374
+ #
1459
2375
  File::Constants::NULL: String
1460
2376
 
2377
+ # <!-- rdoc-file=file.c -->
2378
+ # [File::RDONLY](rdoc-ref:File::Constants@File-3A-3ARDONLY)
2379
+ #
1461
2380
  File::Constants::RDONLY: Integer
1462
2381
 
2382
+ # <!-- rdoc-file=file.c -->
2383
+ # [File::RDWR](rdoc-ref:File::Constants@File-3A-3ARDWR)
2384
+ #
1463
2385
  File::Constants::RDWR: Integer
1464
2386
 
2387
+ # <!-- rdoc-file=file.c -->
2388
+ # [File::RSYNC](rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+an
2389
+ # d+File-3A-3ADSYNC)
2390
+ #
1465
2391
  File::Constants::RSYNC: Integer
1466
2392
 
2393
+ # <!-- rdoc-file=file.c -->
2394
+ # [File::SHARE_DELETE](rdoc-ref:File::Constants@File-3A-3ASHARE_DELETE)
2395
+ #
1467
2396
  File::Constants::SHARE_DELETE: Integer
1468
2397
 
2398
+ # <!-- rdoc-file=file.c -->
2399
+ # [File::SYNC](rdoc-ref:File::Constants@File-3A-3ASYNC-2C+File-3A-3ARSYNC-2C+and
2400
+ # +File-3A-3ADSYNC)
2401
+ #
1469
2402
  File::Constants::SYNC: Integer
1470
2403
 
2404
+ # <!-- rdoc-file=file.c -->
2405
+ # [File::TMPFILE](rdoc-ref:File::Constants@File-3A-3ATMPFILE)
2406
+ #
1471
2407
  File::Constants::TMPFILE: Integer
1472
2408
 
2409
+ # <!-- rdoc-file=file.c -->
2410
+ # [File::TRUNC](rdoc-ref:File::Constants@File-3A-3ATRUNC)
2411
+ #
1473
2412
  File::Constants::TRUNC: Integer
1474
2413
 
2414
+ # <!-- rdoc-file=file.c -->
2415
+ # [File::WRONLY](rdoc-ref:File::Constants@File-3A-3AWRONLY)
2416
+ #
1475
2417
  File::Constants::WRONLY: Integer
1476
2418
 
1477
2419
  # <!-- rdoc-file=file.c -->
@@ -1487,8 +2429,10 @@ class File::Stat < Object
1487
2429
 
1488
2430
  # <!--
1489
2431
  # rdoc-file=file.c
1490
- # - File::Stat.new(file_name) -> stat
2432
+ # - new(p1)
1491
2433
  # -->
2434
+ # File::Stat.new(file_name) -> stat
2435
+ #
1492
2436
  # Create a File::Stat object for the given file name (raising an exception if
1493
2437
  # the file doesn't exist).
1494
2438
  #
@@ -1522,7 +2466,7 @@ class File::Stat < Object
1522
2466
 
1523
2467
  # <!--
1524
2468
  # rdoc-file=file.c
1525
- # - stat.birthtime -> aTime
2469
+ # - stat.birthtime -> time
1526
2470
  # -->
1527
2471
  # Returns the birth time for *stat*.
1528
2472
  #
@@ -1589,7 +2533,7 @@ class File::Stat < Object
1589
2533
 
1590
2534
  # <!--
1591
2535
  # rdoc-file=file.c
1592
- # - stat.ctime -> aTime
2536
+ # - stat.ctime -> time
1593
2537
  # -->
1594
2538
  # Returns the change time for *stat* (that is, the time directory information
1595
2539
  # about the file was changed, not the file itself).
@@ -1634,14 +2578,12 @@ class File::Stat < Object
1634
2578
 
1635
2579
  # <!--
1636
2580
  # rdoc-file=file.c
1637
- # - File.directory?(file_name) -> true or false
2581
+ # - stat.directory? -> true or false
1638
2582
  # -->
1639
- # Returns `true` if the named file is a directory, or a symlink that points at a
1640
- # directory, and `false` otherwise.
1641
- #
1642
- # *file_name* can be an IO object.
2583
+ # Returns `true` if *stat* is a directory, `false` otherwise.
1643
2584
  #
1644
- # File.directory?(".")
2585
+ # File.stat("testfile").directory? #=> false
2586
+ # File.stat(".").directory? #=> true
1645
2587
  #
1646
2588
  def directory?: () -> bool
1647
2589
 
@@ -1703,7 +2645,7 @@ class File::Stat < Object
1703
2645
  # - stat.grpowned? -> true or false
1704
2646
  # -->
1705
2647
  # Returns true if the effective group id of the process is the same as the group
1706
- # id of *stat*. On Windows NT, returns `false`.
2648
+ # id of *stat*. On Windows, returns `false`.
1707
2649
  #
1708
2650
  # File.stat("testfile").grpowned? #=> true
1709
2651
  # File.stat("/etc/passwd").grpowned? #=> false
@@ -1751,7 +2693,7 @@ class File::Stat < Object
1751
2693
 
1752
2694
  # <!--
1753
2695
  # rdoc-file=file.c
1754
- # - stat.mtime -> aTime
2696
+ # - stat.mtime -> time
1755
2697
  # -->
1756
2698
  # Returns the modification time of *stat*.
1757
2699
  #
@@ -1885,7 +2827,7 @@ class File::Stat < Object
1885
2827
  # Returns `nil` if *stat* is a zero-length file, the size of the file otherwise.
1886
2828
  #
1887
2829
  # File.stat("testfile").size? #=> 66
1888
- # File.stat("/dev/null").size? #=> nil
2830
+ # File.stat(File::NULL).size? #=> nil
1889
2831
  #
1890
2832
  def size?: () -> Integer?
1891
2833