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
@@ -1,102 +1,185 @@
1
1
  # <!-- rdoc-file=lib/fileutils.rb -->
2
- # # fileutils.rb
3
- #
4
- # Copyright (c) 2000-2007 Minero Aoki
5
- #
6
- # This program is free software. You can distribute/modify this program under
7
- # the same terms of ruby.
8
- #
9
- # ## module FileUtils
10
- #
11
- # Namespace for several file utility methods for copying, moving, removing, etc.
12
- #
13
- # ### Module Functions
14
- #
15
- # require 'fileutils'
16
- #
17
- # FileUtils.cd(dir, **options)
18
- # FileUtils.cd(dir, **options) {|dir| block }
19
- # FileUtils.pwd()
20
- # FileUtils.mkdir(dir, **options)
21
- # FileUtils.mkdir(list, **options)
22
- # FileUtils.mkdir_p(dir, **options)
23
- # FileUtils.mkdir_p(list, **options)
24
- # FileUtils.rmdir(dir, **options)
25
- # FileUtils.rmdir(list, **options)
26
- # FileUtils.ln(target, link, **options)
27
- # FileUtils.ln(targets, dir, **options)
28
- # FileUtils.ln_s(target, link, **options)
29
- # FileUtils.ln_s(targets, dir, **options)
30
- # FileUtils.ln_sf(target, link, **options)
31
- # FileUtils.cp(src, dest, **options)
32
- # FileUtils.cp(list, dir, **options)
33
- # FileUtils.cp_r(src, dest, **options)
34
- # FileUtils.cp_r(list, dir, **options)
35
- # FileUtils.mv(src, dest, **options)
36
- # FileUtils.mv(list, dir, **options)
37
- # FileUtils.rm(list, **options)
38
- # FileUtils.rm_r(list, **options)
39
- # FileUtils.rm_rf(list, **options)
40
- # FileUtils.install(src, dest, **options)
41
- # FileUtils.chmod(mode, list, **options)
42
- # FileUtils.chmod_R(mode, list, **options)
43
- # FileUtils.chown(user, group, list, **options)
44
- # FileUtils.chown_R(user, group, list, **options)
45
- # FileUtils.touch(list, **options)
46
- #
47
- # Possible `options` are:
48
- #
49
- # `:force`
50
- # : forced operation (rewrite files if exist, remove directories if not empty,
51
- # etc.);
52
- # `:verbose`
53
- # : print command to be run, in bash syntax, before performing it;
54
- # `:preserve`
55
- # : preserve object's group, user and modification time on copying;
56
- # `:noop`
57
- # : no changes are made (usable in combination with `:verbose` which will
58
- # print the command to run)
59
- #
60
- #
61
- # Each method documents the options that it honours. See also ::commands,
62
- # ::options and ::options_of methods to introspect which command have which
63
- # options.
64
- #
65
- # All methods that have the concept of a "source" file or directory can take
66
- # either one file or a list of files in that argument. See the method
67
- # documentation for examples.
68
- #
69
- # There are some `low level' methods, which do not accept keyword arguments:
70
- #
71
- # FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
72
- # FileUtils.copy_file(src, dest, preserve = false, dereference = true)
73
- # FileUtils.copy_stream(srcstream, deststream)
74
- # FileUtils.remove_entry(path, force = false)
75
- # FileUtils.remove_entry_secure(path, force = false)
76
- # FileUtils.remove_file(path, force = false)
77
- # FileUtils.compare_file(path_a, path_b)
78
- # FileUtils.compare_stream(stream_a, stream_b)
79
- # FileUtils.uptodate?(file, cmp_list)
80
- #
81
- # ## module FileUtils::Verbose
82
- #
83
- # This module has all methods of FileUtils module, but it outputs messages
84
- # before acting. This equates to passing the `:verbose` flag to methods in
85
- # FileUtils.
86
- #
87
- # ## module FileUtils::NoWrite
88
- #
89
- # This module has all methods of FileUtils module, but never changes
90
- # files/directories. This equates to passing the `:noop` flag to methods in
91
- # FileUtils.
92
- #
93
- # ## module FileUtils::DryRun
94
- #
95
- # This module has all methods of FileUtils module, but never changes
96
- # files/directories. This equates to passing the `:noop` and `:verbose` flags
97
- # to methods in FileUtils.
2
+ # Namespace for file utility methods for copying, moving, removing, etc.
3
+ #
4
+ # ## What's Here
5
+ #
6
+ # First, what’s elsewhere. Module FileUtils:
7
+ #
8
+ # * Inherits from [class Object](rdoc-ref:Object).
9
+ # * Supplements [class File](rdoc-ref:File) (but is not included or extended
10
+ # there).
11
+ #
12
+ # Here, module FileUtils provides methods that are useful for:
13
+ #
14
+ # * [Creating](rdoc-ref:FileUtils@Creating).
15
+ # * [Deleting](rdoc-ref:FileUtils@Deleting).
16
+ # * [Querying](rdoc-ref:FileUtils@Querying).
17
+ # * [Setting](rdoc-ref:FileUtils@Setting).
18
+ # * [Comparing](rdoc-ref:FileUtils@Comparing).
19
+ # * [Copying](rdoc-ref:FileUtils@Copying).
20
+ # * [Moving](rdoc-ref:FileUtils@Moving).
21
+ # * [Options](rdoc-ref:FileUtils@Options).
22
+ #
23
+ # ### Creating
24
+ #
25
+ # * ::mkdir: Creates directories.
26
+ # * ::mkdir_p, ::makedirs, ::mkpath: Creates directories, also creating
27
+ # ancestor directories as needed.
28
+ # * ::link_entry: Creates a hard link.
29
+ # * ::ln, ::link: Creates hard links.
30
+ # * ::ln_s, ::symlink: Creates symbolic links.
31
+ # * ::ln_sf: Creates symbolic links, overwriting if necessary.
32
+ # * ::ln_sr: Creates symbolic links relative to targets
33
+ #
34
+ # ### Deleting
35
+ #
36
+ # * ::remove_dir: Removes a directory and its descendants.
37
+ # * ::remove_entry: Removes an entry, including its descendants if it is a
38
+ # directory.
39
+ # * ::remove_entry_secure: Like ::remove_entry, but removes securely.
40
+ # * ::remove_file: Removes a file entry.
41
+ # * ::rm, ::remove: Removes entries.
42
+ # * ::rm_f, ::safe_unlink: Like ::rm, but removes forcibly.
43
+ # * ::rm_r: Removes entries and their descendants.
44
+ # * ::rm_rf, ::rmtree: Like ::rm_r, but removes forcibly.
45
+ # * ::rmdir: Removes directories.
46
+ #
47
+ # ### Querying
48
+ #
49
+ # * ::pwd, ::getwd: Returns the path to the working directory.
50
+ # * ::uptodate?: Returns whether a given entry is newer than given other
51
+ # entries.
52
+ #
53
+ # ### Setting
54
+ #
55
+ # * ::cd, ::chdir: Sets the working directory.
56
+ # * ::chmod: Sets permissions for an entry.
57
+ # * ::chmod_R: Sets permissions for an entry and its descendants.
58
+ # * ::chown: Sets the owner and group for entries.
59
+ # * ::chown_R: Sets the owner and group for entries and their descendants.
60
+ # * ::touch: Sets modification and access times for entries, creating if
61
+ # necessary.
62
+ #
63
+ # ### Comparing
64
+ #
65
+ # * ::compare_file, ::cmp, ::identical?: Returns whether two entries are
66
+ # identical.
67
+ # * ::compare_stream: Returns whether two streams are identical.
68
+ #
69
+ # ### Copying
70
+ #
71
+ # * ::copy_entry: Recursively copies an entry.
72
+ # * ::copy_file: Copies an entry.
73
+ # * ::copy_stream: Copies a stream.
74
+ # * ::cp, ::copy: Copies files.
75
+ # * ::cp_lr: Recursively creates hard links.
76
+ # * ::cp_r: Recursively copies files, retaining mode, owner, and group.
77
+ # * ::install: Recursively copies files, optionally setting mode, owner, and
78
+ # group.
79
+ #
80
+ # ### Moving
81
+ #
82
+ # * ::mv, ::move: Moves entries.
83
+ #
84
+ # ### Options
85
+ #
86
+ # * ::collect_method: Returns the names of methods that accept a given option.
87
+ # * ::commands: Returns the names of methods that accept options.
88
+ # * ::have_option?: Returns whether a given method accepts a given option.
89
+ # * ::options: Returns all option names.
90
+ # * ::options_of: Returns the names of the options for a given method.
91
+ #
92
+ # ## Path Arguments
93
+ #
94
+ # Some methods in FileUtils accept *path* arguments, which are interpreted as
95
+ # paths to filesystem entries:
96
+ #
97
+ # * If the argument is a string, that value is the path.
98
+ # * If the argument has method `:to_path`, it is converted via that method.
99
+ # * If the argument has method `:to_str`, it is converted via that method.
100
+ #
101
+ # ## About the Examples
102
+ #
103
+ # Some examples here involve trees of file entries. For these, we sometimes
104
+ # display trees using the [tree command-line
105
+ # utility](https://en.wikipedia.org/wiki/Tree_(command)), which is a recursive
106
+ # directory-listing utility that produces a depth-indented listing of files and
107
+ # directories.
108
+ #
109
+ # We use a helper method to launch the command and control the format:
110
+ #
111
+ # def tree(dirpath = '.')
112
+ # command = "tree --noreport --charset=ascii #{dirpath}"
113
+ # system(command)
114
+ # end
115
+ #
116
+ # To illustrate:
117
+ #
118
+ # tree('src0')
119
+ # # => src0
120
+ # # |-- sub0
121
+ # # | |-- src0.txt
122
+ # # | `-- src1.txt
123
+ # # `-- sub1
124
+ # # |-- src2.txt
125
+ # # `-- src3.txt
126
+ #
127
+ # ## Avoiding the TOCTTOU Vulnerability
128
+ #
129
+ # For certain methods that recursively remove entries, there is a potential
130
+ # vulnerability called the [Time-of-check to
131
+ # time-of-use](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use), or
132
+ # TOCTTOU, vulnerability that can exist when:
133
+ #
134
+ # * An ancestor directory of the entry at the target path is world writable;
135
+ # such directories include `/tmp`.
136
+ # * The directory tree at the target path includes:
137
+ #
138
+ # * A world-writable descendant directory.
139
+ # * A symbolic link.
140
+ #
141
+ # To avoid that vulnerability, you can use this method to remove entries:
142
+ #
143
+ # * FileUtils.remove_entry_secure: removes recursively if the target path
144
+ # points to a directory.
145
+ #
146
+ # Also available are these methods, each of which calls
147
+ # FileUtils.remove_entry_secure:
148
+ #
149
+ # * FileUtils.rm_r with keyword argument `secure: true`.
150
+ # * FileUtils.rm_rf with keyword argument `secure: true`.
151
+ #
152
+ # Finally, this method for moving entries calls FileUtils.remove_entry_secure if
153
+ # the source and destination are on different file systems (which means that the
154
+ # "move" is really a copy and remove):
155
+ #
156
+ # * FileUtils.mv with keyword argument `secure: true`.
157
+ #
158
+ # Method FileUtils.remove_entry_secure removes securely by applying a special
159
+ # pre-process:
160
+ #
161
+ # * If the target path points to a directory, this method uses methods
162
+ # [File#chown](rdoc-ref:File#chown) and [File#chmod](rdoc-ref:File#chmod) in
163
+ # removing directories.
164
+ # * The owner of the target directory should be either the current process or
165
+ # the super user (root).
166
+ #
167
+ # WARNING: You must ensure that **ALL** parent directories cannot be moved by
168
+ # other untrusted users. For example, parent directories should not be owned by
169
+ # untrusted users, and should not be world writable except when the sticky bit
170
+ # is set.
171
+ #
172
+ # For details of this security vulnerability, see Perl cases:
173
+ #
174
+ # * [CVE-2005-0448](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-04
175
+ # 48).
176
+ # * [CVE-2004-0452](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-04
177
+ # 52).
98
178
  #
99
179
  module FileUtils
180
+ # <!-- rdoc-file=lib/fileutils.rb -->
181
+ # The version number.
182
+ #
100
183
  VERSION: String
101
184
 
102
185
  type mode = Integer | String
@@ -109,18 +192,38 @@ module FileUtils
109
192
  # rdoc-file=lib/fileutils.rb
110
193
  # - cd(dir, verbose: nil) { |dir| ... }
111
194
  # -->
112
- # Changes the current directory to the directory `dir`.
195
+ # Changes the working directory to the given `dir`, which should be
196
+ # [interpretable as a path](rdoc-ref:FileUtils@Path+Arguments):
197
+ #
198
+ # With no block given, changes the current directory to the directory at `dir`;
199
+ # returns zero:
200
+ #
201
+ # FileUtils.pwd # => "/rdoc/fileutils"
202
+ # FileUtils.cd('..')
203
+ # FileUtils.pwd # => "/rdoc"
204
+ # FileUtils.cd('fileutils')
205
+ #
206
+ # With a block given, changes the current directory to the directory at `dir`,
207
+ # calls the block with argument `dir`, and restores the original current
208
+ # directory; returns the block's value:
113
209
  #
114
- # If this method is called with block, resumes to the previous working directory
115
- # after the block execution has finished.
210
+ # FileUtils.pwd # => "/rdoc/fileutils"
211
+ # FileUtils.cd('..') { |arg| [arg, FileUtils.pwd] } # => ["..", "/rdoc"]
212
+ # FileUtils.pwd # => "/rdoc/fileutils"
116
213
  #
117
- # FileUtils.cd('/') # change directory
214
+ # Keyword arguments:
118
215
  #
119
- # FileUtils.cd('/', verbose: true) # change directory and report it
216
+ # * `verbose: true` - prints an equivalent command:
120
217
  #
121
- # FileUtils.cd('/') do # change directory
122
- # # ... # do something
123
- # end # return to original directory
218
+ # FileUtils.cd('..')
219
+ # FileUtils.cd('fileutils')
220
+ #
221
+ # Output:
222
+ #
223
+ # cd ..
224
+ # cd fileutils
225
+ #
226
+ # Related: FileUtils.pwd.
124
227
  #
125
228
  def self?.cd: (path dir, ?verbose: boolish) -> void
126
229
  | [X] (path dir, ?verbose: boolish) { (String) -> X } -> X
@@ -143,48 +246,75 @@ module FileUtils
143
246
  # rdoc-file=lib/fileutils.rb
144
247
  # - chmod(mode, list, noop: nil, verbose: nil)
145
248
  # -->
146
- # Changes permission bits on the named files (in `list`) to the bit pattern
147
- # represented by `mode`.
148
- #
149
- # `mode` is the symbolic and absolute mode can be used.
150
- #
151
- # Absolute mode is
152
- # FileUtils.chmod 0755, 'somecommand'
153
- # FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
154
- # FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
155
- #
156
- # Symbolic mode is
157
- # FileUtils.chmod "u=wrx,go=rx", 'somecommand'
158
- # FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
159
- # FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
160
- #
161
- # "a"
162
- # : is user, group, other mask.
163
- # "u"
164
- # : is user's mask.
165
- # "g"
166
- # : is group's mask.
167
- # "o"
168
- # : is other's mask.
169
- # "w"
170
- # : is write permission.
171
- # "r"
172
- # : is read permission.
173
- # "x"
174
- # : is execute permission.
175
- # "X"
176
- # : is execute permission for directories only, must be used in conjunction
177
- # with "+"
178
- # "s"
179
- # : is uid, gid.
180
- # "t"
181
- # : is sticky bit.
182
- # "+"
183
- # : is added to a class given the specified mode.
184
- # "-"
185
- # : Is removed from a given class given mode.
186
- # "="
187
- # : Is the exact nature of the class will be given a specified mode.
249
+ # Changes permissions on the entries at the paths given in `list` (a single path
250
+ # or an array of paths) to the permissions given by `mode`; returns `list` if it
251
+ # is an array, `[list]` otherwise:
252
+ #
253
+ # * Modifies each entry that is a regular file using
254
+ # [File.chmod](rdoc-ref:File.chmod).
255
+ # * Modifies each entry that is a symbolic link using
256
+ # [File.lchmod](rdoc-ref:File.lchmod).
257
+ #
258
+ # Argument `list` or its elements should be [interpretable as
259
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
260
+ #
261
+ # Argument `mode` may be either an integer or a string:
262
+ #
263
+ # * Integer `mode`: represents the permission bits to be set:
264
+ #
265
+ # FileUtils.chmod(0755, 'src0.txt')
266
+ # FileUtils.chmod(0644, ['src0.txt', 'src0.dat'])
267
+ #
268
+ # * String `mode`: represents the permissions to be set:
269
+ #
270
+ # The string is of the form `[targets][[operator][perms[,perms]]`, where:
271
+ #
272
+ # * `targets` may be any combination of these letters:
273
+ #
274
+ # * `'u'`: permissions apply to the file's owner.
275
+ # * `'g'`: permissions apply to users in the file's group.
276
+ # * `'o'`: permissions apply to other users not in the file's group.
277
+ # * `'a'` (the default): permissions apply to all users.
278
+ #
279
+ # * `operator` may be one of these letters:
280
+ #
281
+ # * `'+'`: adds permissions.
282
+ # * `'-'`: removes permissions.
283
+ # * `'='`: sets (replaces) permissions.
284
+ #
285
+ # * `perms` (may be repeated, with separating commas) may be any
286
+ # combination of these letters:
287
+ #
288
+ # * `'r'`: Read.
289
+ # * `'w'`: Write.
290
+ # * `'x'`: Execute (search, for a directory).
291
+ # * `'X'`: Search (for a directories only; must be used with `'+'`)
292
+ # * `'s'`: Uid or gid.
293
+ # * `'t'`: Sticky bit.
294
+ #
295
+ # Examples:
296
+ #
297
+ # FileUtils.chmod('u=wrx,go=rx', 'src1.txt')
298
+ # FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby')
299
+ #
300
+ # Keyword arguments:
301
+ #
302
+ # * `noop: true` - does not change permissions; returns `nil`.
303
+ # * `verbose: true` - prints an equivalent command:
304
+ #
305
+ # FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true)
306
+ # FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true)
307
+ # FileUtils.chmod('u=wrx,go=rx', 'src1.txt', noop: true, verbose: true)
308
+ # FileUtils.chmod('u=wrx,go=rx', '/usr/bin/ruby', noop: true, verbose: true)
309
+ #
310
+ # Output:
311
+ #
312
+ # chmod 755 src0.txt
313
+ # chmod 644 src0.txt src0.dat
314
+ # chmod u=wrx,go=rx src1.txt
315
+ # chmod u=wrx,go=rx /usr/bin/ruby
316
+ #
317
+ # Related: FileUtils.chmod_R.
188
318
  #
189
319
  def self?.chmod: (mode mode, pathlist list, ?noop: boolish, ?verbose: boolish) -> void
190
320
 
@@ -192,11 +322,7 @@ module FileUtils
192
322
  # rdoc-file=lib/fileutils.rb
193
323
  # - chmod_R(mode, list, noop: nil, verbose: nil, force: nil)
194
324
  # -->
195
- # Changes permission bits on the named files (in `list`) to the bit pattern
196
- # represented by `mode`.
197
- #
198
- # FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
199
- # FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
325
+ # Like FileUtils.chmod, but changes permissions recursively.
200
326
  #
201
327
  def self?.chmod_R: (mode mode, pathlist list, ?noop: boolish, ?verbose: boolish, ?force: boolish) -> void
202
328
 
@@ -204,13 +330,67 @@ module FileUtils
204
330
  # rdoc-file=lib/fileutils.rb
205
331
  # - chown(user, group, list, noop: nil, verbose: nil)
206
332
  # -->
207
- # Changes owner and group on the named files (in `list`) to the user `user` and
208
- # the group `group`. `user` and `group` may be an ID (Integer/String) or a name
209
- # (String). If `user` or `group` is nil, this method does not change the
210
- # attribute.
333
+ # Changes the owner and group on the entries at the paths given in `list` (a
334
+ # single path or an array of paths) to the given `user` and `group`; returns
335
+ # `list` if it is an array, `[list]` otherwise:
336
+ #
337
+ # * Modifies each entry that is a regular file using
338
+ # [File.chown](rdoc-ref:File.chown).
339
+ # * Modifies each entry that is a symbolic link using
340
+ # [File.lchown](rdoc-ref:File.lchown).
341
+ #
342
+ # Argument `list` or its elements should be [interpretable as
343
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
344
+ #
345
+ # User and group:
346
+ #
347
+ # * Argument `user` may be a user name or a user id; if `nil` or `-1`, the
348
+ # user is not changed.
349
+ # * Argument `group` may be a group name or a group id; if `nil` or `-1`, the
350
+ # group is not changed.
351
+ # * The user must be a member of the group.
352
+ #
353
+ # Examples:
354
+ #
355
+ # # One path.
356
+ # # User and group as string names.
357
+ # File.stat('src0.txt').uid # => 1004
358
+ # File.stat('src0.txt').gid # => 1004
359
+ # FileUtils.chown('user2', 'group1', 'src0.txt')
360
+ # File.stat('src0.txt').uid # => 1006
361
+ # File.stat('src0.txt').gid # => 1005
362
+ #
363
+ # # User and group as uid and gid.
364
+ # FileUtils.chown(1004, 1004, 'src0.txt')
365
+ # File.stat('src0.txt').uid # => 1004
366
+ # File.stat('src0.txt').gid # => 1004
211
367
  #
212
- # FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
213
- # FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
368
+ # # Array of paths.
369
+ # FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat'])
370
+ #
371
+ # # Directory (not recursive).
372
+ # FileUtils.chown('user2', 'group1', '.')
373
+ #
374
+ # Keyword arguments:
375
+ #
376
+ # * `noop: true` - does not change permissions; returns `nil`.
377
+ # * `verbose: true` - prints an equivalent command:
378
+ #
379
+ # FileUtils.chown('user2', 'group1', 'src0.txt', noop: true, verbose: true)
380
+ # FileUtils.chown(1004, 1004, 'src0.txt', noop: true, verbose: true)
381
+ # FileUtils.chown(1006, 1005, ['src0.txt', 'src0.dat'], noop: true, verbose: true)
382
+ # FileUtils.chown('user2', 'group1', path, noop: true, verbose: true)
383
+ # FileUtils.chown('user2', 'group1', '.', noop: true, verbose: true)
384
+ #
385
+ # Output:
386
+ #
387
+ # chown user2:group1 src0.txt
388
+ # chown 1004:1004 src0.txt
389
+ # chown 1006:1005 src0.txt src0.dat
390
+ # chown user2:group1 src0.txt
391
+ # chown user2:group1 .
392
+ #
393
+ # Related: FileUtils.chown_R.
214
394
  #
215
395
  def self?.chown: (String? user, String? group, pathlist list, ?noop: boolish, ?verbose: boolish) -> void
216
396
 
@@ -218,13 +398,7 @@ module FileUtils
218
398
  # rdoc-file=lib/fileutils.rb
219
399
  # - chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
220
400
  # -->
221
- # Changes owner and group on the named files (in `list`) to the user `user` and
222
- # the group `group` recursively. `user` and `group` may be an ID
223
- # (Integer/String) or a name (String). If `user` or `group` is nil, this method
224
- # does not change the attribute.
225
- #
226
- # FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
227
- # FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
401
+ # Like FileUtils.chown, but changes owner and group recursively.
228
402
  #
229
403
  def self?.chown_R: (String? user, String? group, pathlist list, ?noop: boolish, ?verbose: boolish, ?force: boolish) -> void
230
404
 
@@ -232,9 +406,10 @@ module FileUtils
232
406
  # rdoc-file=lib/fileutils.rb
233
407
  # - collect_method(opt)
234
408
  # -->
235
- # Returns an Array of methods names which have the option `opt`.
409
+ # Returns an array of the string method names of the methods that accept the
410
+ # given keyword option `opt`; the argument must be a symbol:
236
411
  #
237
- # p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
412
+ # FileUtils.collect_method(:preserve) # => ["cp", "copy", "cp_r", "install"]
238
413
  #
239
414
  def self.collect_method: (Symbol opt) -> Array[String]
240
415
 
@@ -242,10 +417,10 @@ module FileUtils
242
417
  # rdoc-file=lib/fileutils.rb
243
418
  # - commands()
244
419
  # -->
245
- # Returns an Array of names of high-level methods that accept any keyword
246
- # arguments.
420
+ # Returns an array of the string names of FileUtils methods that accept one or
421
+ # more keyword arguments:
247
422
  #
248
- # p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
423
+ # FileUtils.commands.sort.take(3) # => ["cd", "chdir", "chmod"]
249
424
  #
250
425
  def self.commands: () -> Array[String]
251
426
 
@@ -253,10 +428,15 @@ module FileUtils
253
428
  # rdoc-file=lib/fileutils.rb
254
429
  # - compare_file(a, b)
255
430
  # -->
256
- # Returns true if the contents of a file `a` and a file `b` are identical.
431
+ # Returns `true` if the contents of files `a` and `b` are identical, `false`
432
+ # otherwise.
257
433
  #
258
- # FileUtils.compare_file('somefile', 'somefile') #=> true
259
- # FileUtils.compare_file('/dev/null', '/dev/urandom') #=> false
434
+ # Arguments `a` and `b` should be [interpretable as a
435
+ # path](rdoc-ref:FileUtils@Path+Arguments).
436
+ #
437
+ # FileUtils.identical? and FileUtils.cmp are aliases for FileUtils.compare_file.
438
+ #
439
+ # Related: FileUtils.compare_stream.
260
440
  #
261
441
  def self?.compare_file: (path a, path b) -> bool
262
442
 
@@ -292,7 +472,13 @@ module FileUtils
292
472
  # rdoc-file=lib/fileutils.rb
293
473
  # - compare_stream(a, b)
294
474
  # -->
295
- # Returns true if the contents of a stream `a` and `b` are identical.
475
+ # Returns `true` if the contents of streams `a` and `b` are identical, `false`
476
+ # otherwise.
477
+ #
478
+ # Arguments `a` and `b` should be [interpretable as a
479
+ # path](rdoc-ref:FileUtils@Path+Arguments).
480
+ #
481
+ # Related: FileUtils.compare_file.
296
482
  #
297
483
  def self?.compare_stream: (IO a, IO b) -> bool
298
484
 
@@ -300,20 +486,49 @@ module FileUtils
300
486
  # rdoc-file=lib/fileutils.rb
301
487
  # - copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
302
488
  # -->
303
- # Copies a file system entry `src` to `dest`. If `src` is a directory, this
304
- # method copies its contents recursively. This method preserves file types, c.f.
305
- # symlink, directory... (FIFO, device files and etc. are not supported yet)
489
+ # Recursively copies files from `src` to `dest`.
490
+ #
491
+ # Arguments `src` and `dest` should be [interpretable as
492
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
493
+ #
494
+ # If `src` is the path to a file, copies `src` to `dest`:
495
+ #
496
+ # FileUtils.touch('src0.txt')
497
+ # File.exist?('dest0.txt') # => false
498
+ # FileUtils.copy_entry('src0.txt', 'dest0.txt')
499
+ # File.file?('dest0.txt') # => true
500
+ #
501
+ # If `src` is a directory, recursively copies `src` to `dest`:
306
502
  #
307
- # Both of `src` and `dest` must be a path name. `src` must exist, `dest` must
308
- # not exist.
503
+ # tree('src1')
504
+ # # => src1
505
+ # # |-- dir0
506
+ # # | |-- src0.txt
507
+ # # | `-- src1.txt
508
+ # # `-- dir1
509
+ # # |-- src2.txt
510
+ # # `-- src3.txt
511
+ # FileUtils.copy_entry('src1', 'dest1')
512
+ # tree('dest1')
513
+ # # => dest1
514
+ # # |-- dir0
515
+ # # | |-- src0.txt
516
+ # # | `-- src1.txt
517
+ # # `-- dir1
518
+ # # |-- src2.txt
519
+ # # `-- src3.txt
309
520
  #
310
- # If `preserve` is true, this method preserves owner, group, and modified time.
311
- # Permissions are copied regardless `preserve`.
521
+ # The recursive copying preserves file types for regular files, directories, and
522
+ # symbolic links; other file types (FIFO streams, device files, etc.) are not
523
+ # supported.
312
524
  #
313
- # If `dereference_root` is true, this method dereference tree root.
525
+ # Keyword arguments:
314
526
  #
315
- # If `remove_destination` is true, this method removes each destination file
316
- # before copy.
527
+ # * `dereference_root: true` - if `src` is a symbolic link, follows the link.
528
+ # * `preserve: true` - preserves file times.
529
+ # * `remove_destination: true` - removes `dest` before copying files.
530
+ #
531
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
317
532
  #
318
533
  def self?.copy_entry: (path src, path dest, ?boolish preserve, ?boolish dereference_root, ?boolish remove_destination) -> void
319
534
 
@@ -321,8 +536,25 @@ module FileUtils
321
536
  # rdoc-file=lib/fileutils.rb
322
537
  # - copy_file(src, dest, preserve = false, dereference = true)
323
538
  # -->
324
- # Copies file contents of `src` to `dest`. Both of `src` and `dest` must be a
325
- # path name.
539
+ # Copies file from `src` to `dest`, which should not be directories.
540
+ #
541
+ # Arguments `src` and `dest` should be [interpretable as
542
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
543
+ #
544
+ # Examples:
545
+ #
546
+ # FileUtils.touch('src0.txt')
547
+ # FileUtils.copy_file('src0.txt', 'dest0.txt')
548
+ # File.file?('dest0.txt') # => true
549
+ #
550
+ # Keyword arguments:
551
+ #
552
+ # * `dereference: false` - if `src` is a symbolic link, does not follow the
553
+ # link.
554
+ # * `preserve: true` - preserves file times.
555
+ # * `remove_destination: true` - removes `dest` before copying files.
556
+ #
557
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
326
558
  #
327
559
  def self?.copy_file: (path src, path dest, ?boolish preserve, ?boolish dereference) -> void
328
560
 
@@ -330,8 +562,10 @@ module FileUtils
330
562
  # rdoc-file=lib/fileutils.rb
331
563
  # - copy_stream(src, dest)
332
564
  # -->
333
- # Copies stream `src` to `dest`. `src` must respond to #read(n) and `dest` must
334
- # respond to #write(str).
565
+ # Copies IO stream `src` to IO stream `dest` via
566
+ # [IO.copy_stream](rdoc-ref:IO.copy_stream).
567
+ #
568
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
335
569
  #
336
570
  def self?.copy_stream: (_Reader src, _Writer dest) -> void
337
571
 
@@ -339,15 +573,56 @@ module FileUtils
339
573
  # rdoc-file=lib/fileutils.rb
340
574
  # - cp(src, dest, preserve: nil, noop: nil, verbose: nil)
341
575
  # -->
342
- # Copies a file content `src` to `dest`. If `dest` is a directory, copies `src`
343
- # to `dest/src`.
576
+ # Copies files.
577
+ #
578
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
579
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments).
580
+ #
581
+ # If `src` is the path to a file and `dest` is not the path to a directory,
582
+ # copies `src` to `dest`:
583
+ #
584
+ # FileUtils.touch('src0.txt')
585
+ # File.exist?('dest0.txt') # => false
586
+ # FileUtils.cp('src0.txt', 'dest0.txt')
587
+ # File.file?('dest0.txt') # => true
588
+ #
589
+ # If `src` is the path to a file and `dest` is the path to a directory, copies
590
+ # `src` to `dest/src`:
591
+ #
592
+ # FileUtils.touch('src1.txt')
593
+ # FileUtils.mkdir('dest1')
594
+ # FileUtils.cp('src1.txt', 'dest1')
595
+ # File.file?('dest1/src1.txt') # => true
596
+ #
597
+ # If `src` is an array of paths to files and `dest` is the path to a directory,
598
+ # copies from each `src` to `dest`:
599
+ #
600
+ # src_file_paths = ['src2.txt', 'src2.dat']
601
+ # FileUtils.touch(src_file_paths)
602
+ # FileUtils.mkdir('dest2')
603
+ # FileUtils.cp(src_file_paths, 'dest2')
604
+ # File.file?('dest2/src2.txt') # => true
605
+ # File.file?('dest2/src2.dat') # => true
606
+ #
607
+ # Keyword arguments:
344
608
  #
345
- # If `src` is a list of files, then `dest` must be a directory.
609
+ # * `preserve: true` - preserves file times.
610
+ # * `noop: true` - does not copy files.
611
+ # * `verbose: true` - prints an equivalent command:
346
612
  #
347
- # FileUtils.cp 'eval.c', 'eval.c.org'
348
- # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
349
- # FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
350
- # FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
613
+ # FileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true)
614
+ # FileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true)
615
+ # FileUtils.cp(src_file_paths, 'dest2', noop: true, verbose: true)
616
+ #
617
+ # Output:
618
+ #
619
+ # cp src0.txt dest0.txt
620
+ # cp src1.txt dest1
621
+ # cp src2.txt src2.dat dest2
622
+ #
623
+ # Raises an exception if `src` is a directory.
624
+ #
625
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
351
626
  #
352
627
  def self?.cp: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
353
628
 
@@ -369,27 +644,101 @@ module FileUtils
369
644
  # rdoc-file=lib/fileutils.rb
370
645
  # - cp_lr(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)
371
646
  # -->
372
- # Hard link `src` to `dest`. If `src` is a directory, this method links all its
373
- # contents recursively. If `dest` is a directory, links `src` to `dest/src`.
374
- #
375
- # `src` can be a list of files.
376
- #
377
- # If `dereference_root` is true, this method dereference tree root.
378
- #
379
- # If `remove_destination` is true, this method removes each destination file
380
- # before copy.
381
- #
382
- # FileUtils.rm_r site_ruby + '/mylib', force: true
383
- # FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
384
- #
385
- # # Examples of linking several files to target directory.
386
- # FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
387
- # FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
388
- #
389
- # # If you want to link all contents of a directory instead of the
390
- # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
391
- # # use the following code.
392
- # FileUtils.cp_lr 'src/.', 'dest' # cp_lr('src', 'dest') makes dest/src, but this doesn't.
647
+ # Creates [hard links](https://en.wikipedia.org/wiki/Hard_link).
648
+ #
649
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
650
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments).
651
+ #
652
+ # If `src` is the path to a directory and `dest` does not exist, creates links
653
+ # `dest` and descendents pointing to `src` and its descendents:
654
+ #
655
+ # tree('src0')
656
+ # # => src0
657
+ # # |-- sub0
658
+ # # | |-- src0.txt
659
+ # # | `-- src1.txt
660
+ # # `-- sub1
661
+ # # |-- src2.txt
662
+ # # `-- src3.txt
663
+ # File.exist?('dest0') # => false
664
+ # FileUtils.cp_lr('src0', 'dest0')
665
+ # tree('dest0')
666
+ # # => dest0
667
+ # # |-- sub0
668
+ # # | |-- src0.txt
669
+ # # | `-- src1.txt
670
+ # # `-- sub1
671
+ # # |-- src2.txt
672
+ # # `-- src3.txt
673
+ #
674
+ # If `src` and `dest` are both paths to directories, creates links `dest/src`
675
+ # and descendents pointing to `src` and its descendents:
676
+ #
677
+ # tree('src1')
678
+ # # => src1
679
+ # # |-- sub0
680
+ # # | |-- src0.txt
681
+ # # | `-- src1.txt
682
+ # # `-- sub1
683
+ # # |-- src2.txt
684
+ # # `-- src3.txt
685
+ # FileUtils.mkdir('dest1')
686
+ # FileUtils.cp_lr('src1', 'dest1')
687
+ # tree('dest1')
688
+ # # => dest1
689
+ # # `-- src1
690
+ # # |-- sub0
691
+ # # | |-- src0.txt
692
+ # # | `-- src1.txt
693
+ # # `-- sub1
694
+ # # |-- src2.txt
695
+ # # `-- src3.txt
696
+ #
697
+ # If `src` is an array of paths to entries and `dest` is the path to a
698
+ # directory, for each path `filepath` in `src`, creates a link at
699
+ # `dest/filepath` pointing to that path:
700
+ #
701
+ # tree('src2')
702
+ # # => src2
703
+ # # |-- sub0
704
+ # # | |-- src0.txt
705
+ # # | `-- src1.txt
706
+ # # `-- sub1
707
+ # # |-- src2.txt
708
+ # # `-- src3.txt
709
+ # FileUtils.mkdir('dest2')
710
+ # FileUtils.cp_lr(['src2/sub0', 'src2/sub1'], 'dest2')
711
+ # tree('dest2')
712
+ # # => dest2
713
+ # # |-- sub0
714
+ # # | |-- src0.txt
715
+ # # | `-- src1.txt
716
+ # # `-- sub1
717
+ # # |-- src2.txt
718
+ # # `-- src3.txt
719
+ #
720
+ # Keyword arguments:
721
+ #
722
+ # * `dereference_root: false` - if `src` is a symbolic link, does not
723
+ # dereference it.
724
+ # * `noop: true` - does not create links.
725
+ # * `remove_destination: true` - removes `dest` before creating links.
726
+ # * `verbose: true` - prints an equivalent command:
727
+ #
728
+ # FileUtils.cp_lr('src0', 'dest0', noop: true, verbose: true)
729
+ # FileUtils.cp_lr('src1', 'dest1', noop: true, verbose: true)
730
+ # FileUtils.cp_lr(['src2/sub0', 'src2/sub1'], 'dest2', noop: true, verbose: true)
731
+ #
732
+ # Output:
733
+ #
734
+ # cp -lr src0 dest0
735
+ # cp -lr src1 dest1
736
+ # cp -lr src2/sub0 src2/sub1 dest2
737
+ #
738
+ # Raises an exception if `dest` is the path to an existing file or directory and
739
+ # keyword argument `remove_destination: true` is not given.
740
+ #
741
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
393
742
  #
394
743
  def self?.cp_lr: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
395
744
 
@@ -397,29 +746,104 @@ module FileUtils
397
746
  # rdoc-file=lib/fileutils.rb
398
747
  # - cp_r(src, dest, preserve: nil, noop: nil, verbose: nil, dereference_root: true, remove_destination: nil)
399
748
  # -->
400
- # Copies `src` to `dest`. If `src` is a directory, this method copies all its
401
- # contents recursively. If `dest` is a directory, copies `src` to `dest/src`.
402
- #
403
- # `src` can be a list of files.
404
- #
405
- # If `dereference_root` is true, this method dereference tree root.
406
- #
407
- # If `remove_destination` is true, this method removes each destination file
408
- # before copy.
409
- #
410
- # # Installing Ruby library "mylib" under the site_ruby
411
- # FileUtils.rm_r site_ruby + '/mylib', force: true
412
- # FileUtils.cp_r 'lib/', site_ruby + '/mylib'
413
- #
414
- # # Examples of copying several files to target directory.
415
- # FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
416
- # FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
417
- #
418
- # # If you want to copy all contents of a directory instead of the
419
- # # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
420
- # # use following code.
421
- # FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest') makes dest/src,
422
- # # but this doesn't.
749
+ # Recursively copies files.
750
+ #
751
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
752
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments).
753
+ #
754
+ # The mode, owner, and group are retained in the copy; to change those, use
755
+ # FileUtils.install instead.
756
+ #
757
+ # If `src` is the path to a file and `dest` is not the path to a directory,
758
+ # copies `src` to `dest`:
759
+ #
760
+ # FileUtils.touch('src0.txt')
761
+ # File.exist?('dest0.txt') # => false
762
+ # FileUtils.cp_r('src0.txt', 'dest0.txt')
763
+ # File.file?('dest0.txt') # => true
764
+ #
765
+ # If `src` is the path to a file and `dest` is the path to a directory, copies
766
+ # `src` to `dest/src`:
767
+ #
768
+ # FileUtils.touch('src1.txt')
769
+ # FileUtils.mkdir('dest1')
770
+ # FileUtils.cp_r('src1.txt', 'dest1')
771
+ # File.file?('dest1/src1.txt') # => true
772
+ #
773
+ # If `src` is the path to a directory and `dest` does not exist, recursively
774
+ # copies `src` to `dest`:
775
+ #
776
+ # tree('src2')
777
+ # # => src2
778
+ # # |-- dir0
779
+ # # | |-- src0.txt
780
+ # # | `-- src1.txt
781
+ # # `-- dir1
782
+ # # |-- src2.txt
783
+ # # `-- src3.txt
784
+ # FileUtils.exist?('dest2') # => false
785
+ # FileUtils.cp_r('src2', 'dest2')
786
+ # tree('dest2')
787
+ # # => dest2
788
+ # # |-- dir0
789
+ # # | |-- src0.txt
790
+ # # | `-- src1.txt
791
+ # # `-- dir1
792
+ # # |-- src2.txt
793
+ # # `-- src3.txt
794
+ #
795
+ # If `src` and `dest` are paths to directories, recursively copies `src` to
796
+ # `dest/src`:
797
+ #
798
+ # tree('src3')
799
+ # # => src3
800
+ # # |-- dir0
801
+ # # | |-- src0.txt
802
+ # # | `-- src1.txt
803
+ # # `-- dir1
804
+ # # |-- src2.txt
805
+ # # `-- src3.txt
806
+ # FileUtils.mkdir('dest3')
807
+ # FileUtils.cp_r('src3', 'dest3')
808
+ # tree('dest3')
809
+ # # => dest3
810
+ # # `-- src3
811
+ # # |-- dir0
812
+ # # | |-- src0.txt
813
+ # # | `-- src1.txt
814
+ # # `-- dir1
815
+ # # |-- src2.txt
816
+ # # `-- src3.txt
817
+ #
818
+ # If `src` is an array of paths and `dest` is a directory, recursively copies
819
+ # from each path in `src` to `dest`; the paths in `src` may point to files
820
+ # and/or directories.
821
+ #
822
+ # Keyword arguments:
823
+ #
824
+ # * `dereference_root: false` - if `src` is a symbolic link, does not
825
+ # dereference it.
826
+ # * `noop: true` - does not copy files.
827
+ # * `preserve: true` - preserves file times.
828
+ # * `remove_destination: true` - removes `dest` before copying files.
829
+ # * `verbose: true` - prints an equivalent command:
830
+ #
831
+ # FileUtils.cp_r('src0.txt', 'dest0.txt', noop: true, verbose: true)
832
+ # FileUtils.cp_r('src1.txt', 'dest1', noop: true, verbose: true)
833
+ # FileUtils.cp_r('src2', 'dest2', noop: true, verbose: true)
834
+ # FileUtils.cp_r('src3', 'dest3', noop: true, verbose: true)
835
+ #
836
+ # Output:
837
+ #
838
+ # cp -r src0.txt dest0.txt
839
+ # cp -r src1.txt dest1
840
+ # cp -r src2 dest2
841
+ # cp -r src3 dest3
842
+ #
843
+ # Raises an exception of `src` is the path to a directory and `dest` is the path
844
+ # to a file.
845
+ #
846
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
423
847
  #
424
848
  def self?.cp_r: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
425
849
 
@@ -427,11 +851,11 @@ module FileUtils
427
851
  # rdoc-file=lib/fileutils.rb
428
852
  # - have_option?(mid, opt)
429
853
  # -->
430
- # Returns true if the method `mid` have an option `opt`.
854
+ # Returns `true` if method `mid` accepts the given option `opt`, `false`
855
+ # otherwise; the arguments may be strings or symbols:
431
856
  #
432
- # p FileUtils.have_option?(:cp, :noop) #=> true
433
- # p FileUtils.have_option?(:rm, :force) #=> true
434
- # p FileUtils.have_option?(:rm, :preserve) #=> false
857
+ # FileUtils.have_option?(:chmod, :noop) # => true
858
+ # FileUtils.have_option?('chmod', 'secure') # => false
435
859
  #
436
860
  def self.have_option?: (Symbol mid, Symbol opt) -> bool
437
861
 
@@ -439,12 +863,68 @@ module FileUtils
439
863
  # rdoc-file=lib/fileutils.rb
440
864
  # - install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil, noop: nil, verbose: nil)
441
865
  # -->
442
- # If `src` is not same as `dest`, copies it and changes the permission mode to
443
- # `mode`. If `dest` is a directory, destination is `dest`/`src`. This method
444
- # removes destination before copy.
866
+ # Copies a file entry. See
867
+ # [install(1)](https://man7.org/linux/man-pages/man1/install.1.html).
445
868
  #
446
- # FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
447
- # FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
869
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
870
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments);
871
+ #
872
+ # If the entry at `dest` does not exist, copies from `src` to `dest`:
873
+ #
874
+ # File.read('src0.txt') # => "aaa\n"
875
+ # File.exist?('dest0.txt') # => false
876
+ # FileUtils.install('src0.txt', 'dest0.txt')
877
+ # File.read('dest0.txt') # => "aaa\n"
878
+ #
879
+ # If `dest` is a file entry, copies from `src` to `dest`, overwriting:
880
+ #
881
+ # File.read('src1.txt') # => "aaa\n"
882
+ # File.read('dest1.txt') # => "bbb\n"
883
+ # FileUtils.install('src1.txt', 'dest1.txt')
884
+ # File.read('dest1.txt') # => "aaa\n"
885
+ #
886
+ # If `dest` is a directory entry, copies from `src` to `dest/src`, overwriting
887
+ # if necessary:
888
+ #
889
+ # File.read('src2.txt') # => "aaa\n"
890
+ # File.read('dest2/src2.txt') # => "bbb\n"
891
+ # FileUtils.install('src2.txt', 'dest2')
892
+ # File.read('dest2/src2.txt') # => "aaa\n"
893
+ #
894
+ # If `src` is an array of paths and `dest` points to a directory, copies each
895
+ # path `path` in `src` to `dest/path`:
896
+ #
897
+ # File.file?('src3.txt') # => true
898
+ # File.file?('src3.dat') # => true
899
+ # FileUtils.mkdir('dest3')
900
+ # FileUtils.install(['src3.txt', 'src3.dat'], 'dest3')
901
+ # File.file?('dest3/src3.txt') # => true
902
+ # File.file?('dest3/src3.dat') # => true
903
+ #
904
+ # Keyword arguments:
905
+ #
906
+ # * `group: *group`* - changes the group if not `nil`, using
907
+ # [File.chown](rdoc-ref:File.chown).
908
+ # * `mode: *permissions`* - changes the permissions. using
909
+ # [File.chmod](rdoc-ref:File.chmod).
910
+ # * `noop: true` - does not copy entries; returns `nil`.
911
+ # * `owner: *owner`* - changes the owner if not `nil`, using
912
+ # [File.chown](rdoc-ref:File.chown).
913
+ # * `preserve: true` - preserve timestamps using
914
+ # [File.utime](rdoc-ref:File.utime).
915
+ # * `verbose: true` - prints an equivalent command:
916
+ #
917
+ # FileUtils.install('src0.txt', 'dest0.txt', noop: true, verbose: true)
918
+ # FileUtils.install('src1.txt', 'dest1.txt', noop: true, verbose: true)
919
+ # FileUtils.install('src2.txt', 'dest2', noop: true, verbose: true)
920
+ #
921
+ # Output:
922
+ #
923
+ # install -c src0.txt dest0.txt
924
+ # install -c src1.txt dest1.txt
925
+ # install -c src2.txt dest2
926
+ #
927
+ # Related: [methods for copying](rdoc-ref:FileUtils@Copying).
448
928
  #
449
929
  def self?.install: (path src, path dest, ?mode: mode?, ?owner: String?, ?group: String?, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
450
930
 
@@ -452,38 +932,104 @@ module FileUtils
452
932
  # rdoc-file=lib/fileutils.rb
453
933
  # - link_entry(src, dest, dereference_root = false, remove_destination = false)
454
934
  # -->
455
- # Hard links a file system entry `src` to `dest`. If `src` is a directory, this
456
- # method links its contents recursively.
935
+ # Creates [hard links](https://en.wikipedia.org/wiki/Hard_link); returns `nil`.
936
+ #
937
+ # Arguments `src` and `dest` should be [interpretable as
938
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
939
+ #
940
+ # If `src` is the path to a file and `dest` does not exist, creates a hard link
941
+ # at `dest` pointing to `src`:
457
942
  #
458
- # Both of `src` and `dest` must be a path name. `src` must exist, `dest` must
459
- # not exist.
943
+ # FileUtils.touch('src0.txt')
944
+ # File.exist?('dest0.txt') # => false
945
+ # FileUtils.link_entry('src0.txt', 'dest0.txt')
946
+ # File.file?('dest0.txt') # => true
460
947
  #
461
- # If `dereference_root` is true, this method dereferences the tree root.
948
+ # If `src` is the path to a directory and `dest` does not exist, recursively
949
+ # creates hard links at `dest` pointing to paths in `src`:
462
950
  #
463
- # If `remove_destination` is true, this method removes each destination file
464
- # before copy.
951
+ # FileUtils.mkdir_p(['src1/dir0', 'src1/dir1'])
952
+ # src_file_paths = [
953
+ # 'src1/dir0/t0.txt',
954
+ # 'src1/dir0/t1.txt',
955
+ # 'src1/dir1/t2.txt',
956
+ # 'src1/dir1/t3.txt',
957
+ # ]
958
+ # FileUtils.touch(src_file_paths)
959
+ # File.directory?('dest1') # => true
960
+ # FileUtils.link_entry('src1', 'dest1')
961
+ # File.file?('dest1/dir0/t0.txt') # => true
962
+ # File.file?('dest1/dir0/t1.txt') # => true
963
+ # File.file?('dest1/dir1/t2.txt') # => true
964
+ # File.file?('dest1/dir1/t3.txt') # => true
965
+ #
966
+ # Keyword arguments:
967
+ #
968
+ # * `dereference_root: true` - dereferences `src` if it is a symbolic link.
969
+ # * `remove_destination: true` - removes `dest` before creating links.
970
+ #
971
+ # Raises an exception if `dest` is the path to an existing file or directory and
972
+ # keyword argument `remove_destination: true` is not given.
973
+ #
974
+ # Related: FileUtils.ln (has different options).
465
975
  #
466
976
  def self?.link_entry: (path src, path dest, ?boolish dereference_root, ?boolish remove_destination) -> void
467
977
 
468
978
  # <!--
469
979
  # rdoc-file=lib/fileutils.rb
470
- # - FileUtils.ln(target, link, force: nil, noop: nil, verbose: nil)
471
- # - FileUtils.ln(target, dir, force: nil, noop: nil, verbose: nil)
472
- # - FileUtils.ln(targets, dir, force: nil, noop: nil, verbose: nil)
980
+ # - ln(src, dest, force: nil, noop: nil, verbose: nil)
473
981
  # -->
474
- # In the first form, creates a hard link `link` which points to `target`. If
475
- # `link` already exists, raises Errno::EEXIST. But if the `force` option is set,
476
- # overwrites `link`.
982
+ # Creates [hard links](https://en.wikipedia.org/wiki/Hard_link).
983
+ #
984
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
985
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments).
986
+ #
987
+ # When `src` is the path to an existing file and `dest` is the path to a
988
+ # non-existent file, creates a hard link at `dest` pointing to `src`; returns
989
+ # zero:
990
+ #
991
+ # Dir.children('tmp0/') # => ["t.txt"]
992
+ # Dir.children('tmp1/') # => []
993
+ # FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk') # => 0
994
+ # Dir.children('tmp1/') # => ["t.lnk"]
995
+ #
996
+ # When `src` is the path to an existing file and `dest` is the path to an
997
+ # existing directory, creates a hard link at `dest/src` pointing to `src`;
998
+ # returns zero:
477
999
  #
478
- # FileUtils.ln 'gcc', 'cc', verbose: true
479
- # FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
1000
+ # Dir.children('tmp2') # => ["t.dat"]
1001
+ # Dir.children('tmp3') # => []
1002
+ # FileUtils.ln('tmp2/t.dat', 'tmp3') # => 0
1003
+ # Dir.children('tmp3') # => ["t.dat"]
480
1004
  #
481
- # In the second form, creates a link `dir/target` pointing to `target`. In the
482
- # third form, creates several hard links in the directory `dir`, pointing to
483
- # each item in `targets`. If `dir` is not a directory, raises Errno::ENOTDIR.
1005
+ # When `src` is an array of paths to existing files and `dest` is the path to an
1006
+ # existing directory, then for each path `target` in `src`, creates a hard link
1007
+ # at `dest/target` pointing to `target`; returns `src`:
484
1008
  #
485
- # FileUtils.cd '/sbin'
486
- # FileUtils.ln %w(cp mv mkdir), '/bin' # Now /sbin/cp and /bin/cp are linked.
1009
+ # Dir.children('tmp4/') # => []
1010
+ # FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/') # => ["tmp0/t.txt", "tmp2/t.dat"]
1011
+ # Dir.children('tmp4/') # => ["t.dat", "t.txt"]
1012
+ #
1013
+ # Keyword arguments:
1014
+ #
1015
+ # * `force: true` - overwrites `dest` if it exists.
1016
+ # * `noop: true` - does not create links.
1017
+ # * `verbose: true` - prints an equivalent command:
1018
+ #
1019
+ # FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk', verbose: true)
1020
+ # FileUtils.ln('tmp2/t.dat', 'tmp3', verbose: true)
1021
+ # FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/', verbose: true)
1022
+ #
1023
+ # Output:
1024
+ #
1025
+ # ln tmp0/t.txt tmp1/t.lnk
1026
+ # ln tmp2/t.dat tmp3
1027
+ # ln tmp0/t.txt tmp2/t.dat tmp4/
1028
+ #
1029
+ # Raises an exception if `dest` is the path to an existing file and keyword
1030
+ # argument `force` is not `true`.
1031
+ #
1032
+ # Related: FileUtils.link_entry (has different options).
487
1033
  #
488
1034
  def self?.ln: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
489
1035
 
@@ -503,59 +1049,142 @@ module FileUtils
503
1049
 
504
1050
  # <!--
505
1051
  # rdoc-file=lib/fileutils.rb
506
- # - FileUtils.ln_s(target, link, force: nil, noop: nil, verbose: nil)
507
- # - FileUtils.ln_s(target, dir, force: nil, noop: nil, verbose: nil)
508
- # - FileUtils.ln_s(targets, dir, force: nil, noop: nil, verbose: nil)
1052
+ # - ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
509
1053
  # -->
510
- # In the first form, creates a symbolic link `link` which points to `target`. If
511
- # `link` already exists, raises Errno::EEXIST. But if the `force` option is set,
512
- # overwrites `link`.
1054
+ # Creates [symbolic links](https://en.wikipedia.org/wiki/Symbolic_link).
1055
+ #
1056
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
1057
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments).
513
1058
  #
514
- # FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
515
- # FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
1059
+ # If `src` is the path to an existing file:
516
1060
  #
517
- # In the second form, creates a link `dir/target` pointing to `target`. In the
518
- # third form, creates several symbolic links in the directory `dir`, pointing to
519
- # each item in `targets`. If `dir` is not a directory, raises Errno::ENOTDIR.
1061
+ # * When `dest` is the path to a non-existent file, creates a symbolic link at
1062
+ # `dest` pointing to `src`:
520
1063
  #
521
- # FileUtils.ln_s Dir.glob('/bin/*.rb'), '/home/foo/bin'
1064
+ # FileUtils.touch('src0.txt')
1065
+ # File.exist?('dest0.txt') # => false
1066
+ # FileUtils.ln_s('src0.txt', 'dest0.txt')
1067
+ # File.symlink?('dest0.txt') # => true
522
1068
  #
523
- def self?.ln_s: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
1069
+ # * When `dest` is the path to an existing file, creates a symbolic link at
1070
+ # `dest` pointing to `src` if and only if keyword argument `force: true` is
1071
+ # given (raises an exception otherwise):
1072
+ #
1073
+ # FileUtils.touch('src1.txt')
1074
+ # FileUtils.touch('dest1.txt')
1075
+ # FileUtils.ln_s('src1.txt', 'dest1.txt', force: true)
1076
+ # FileTest.symlink?('dest1.txt') # => true
1077
+ #
1078
+ # FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST.
1079
+ #
1080
+ # If `dest` is the path to a directory, creates a symbolic link at `dest/src`
1081
+ # pointing to `src`:
1082
+ #
1083
+ # FileUtils.touch('src2.txt')
1084
+ # FileUtils.mkdir('destdir2')
1085
+ # FileUtils.ln_s('src2.txt', 'destdir2')
1086
+ # File.symlink?('destdir2/src2.txt') # => true
1087
+ #
1088
+ # If `src` is an array of paths to existing files and `dest` is a directory, for
1089
+ # each child `child` in `src` creates a symbolic link `dest/child` pointing to
1090
+ # `child`:
1091
+ #
1092
+ # FileUtils.mkdir('srcdir3')
1093
+ # FileUtils.touch('srcdir3/src0.txt')
1094
+ # FileUtils.touch('srcdir3/src1.txt')
1095
+ # FileUtils.mkdir('destdir3')
1096
+ # FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3')
1097
+ # File.symlink?('destdir3/src0.txt') # => true
1098
+ # File.symlink?('destdir3/src1.txt') # => true
1099
+ #
1100
+ # Keyword arguments:
1101
+ #
1102
+ # * `force: true` - overwrites `dest` if it exists.
1103
+ # * `relative: false` - create links relative to `dest`.
1104
+ # * `noop: true` - does not create links.
1105
+ # * `verbose: true` - prints an equivalent command:
1106
+ #
1107
+ # FileUtils.ln_s('src0.txt', 'dest0.txt', noop: true, verbose: true)
1108
+ # FileUtils.ln_s('src1.txt', 'destdir1', noop: true, verbose: true)
1109
+ # FileUtils.ln_s('src2.txt', 'dest2.txt', force: true, noop: true, verbose: true)
1110
+ # FileUtils.ln_s(['srcdir3/src0.txt', 'srcdir3/src1.txt'], 'destdir3', noop: true, verbose: true)
1111
+ #
1112
+ # Output:
1113
+ #
1114
+ # ln -s src0.txt dest0.txt
1115
+ # ln -s src1.txt destdir1
1116
+ # ln -sf src2.txt dest2.txt
1117
+ # ln -s srcdir3/src0.txt srcdir3/src1.txt destdir3
1118
+ #
1119
+ # Related: FileUtils.ln_sf.
1120
+ #
1121
+ def self?.ln_s: (pathlist src, path dest, ?force: boolish, ?relative: boolish, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
524
1122
 
525
1123
  # <!--
526
1124
  # rdoc-file=lib/fileutils.rb
527
- # - symlink(src, dest, force: nil, noop: nil, verbose: nil)
1125
+ # - symlink(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
528
1126
  # -->
529
1127
  #
530
1128
  alias self.symlink self.ln_s
531
1129
 
532
1130
  # <!--
533
1131
  # rdoc-file=lib/fileutils.rb
534
- # - symlink(src, dest, force: nil, noop: nil, verbose: nil)
1132
+ # - symlink(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
535
1133
  # -->
536
1134
  #
537
1135
  alias symlink ln_s
538
1136
 
539
1137
  # <!--
540
1138
  # rdoc-file=lib/fileutils.rb
541
- # - FileUtils.ln_sf(*args)
1139
+ # - ln_sf(src, dest, noop: nil, verbose: nil)
542
1140
  # -->
543
- # Same as
544
- #
545
- # FileUtils.ln_s(*args, force: true)
1141
+ # Like FileUtils.ln_s, but always with keyword argument `force: true` given.
546
1142
  #
547
1143
  def self?.ln_sf: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish) -> void
548
1144
 
1145
+ # <!--
1146
+ # rdoc-file=lib/fileutils.rb
1147
+ # - ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)
1148
+ # -->
1149
+ # Like FileUtils.ln_s, but create links relative to `dest`.
1150
+ #
1151
+ def self?.ln_sr: (pathlist src, path dest, ?target_directory: boolish, ?noop: boolish, ?verbose: boolish) -> void
1152
+
549
1153
  # <!--
550
1154
  # rdoc-file=lib/fileutils.rb
551
1155
  # - mkdir(list, mode: nil, noop: nil, verbose: nil)
552
1156
  # -->
553
- # Creates one or more directories.
1157
+ # Creates directories at the paths in the given `list` (a single path or an
1158
+ # array of paths); returns `list` if it is an array, `[list]` otherwise.
1159
+ #
1160
+ # Argument `list` or its elements should be [interpretable as
1161
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
1162
+ #
1163
+ # With no keyword arguments, creates a directory at each `path` in `list` by
1164
+ # calling: `Dir.mkdir(path, mode)`; see [Dir.mkdir](rdoc-ref:Dir.mkdir):
1165
+ #
1166
+ # FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"]
1167
+ # FileUtils.mkdir('tmp4') # => ["tmp4"]
1168
+ #
1169
+ # Keyword arguments:
1170
+ #
1171
+ # * `mode: *mode`* - also calls `File.chmod(mode, path)`; see
1172
+ # [File.chmod](rdoc-ref:File.chmod).
1173
+ # * `noop: true` - does not create directories.
1174
+ # * `verbose: true` - prints an equivalent command:
554
1175
  #
555
- # FileUtils.mkdir 'test'
556
- # FileUtils.mkdir %w(tmp data)
557
- # FileUtils.mkdir 'notexist', noop: true # Does not really create.
558
- # FileUtils.mkdir 'tmp', mode: 0700
1176
+ # FileUtils.mkdir(%w[tmp0 tmp1], verbose: true)
1177
+ # FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true)
1178
+ #
1179
+ # Output:
1180
+ #
1181
+ # mkdir tmp0 tmp1
1182
+ # mkdir -m 700 tmp2 tmp3
1183
+ #
1184
+ # Raises an exception if any path points to an existing file or directory, or if
1185
+ # for any reason a directory cannot be created.
1186
+ #
1187
+ # Related: FileUtils.mkdir_p.
559
1188
  #
560
1189
  def self?.mkdir: (pathlist list, ?mode: Integer?, ?noop: boolish, ?verbose: boolish) -> void
561
1190
 
@@ -563,19 +1192,40 @@ module FileUtils
563
1192
  # rdoc-file=lib/fileutils.rb
564
1193
  # - mkdir_p(list, mode: nil, noop: nil, verbose: nil)
565
1194
  # -->
566
- # Creates a directory and all its parent directories. For example,
1195
+ # Creates directories at the paths in the given `list` (a single path or an
1196
+ # array of paths), also creating ancestor directories as needed; returns `list`
1197
+ # if it is an array, `[list]` otherwise.
1198
+ #
1199
+ # Argument `list` or its elements should be [interpretable as
1200
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
1201
+ #
1202
+ # With no keyword arguments, creates a directory at each `path` in `list`, along
1203
+ # with any needed ancestor directories, by calling: `Dir.mkdir(path, mode)`; see
1204
+ # [Dir.mkdir](rdoc-ref:Dir.mkdir):
1205
+ #
1206
+ # FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"]
1207
+ # FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"]
1208
+ #
1209
+ # Keyword arguments:
567
1210
  #
568
- # FileUtils.mkdir_p '/usr/local/lib/ruby'
1211
+ # * `mode: *mode`* - also calls `File.chmod(mode, path)`; see
1212
+ # [File.chmod](rdoc-ref:File.chmod).
1213
+ # * `noop: true` - does not create directories.
1214
+ # * `verbose: true` - prints an equivalent command:
569
1215
  #
570
- # causes to make following directories, if they do not exist.
1216
+ # FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true)
1217
+ # FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true)
571
1218
  #
572
- # * /usr
573
- # * /usr/local
574
- # * /usr/local/lib
575
- # * /usr/local/lib/ruby
1219
+ # Output:
576
1220
  #
1221
+ # mkdir -p tmp0 tmp1
1222
+ # mkdir -p -m 700 tmp2 tmp3
577
1223
  #
578
- # You can pass several directories at a time in a list.
1224
+ # Raises an exception if for any reason a directory cannot be created.
1225
+ #
1226
+ # FileUtils.mkpath and FileUtils.makedirs are aliases for FileUtils.mkdir_p.
1227
+ #
1228
+ # Related: FileUtils.mkdir.
579
1229
  #
580
1230
  def self?.mkdir_p: (pathlist list, ?mode: mode?, ?noop: boolish, ?verbose: boolish) -> void
581
1231
 
@@ -611,14 +1261,67 @@ module FileUtils
611
1261
  # rdoc-file=lib/fileutils.rb
612
1262
  # - mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
613
1263
  # -->
614
- # Moves file(s) `src` to `dest`. If `file` and `dest` exist on the different
615
- # disk partition, the file is copied then the original file is removed.
616
- #
617
- # FileUtils.mv 'badname.rb', 'goodname.rb'
618
- # FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
619
- #
620
- # FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
621
- # FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
1264
+ # Moves entries.
1265
+ #
1266
+ # Arguments `src` (a single path or an array of paths) and `dest` (a single
1267
+ # path) should be [interpretable as paths](rdoc-ref:FileUtils@Path+Arguments).
1268
+ #
1269
+ # If `src` and `dest` are on different file systems, first copies, then removes
1270
+ # `src`.
1271
+ #
1272
+ # May cause a local vulnerability if not called with keyword argument `secure:
1273
+ # true`; see [Avoiding the TOCTTOU
1274
+ # Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
1275
+ #
1276
+ # If `src` is the path to a single file or directory and `dest` does not exist,
1277
+ # moves `src` to `dest`:
1278
+ #
1279
+ # tree('src0')
1280
+ # # => src0
1281
+ # # |-- src0.txt
1282
+ # # `-- src1.txt
1283
+ # File.exist?('dest0') # => false
1284
+ # FileUtils.mv('src0', 'dest0')
1285
+ # File.exist?('src0') # => false
1286
+ # tree('dest0')
1287
+ # # => dest0
1288
+ # # |-- src0.txt
1289
+ # # `-- src1.txt
1290
+ #
1291
+ # If `src` is an array of paths to files and directories and `dest` is the path
1292
+ # to a directory, copies from each path in the array to `dest`:
1293
+ #
1294
+ # File.file?('src1.txt') # => true
1295
+ # tree('src1')
1296
+ # # => src1
1297
+ # # |-- src.dat
1298
+ # # `-- src.txt
1299
+ # Dir.empty?('dest1') # => true
1300
+ # FileUtils.mv(['src1.txt', 'src1'], 'dest1')
1301
+ # tree('dest1')
1302
+ # # => dest1
1303
+ # # |-- src1
1304
+ # # | |-- src.dat
1305
+ # # | `-- src.txt
1306
+ # # `-- src1.txt
1307
+ #
1308
+ # Keyword arguments:
1309
+ #
1310
+ # * `force: true` - if the move includes removing `src` (that is, if `src` and
1311
+ # `dest` are on different file systems), ignores raised exceptions of
1312
+ # StandardError and its descendants.
1313
+ # * `noop: true` - does not move files.
1314
+ # * `secure: true` - removes `src` securely; see details at
1315
+ # FileUtils.remove_entry_secure.
1316
+ # * `verbose: true` - prints an equivalent command:
1317
+ #
1318
+ # FileUtils.mv('src0', 'dest0', noop: true, verbose: true)
1319
+ # FileUtils.mv(['src1.txt', 'src1'], 'dest1', noop: true, verbose: true)
1320
+ #
1321
+ # Output:
1322
+ #
1323
+ # mv src0 dest0
1324
+ # mv src1.txt src1 dest1
622
1325
  #
623
1326
  def self?.mv: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
624
1327
 
@@ -640,9 +1343,9 @@ module FileUtils
640
1343
  # rdoc-file=lib/fileutils.rb
641
1344
  # - options()
642
1345
  # -->
643
- # Returns an Array of option names.
1346
+ # Returns an array of the string keyword names:
644
1347
  #
645
- # p FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
1348
+ # FileUtils.options.take(3) # => ["noop", "verbose", "force"]
646
1349
  #
647
1350
  def self.options: () -> Array[String]
648
1351
 
@@ -650,9 +1353,11 @@ module FileUtils
650
1353
  # rdoc-file=lib/fileutils.rb
651
1354
  # - options_of(mid)
652
1355
  # -->
653
- # Returns an Array of option names of the method `mid`.
1356
+ # Returns an array of the string keyword name for method `mid`; the argument may
1357
+ # be a string or a symbol:
654
1358
  #
655
- # p FileUtils.options_of(:rm) #=> ["noop", "verbose", "force"]
1359
+ # FileUtils.options_of(:rm) # => ["force", "noop", "verbose"]
1360
+ # FileUtils.options_of('mv') # => ["force", "noop", "verbose", "secure"]
656
1361
  #
657
1362
  def self.options_of: (Symbol mid) -> Array[String]
658
1363
 
@@ -660,7 +1365,11 @@ module FileUtils
660
1365
  # rdoc-file=lib/fileutils.rb
661
1366
  # - pwd()
662
1367
  # -->
663
- # Returns the name of the current directory.
1368
+ # Returns a string containing the path to the current directory:
1369
+ #
1370
+ # FileUtils.pwd # => "/rdoc/fileutils"
1371
+ #
1372
+ # Related: FileUtils.cd.
664
1373
  #
665
1374
  def self?.pwd: () -> String
666
1375
 
@@ -682,8 +1391,16 @@ module FileUtils
682
1391
  # rdoc-file=lib/fileutils.rb
683
1392
  # - remove_dir(path, force = false)
684
1393
  # -->
685
- # Removes a directory `dir` and its contents recursively. This method ignores
686
- # StandardError if `force` is true.
1394
+ # Recursively removes the directory entry given by `path`, which should be the
1395
+ # entry for a regular file, a symbolic link, or a directory.
1396
+ #
1397
+ # Argument `path` should be [interpretable as a
1398
+ # path](rdoc-ref:FileUtils@Path+Arguments).
1399
+ #
1400
+ # Optional argument `force` specifies whether to ignore raised exceptions of
1401
+ # StandardError and its descendants.
1402
+ #
1403
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
687
1404
  #
688
1405
  def self?.remove_dir: (path path, ?boolish force) -> void
689
1406
 
@@ -691,11 +1408,16 @@ module FileUtils
691
1408
  # rdoc-file=lib/fileutils.rb
692
1409
  # - remove_entry(path, force = false)
693
1410
  # -->
694
- # This method removes a file system entry `path`. `path` might be a regular
695
- # file, a directory, or something. If `path` is a directory, remove it
696
- # recursively.
1411
+ # Removes the entry given by `path`, which should be the entry for a regular
1412
+ # file, a symbolic link, or a directory.
1413
+ #
1414
+ # Argument `path` should be [interpretable as a
1415
+ # path](rdoc-ref:FileUtils@Path+Arguments).
697
1416
  #
698
- # See also remove_entry_secure.
1417
+ # Optional argument `force` specifies whether to ignore raised exceptions of
1418
+ # StandardError and its descendants.
1419
+ #
1420
+ # Related: FileUtils.remove_entry_secure.
699
1421
  #
700
1422
  def self?.remove_entry: (path path, ?boolish force) -> void
701
1423
 
@@ -703,37 +1425,20 @@ module FileUtils
703
1425
  # rdoc-file=lib/fileutils.rb
704
1426
  # - remove_entry_secure(path, force = false)
705
1427
  # -->
706
- # This method removes a file system entry `path`. `path` shall be a regular
707
- # file, a directory, or something. If `path` is a directory, remove it
708
- # recursively. This method is required to avoid TOCTTOU
709
- # (time-of-check-to-time-of-use) local security vulnerability of rm_r. #rm_r
710
- # causes security hole when:
711
- #
712
- # * Parent directory is world writable (including /tmp).
713
- # * Removing directory tree includes world writable directory.
714
- # * The system has symbolic link.
715
- #
716
- #
717
- # To avoid this security hole, this method applies special preprocess. If `path`
718
- # is a directory, this method chown(2) and chmod(2) all removing directories.
719
- # This requires the current process is the owner of the removing whole directory
720
- # tree, or is the super user (root).
721
- #
722
- # WARNING: You must ensure that **ALL** parent directories cannot be moved by
723
- # other untrusted users. For example, parent directories should not be owned by
724
- # untrusted users, and should not be world writable except when the sticky bit
725
- # set.
726
- #
727
- # WARNING: Only the owner of the removing directory tree, or Unix super user
728
- # (root) should invoke this method. Otherwise this method does not work.
1428
+ # Securely removes the entry given by `path`, which should be the entry for a
1429
+ # regular file, a symbolic link, or a directory.
729
1430
  #
730
- # For details of this security vulnerability, see Perl's case:
1431
+ # Argument `path` should be [interpretable as a
1432
+ # path](rdoc-ref:FileUtils@Path+Arguments).
731
1433
  #
732
- # * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
733
- # * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
1434
+ # Avoids a local vulnerability that can exist in certain circumstances; see
1435
+ # [Avoiding the TOCTTOU
1436
+ # Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
734
1437
  #
1438
+ # Optional argument `force` specifies whether to ignore raised exceptions of
1439
+ # StandardError and its descendants.
735
1440
  #
736
- # For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
1441
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
737
1442
  #
738
1443
  def self?.remove_entry_secure: (path path, ?boolish force) -> void
739
1444
 
@@ -741,20 +1446,48 @@ module FileUtils
741
1446
  # rdoc-file=lib/fileutils.rb
742
1447
  # - remove_file(path, force = false)
743
1448
  # -->
744
- # Removes a file `path`. This method ignores StandardError if `force` is true.
1449
+ # Removes the file entry given by `path`, which should be the entry for a
1450
+ # regular file or a symbolic link.
745
1451
  #
746
- def self?.remove_file: (path path, ?void force) -> void
1452
+ # Argument `path` should be [interpretable as a
1453
+ # path](rdoc-ref:FileUtils@Path+Arguments).
1454
+ #
1455
+ # Optional argument `force` specifies whether to ignore raised exceptions of
1456
+ # StandardError and its descendants.
1457
+ #
1458
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
1459
+ #
1460
+ def self?.remove_file: (path path, ?boolish force) -> void
747
1461
 
748
1462
  # <!--
749
1463
  # rdoc-file=lib/fileutils.rb
750
1464
  # - rm(list, force: nil, noop: nil, verbose: nil)
751
1465
  # -->
752
- # Remove file(s) specified in `list`. This method cannot remove directories.
753
- # All StandardErrors are ignored when the :force option is set.
1466
+ # Removes entries at the paths in the given `list` (a single path or an array of
1467
+ # paths) returns `list`, if it is an array, `[list]` otherwise.
1468
+ #
1469
+ # Argument `list` or its elements should be [interpretable as
1470
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
1471
+ #
1472
+ # With no keyword arguments, removes files at the paths given in `list`:
1473
+ #
1474
+ # FileUtils.touch(['src0.txt', 'src0.dat'])
1475
+ # FileUtils.rm(['src0.dat', 'src0.txt']) # => ["src0.dat", "src0.txt"]
1476
+ #
1477
+ # Keyword arguments:
1478
+ #
1479
+ # * `force: true` - ignores raised exceptions of StandardError and its
1480
+ # descendants.
1481
+ # * `noop: true` - does not remove files; returns `nil`.
1482
+ # * `verbose: true` - prints an equivalent command:
754
1483
  #
755
- # FileUtils.rm %w( junk.txt dust.txt )
756
- # FileUtils.rm Dir.glob('*.so')
757
- # FileUtils.rm 'NotExistFile', force: true # never raises exception
1484
+ # FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true)
1485
+ #
1486
+ # Output:
1487
+ #
1488
+ # rm src0.dat src0.txt
1489
+ #
1490
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
758
1491
  #
759
1492
  def self?.rm: (pathlist list, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
760
1493
 
@@ -776,9 +1509,16 @@ module FileUtils
776
1509
  # rdoc-file=lib/fileutils.rb
777
1510
  # - rm_f(list, noop: nil, verbose: nil)
778
1511
  # -->
779
- # Equivalent to
1512
+ # Equivalent to:
1513
+ #
1514
+ # FileUtils.rm(list, force: true, **kwargs)
780
1515
  #
781
- # FileUtils.rm(list, force: true)
1516
+ # Argument `list` (a single path or an array of paths) should be [interpretable
1517
+ # as paths](rdoc-ref:FileUtils@Path+Arguments).
1518
+ #
1519
+ # See FileUtils.rm for keyword arguments.
1520
+ #
1521
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
782
1522
  #
783
1523
  def self?.rm_f: (pathlist list, ?noop: boolish, ?verbose: boolish) -> void
784
1524
 
@@ -800,22 +1540,54 @@ module FileUtils
800
1540
  # rdoc-file=lib/fileutils.rb
801
1541
  # - rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
802
1542
  # -->
803
- # remove files `list`[0] `list`[1]... If `list`[n] is a directory, removes its
804
- # all contents recursively. This method ignores StandardError when :force option
805
- # is set.
1543
+ # Removes entries at the paths in the given `list` (a single path or an array of
1544
+ # paths); returns `list`, if it is an array, `[list]` otherwise.
1545
+ #
1546
+ # Argument `list` or its elements should be [interpretable as
1547
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
1548
+ #
1549
+ # May cause a local vulnerability if not called with keyword argument `secure:
1550
+ # true`; see [Avoiding the TOCTTOU
1551
+ # Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
806
1552
  #
807
- # FileUtils.rm_r Dir.glob('/tmp/*')
808
- # FileUtils.rm_r 'some_dir', force: true
1553
+ # For each file path, removes the file at that path:
809
1554
  #
810
- # WARNING: This method causes local vulnerability if one of parent directories
811
- # or removing directory tree are world writable (including /tmp, whose
812
- # permission is 1777), and the current process has strong privilege such as Unix
813
- # super user (root), and the system has symbolic link. For secure removing,
814
- # read the documentation of remove_entry_secure carefully, and set :secure
815
- # option to true. Default is `secure: false`.
1555
+ # FileUtils.touch(['src0.txt', 'src0.dat'])
1556
+ # FileUtils.rm_r(['src0.dat', 'src0.txt'])
1557
+ # File.exist?('src0.txt') # => false
1558
+ # File.exist?('src0.dat') # => false
816
1559
  #
817
- # NOTE: This method calls remove_entry_secure if :secure option is set. See also
818
- # remove_entry_secure.
1560
+ # For each directory path, recursively removes files and directories:
1561
+ #
1562
+ # tree('src1')
1563
+ # # => src1
1564
+ # # |-- dir0
1565
+ # # | |-- src0.txt
1566
+ # # | `-- src1.txt
1567
+ # # `-- dir1
1568
+ # # |-- src2.txt
1569
+ # # `-- src3.txt
1570
+ # FileUtils.rm_r('src1')
1571
+ # File.exist?('src1') # => false
1572
+ #
1573
+ # Keyword arguments:
1574
+ #
1575
+ # * `force: true` - ignores raised exceptions of StandardError and its
1576
+ # descendants.
1577
+ # * `noop: true` - does not remove entries; returns `nil`.
1578
+ # * `secure: true` - removes `src` securely; see details at
1579
+ # FileUtils.remove_entry_secure.
1580
+ # * `verbose: true` - prints an equivalent command:
1581
+ #
1582
+ # FileUtils.rm_r(['src0.dat', 'src0.txt'], noop: true, verbose: true)
1583
+ # FileUtils.rm_r('src1', noop: true, verbose: true)
1584
+ #
1585
+ # Output:
1586
+ #
1587
+ # rm -r src0.dat src0.txt
1588
+ # rm -r src1
1589
+ #
1590
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
819
1591
  #
820
1592
  def self?.rm_r: (pathlist list, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
821
1593
 
@@ -823,12 +1595,20 @@ module FileUtils
823
1595
  # rdoc-file=lib/fileutils.rb
824
1596
  # - rm_rf(list, noop: nil, verbose: nil, secure: nil)
825
1597
  # -->
826
- # Equivalent to
1598
+ # Equivalent to:
1599
+ #
1600
+ # FileUtils.rm_r(list, force: true, **kwargs)
827
1601
  #
828
- # FileUtils.rm_r(list, force: true)
1602
+ # Argument `list` or its elements should be [interpretable as
1603
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
829
1604
  #
830
- # WARNING: This method causes local vulnerability. Read the documentation of
831
- # rm_r first.
1605
+ # May cause a local vulnerability if not called with keyword argument `secure:
1606
+ # true`; see [Avoiding the TOCTTOU
1607
+ # Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
1608
+ #
1609
+ # See FileUtils.rm_r for keyword arguments.
1610
+ #
1611
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
832
1612
  #
833
1613
  def self?.rm_rf: (pathlist list, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
834
1614
 
@@ -850,12 +1630,36 @@ module FileUtils
850
1630
  # rdoc-file=lib/fileutils.rb
851
1631
  # - rmdir(list, parents: nil, noop: nil, verbose: nil)
852
1632
  # -->
853
- # Removes one or more directories.
1633
+ # Removes directories at the paths in the given `list` (a single path or an
1634
+ # array of paths); returns `list`, if it is an array, `[list]` otherwise.
1635
+ #
1636
+ # Argument `list` or its elements should be [interpretable as
1637
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
1638
+ #
1639
+ # With no keyword arguments, removes the directory at each `path` in `list`, by
1640
+ # calling: `Dir.rmdir(path)`; see [Dir.rmdir](rdoc-ref:Dir.rmdir):
1641
+ #
1642
+ # FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"]
1643
+ # FileUtils.rmdir('tmp4/tmp5') # => ["tmp4/tmp5"]
1644
+ #
1645
+ # Keyword arguments:
1646
+ #
1647
+ # * `parents: true` - removes successive ancestor directories if empty.
1648
+ # * `noop: true` - does not remove directories.
1649
+ # * `verbose: true` - prints an equivalent command:
1650
+ #
1651
+ # FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3], parents: true, verbose: true)
1652
+ # FileUtils.rmdir('tmp4/tmp5', parents: true, verbose: true)
854
1653
  #
855
- # FileUtils.rmdir 'somedir'
856
- # FileUtils.rmdir %w(somedir anydir otherdir)
857
- # # Does not really remove directory; outputs message.
858
- # FileUtils.rmdir 'somedir', verbose: true, noop: true
1654
+ # Output:
1655
+ #
1656
+ # rmdir -p tmp0/tmp1 tmp2/tmp3
1657
+ # rmdir -p tmp4/tmp5
1658
+ #
1659
+ # Raises an exception if a directory does not exist or if for any reason a
1660
+ # directory cannot be removed.
1661
+ #
1662
+ # Related: [methods for deleting](rdoc-ref:FileUtils@Deleting).
859
1663
  #
860
1664
  def self?.rmdir: (pathlist list, ?parents: boolish, ?noop: boolish, ?verbose: boolish) -> void
861
1665
 
@@ -863,11 +1667,49 @@ module FileUtils
863
1667
  # rdoc-file=lib/fileutils.rb
864
1668
  # - touch(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)
865
1669
  # -->
866
- # Updates modification time (mtime) and access time (atime) of file(s) in
867
- # `list`. Files are created if they don't exist.
1670
+ # Updates modification times (mtime) and access times (atime) of the entries
1671
+ # given by the paths in `list` (a single path or an array of paths); returns
1672
+ # `list` if it is an array, `[list]` otherwise.
1673
+ #
1674
+ # By default, creates an empty file for any path to a non-existent entry; use
1675
+ # keyword argument `nocreate` to raise an exception instead.
1676
+ #
1677
+ # Argument `list` or its elements should be [interpretable as
1678
+ # paths](rdoc-ref:FileUtils@Path+Arguments).
1679
+ #
1680
+ # Examples:
1681
+ #
1682
+ # # Single path.
1683
+ # f = File.new('src0.txt') # Existing file.
1684
+ # f.atime # => 2022-06-10 11:11:21.200277 -0700
1685
+ # f.mtime # => 2022-06-10 11:11:21.200277 -0700
1686
+ # FileUtils.touch('src0.txt')
1687
+ # f = File.new('src0.txt')
1688
+ # f.atime # => 2022-06-11 08:28:09.8185343 -0700
1689
+ # f.mtime # => 2022-06-11 08:28:09.8185343 -0700
1690
+ #
1691
+ # # Array of paths.
1692
+ # FileUtils.touch(['src0.txt', 'src0.dat'])
868
1693
  #
869
- # FileUtils.touch 'timestamp'
870
- # FileUtils.touch Dir.glob('*.c'); system 'make'
1694
+ # Keyword arguments:
1695
+ #
1696
+ # * `mtime: *time`* - sets the entry's mtime to the given time, instead of the
1697
+ # current time.
1698
+ # * `nocreate: true` - raises an exception if the entry does not exist.
1699
+ # * `noop: true` - does not touch entries; returns `nil`.
1700
+ # * `verbose: true` - prints an equivalent command:
1701
+ #
1702
+ # FileUtils.touch('src0.txt', noop: true, verbose: true)
1703
+ # FileUtils.touch(['src0.txt', 'src0.dat'], noop: true, verbose: true)
1704
+ # FileUtils.touch(path, noop: true, verbose: true)
1705
+ #
1706
+ # Output:
1707
+ #
1708
+ # touch src0.txt
1709
+ # touch src0.txt src0.dat
1710
+ # touch src0.txt
1711
+ #
1712
+ # Related: FileUtils.uptodate?.
871
1713
  #
872
1714
  def self?.touch: (pathlist list, ?noop: boolish, ?verbose: boolish, ?mtime: (Time | Numeric)?, ?nocreate: boolish) -> void
873
1715
 
@@ -875,11 +1717,18 @@ module FileUtils
875
1717
  # rdoc-file=lib/fileutils.rb
876
1718
  # - uptodate?(new, old_list)
877
1719
  # -->
878
- # Returns true if `new` is newer than all `old_list`. Non-existent files are
879
- # older than any file.
1720
+ # Returns `true` if the file at path `new` is newer than all the files at paths
1721
+ # in array `old_list`; `false` otherwise.
1722
+ #
1723
+ # Argument `new` and the elements of `old_list` should be [interpretable as
1724
+ # paths](rdoc-ref:FileUtils@Path+Arguments):
1725
+ #
1726
+ # FileUtils.uptodate?('Rakefile', ['Gemfile', 'README.md']) # => true
1727
+ # FileUtils.uptodate?('Gemfile', ['Rakefile', 'README.md']) # => false
1728
+ #
1729
+ # A non-existent file is considered to be infinitely old.
880
1730
  #
881
- # FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
882
- # system 'make hello.o'
1731
+ # Related: FileUtils.touch.
883
1732
  #
884
- def self?.uptodate?: (path new, pathlist old_list) -> bool
1733
+ def self?.uptodate?: (path new, _Each[path] old_list) -> bool
885
1734
  end