rbs 2.0.0 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +34 -0
  3. data/.github/workflows/ruby.yml +5 -0
  4. data/CHANGELOG.md +82 -0
  5. data/README.md +6 -1
  6. data/Rakefile +56 -21
  7. data/core/array.rbs +2866 -1086
  8. data/core/basic_object.rbs +150 -30
  9. data/core/binding.rbs +33 -0
  10. data/core/builtin.rbs +4 -4
  11. data/core/class.rbs +43 -5
  12. data/core/comparable.rbs +57 -0
  13. data/core/complex.rbs +170 -4
  14. data/core/constants.rbs +51 -0
  15. data/core/deprecated.rbs +7 -0
  16. data/core/dir.rbs +305 -20
  17. data/core/encoding.rbs +1214 -77
  18. data/core/enumerable.rbs +2173 -234
  19. data/core/enumerator.rbs +448 -182
  20. data/core/env.rbs +448 -1
  21. data/core/errno.rbs +1 -10
  22. data/core/errors.rbs +152 -2
  23. data/core/exception.rbs +201 -127
  24. data/core/false_class.rbs +27 -0
  25. data/core/fiber.rbs +118 -37
  26. data/core/fiber_error.rbs +8 -9
  27. data/core/file.rbs +1060 -142
  28. data/core/file_test.rbs +287 -32
  29. data/core/float.rbs +776 -300
  30. data/core/gc.rbs +185 -34
  31. data/core/global_variables.rbs +5 -1
  32. data/core/hash.rbs +1582 -649
  33. data/core/integer.rbs +974 -204
  34. data/core/io/buffer.rbs +710 -0
  35. data/core/io/wait.rbs +29 -8
  36. data/core/io.rbs +2438 -417
  37. data/core/kernel.rbs +2319 -318
  38. data/core/marshal.rbs +37 -2
  39. data/core/match_data.rbs +123 -6
  40. data/core/math.rbs +126 -6
  41. data/core/method.rbs +226 -102
  42. data/core/module.rbs +421 -45
  43. data/core/nil_class.rbs +64 -0
  44. data/core/numeric.rbs +620 -142
  45. data/core/object.rbs +453 -81
  46. data/core/object_space.rbs +92 -2
  47. data/core/proc.rbs +482 -285
  48. data/core/process.rbs +443 -34
  49. data/core/ractor.rbs +232 -9
  50. data/core/random.rbs +151 -52
  51. data/core/range.rbs +885 -160
  52. data/core/rational.rbs +122 -6
  53. data/core/rb_config.rbs +14 -4
  54. data/core/refinement.rbs +44 -0
  55. data/core/regexp.rbs +156 -14
  56. data/core/ruby_vm.rbs +42 -3
  57. data/core/signal.rbs +78 -39
  58. data/core/string.rbs +2123 -567
  59. data/core/string_io.rbs +204 -0
  60. data/core/struct.rbs +283 -28
  61. data/core/symbol.rbs +304 -30
  62. data/core/thread.rbs +1288 -688
  63. data/core/thread_group.rbs +66 -10
  64. data/core/time.rbs +643 -217
  65. data/core/trace_point.rbs +100 -12
  66. data/core/true_class.rbs +24 -0
  67. data/core/unbound_method.rbs +73 -7
  68. data/core/warning.rbs +37 -12
  69. data/docs/CONTRIBUTING.md +40 -34
  70. data/docs/stdlib.md +3 -102
  71. data/docs/syntax.md +54 -11
  72. data/ext/rbs_extension/extconf.rb +1 -0
  73. data/ext/rbs_extension/lexer.h +5 -0
  74. data/ext/rbs_extension/lexstate.c +6 -0
  75. data/ext/rbs_extension/parser.c +85 -10
  76. data/ext/rbs_extension/ruby_objs.c +4 -2
  77. data/ext/rbs_extension/ruby_objs.h +2 -2
  78. data/goodcheck.yml +0 -11
  79. data/lib/rbs/annotate/annotations.rb +197 -0
  80. data/lib/rbs/annotate/formatter.rb +80 -0
  81. data/lib/rbs/annotate/rdoc_annotator.rb +398 -0
  82. data/lib/rbs/annotate/rdoc_source.rb +120 -0
  83. data/lib/rbs/annotate.rb +6 -0
  84. data/lib/rbs/ast/members.rb +21 -13
  85. data/lib/rbs/buffer.rb +17 -11
  86. data/lib/rbs/cli.rb +48 -1
  87. data/lib/rbs/definition_builder/method_builder.rb +28 -16
  88. data/lib/rbs/definition_builder.rb +6 -2
  89. data/lib/rbs/environment.rb +8 -4
  90. data/lib/rbs/location_aux.rb +12 -0
  91. data/lib/rbs/namespace.rb +1 -1
  92. data/lib/rbs/prototype/rb.rb +12 -0
  93. data/lib/rbs/type_alias_regularity.rb +6 -4
  94. data/lib/rbs/type_name.rb +1 -1
  95. data/lib/rbs/types.rb +1 -1
  96. data/lib/rbs/validator.rb +6 -0
  97. data/lib/rbs/version.rb +1 -1
  98. data/lib/rbs/writer.rb +54 -4
  99. data/lib/rbs.rb +0 -2
  100. data/schema/typeParam.json +3 -3
  101. data/sig/annotate/annotations.rbs +102 -0
  102. data/sig/annotate/formatter.rbs +24 -0
  103. data/sig/annotate/rdoc_annotater.rbs +82 -0
  104. data/sig/annotate/rdoc_source.rbs +30 -0
  105. data/sig/buffer.rbs +6 -2
  106. data/sig/cli.rbs +2 -0
  107. data/sig/collection/{collections.rbs → sources.rbs} +0 -0
  108. data/sig/location.rbs +6 -0
  109. data/sig/members.rbs +24 -18
  110. data/sig/method_builder.rbs +5 -4
  111. data/sig/method_types.rbs +5 -1
  112. data/sig/polyfill.rbs +78 -0
  113. data/sig/validator.rbs +3 -1
  114. data/sig/writer.rbs +79 -2
  115. data/stdlib/abbrev/0/abbrev.rbs +6 -0
  116. data/stdlib/abbrev/0/array.rbs +26 -0
  117. data/stdlib/base64/0/base64.rbs +31 -0
  118. data/stdlib/benchmark/0/benchmark.rbs +74 -3
  119. data/stdlib/bigdecimal/0/big_decimal.rbs +614 -165
  120. data/stdlib/bigdecimal-math/0/big_math.rbs +41 -64
  121. data/stdlib/cgi/0/core.rbs +649 -21
  122. data/stdlib/coverage/0/coverage.rbs +164 -2
  123. data/stdlib/csv/0/csv.rbs +2862 -398
  124. data/stdlib/date/0/date.rbs +483 -25
  125. data/stdlib/date/0/date_time.rbs +187 -12
  126. data/stdlib/dbm/0/dbm.rbs +152 -17
  127. data/stdlib/digest/0/digest.rbs +146 -0
  128. data/stdlib/erb/0/erb.rbs +65 -245
  129. data/stdlib/fiber/0/fiber.rbs +73 -91
  130. data/stdlib/fileutils/0/fileutils.rbs +301 -1
  131. data/stdlib/find/0/find.rbs +9 -0
  132. data/stdlib/forwardable/0/forwardable.rbs +65 -1
  133. data/stdlib/io-console/0/io-console.rbs +227 -15
  134. data/stdlib/ipaddr/0/ipaddr.rbs +161 -0
  135. data/stdlib/json/0/json.rbs +1147 -145
  136. data/stdlib/logger/0/formatter.rbs +24 -0
  137. data/stdlib/logger/0/log_device.rbs +64 -0
  138. data/stdlib/logger/0/logger.rbs +165 -13
  139. data/stdlib/logger/0/period.rbs +10 -0
  140. data/stdlib/logger/0/severity.rbs +26 -0
  141. data/stdlib/monitor/0/monitor.rbs +163 -0
  142. data/stdlib/mutex_m/0/mutex_m.rbs +35 -6
  143. data/stdlib/net-http/0/manifest.yaml +1 -0
  144. data/stdlib/net-http/0/net-http.rbs +1513 -683
  145. data/stdlib/nkf/0/nkf.rbs +372 -0
  146. data/stdlib/objspace/0/objspace.rbs +149 -90
  147. data/stdlib/openssl/0/openssl.rbs +8108 -71
  148. data/stdlib/optparse/0/optparse.rbs +487 -19
  149. data/stdlib/pathname/0/pathname.rbs +425 -124
  150. data/stdlib/prettyprint/0/prettyprint.rbs +120 -99
  151. data/stdlib/prime/0/integer-extension.rbs +20 -2
  152. data/stdlib/prime/0/prime.rbs +88 -21
  153. data/stdlib/pstore/0/pstore.rbs +102 -0
  154. data/stdlib/pty/0/pty.rbs +64 -14
  155. data/stdlib/resolv/0/resolv.rbs +420 -31
  156. data/stdlib/rubygems/0/basic_specification.rbs +4 -1
  157. data/stdlib/rubygems/0/config_file.rbs +33 -1
  158. data/stdlib/rubygems/0/dependency_installer.rbs +4 -3
  159. data/stdlib/rubygems/0/installer.rbs +13 -1
  160. data/stdlib/rubygems/0/path_support.rbs +4 -1
  161. data/stdlib/rubygems/0/platform.rbs +5 -1
  162. data/stdlib/rubygems/0/request_set.rbs +44 -2
  163. data/stdlib/rubygems/0/requirement.rbs +65 -2
  164. data/stdlib/rubygems/0/rubygems.rbs +407 -0
  165. data/stdlib/rubygems/0/source_list.rbs +13 -0
  166. data/stdlib/rubygems/0/specification.rbs +21 -1
  167. data/stdlib/rubygems/0/stream_ui.rbs +3 -1
  168. data/stdlib/rubygems/0/uninstaller.rbs +8 -1
  169. data/stdlib/rubygems/0/version.rbs +60 -157
  170. data/stdlib/securerandom/0/securerandom.rbs +44 -0
  171. data/stdlib/set/0/set.rbs +423 -109
  172. data/stdlib/shellwords/0/shellwords.rbs +55 -77
  173. data/stdlib/singleton/0/singleton.rbs +20 -0
  174. data/stdlib/socket/0/addrinfo.rbs +210 -9
  175. data/stdlib/socket/0/basic_socket.rbs +103 -11
  176. data/stdlib/socket/0/ip_socket.rbs +31 -9
  177. data/stdlib/socket/0/socket.rbs +586 -38
  178. data/stdlib/socket/0/tcp_server.rbs +22 -2
  179. data/stdlib/socket/0/tcp_socket.rbs +12 -1
  180. data/stdlib/socket/0/udp_socket.rbs +25 -2
  181. data/stdlib/socket/0/unix_server.rbs +22 -2
  182. data/stdlib/socket/0/unix_socket.rbs +45 -5
  183. data/stdlib/strscan/0/string_scanner.rbs +210 -9
  184. data/stdlib/tempfile/0/tempfile.rbs +58 -10
  185. data/stdlib/time/0/time.rbs +208 -116
  186. data/stdlib/timeout/0/timeout.rbs +10 -0
  187. data/stdlib/tmpdir/0/tmpdir.rbs +13 -4
  188. data/stdlib/tsort/0/cyclic.rbs +1 -0
  189. data/stdlib/tsort/0/interfaces.rbs +1 -0
  190. data/stdlib/tsort/0/tsort.rbs +42 -0
  191. data/stdlib/uri/0/common.rbs +57 -8
  192. data/stdlib/uri/0/file.rbs +55 -109
  193. data/stdlib/uri/0/ftp.rbs +6 -3
  194. data/stdlib/uri/0/generic.rbs +558 -329
  195. data/stdlib/uri/0/http.rbs +60 -114
  196. data/stdlib/uri/0/https.rbs +8 -102
  197. data/stdlib/uri/0/ldap.rbs +143 -137
  198. data/stdlib/uri/0/ldaps.rbs +8 -102
  199. data/stdlib/uri/0/mailto.rbs +3 -0
  200. data/stdlib/uri/0/rfc2396_parser.rbs +66 -26
  201. data/stdlib/uri/0/ws.rbs +6 -3
  202. data/stdlib/uri/0/wss.rbs +5 -3
  203. data/stdlib/yaml/0/dbm.rbs +151 -87
  204. data/stdlib/yaml/0/store.rbs +6 -0
  205. data/stdlib/zlib/0/zlib.rbs +90 -31
  206. metadata +18 -6
  207. data/lib/rbs/location.rb +0 -221
  208. data/sig/char_scanner.rbs +0 -9
data/core/dir.rbs CHANGED
@@ -1,3 +1,4 @@
1
+ # <!-- rdoc-file=dir.rb -->
1
2
  # Objects of class Dir are directory streams representing directories in the
2
3
  # underlying file system. They provide a variety of ways to list directories and
3
4
  # their contents. See also File.
@@ -6,9 +7,148 @@
6
7
  # (`config.h` and `main.rb`), the parent directory (`..`), and the directory
7
8
  # itself (`.`).
8
9
  #
10
+ # ## What's Here
11
+ #
12
+ # First, what's elsewhere. Class Dir:
13
+ #
14
+ # * Inherits from [class
15
+ # Object](Object.html#class-Object-label-What-27s+Here).
16
+ # * Includes [module
17
+ # Enumerable](Enumerable.html#module-Enumerable-label-What-27s+Here), which
18
+ # provides dozens of additional methods.
19
+ #
20
+ #
21
+ # Here, class Dir provides methods that are useful for:
22
+ #
23
+ # * [Reading](#class-Dir-label-Reading)
24
+ # * [Setting](#class-Dir-label-Setting)
25
+ # * [Querying](#class-Dir-label-Querying)
26
+ # * [Iterating](#class-Dir-label-Iterating)
27
+ # * [Other](#class-Dir-label-Other)
28
+ #
29
+ #
30
+ # ### Reading
31
+ #
32
+ # #close
33
+ # : Closes the directory stream for `self`.
34
+ #
35
+ # #pos=
36
+ # : Sets the position in the directory stream for `self`.
37
+ #
38
+ # #read
39
+ # : Reads and returns the next entry in the directory stream for `self`.
40
+ #
41
+ # #rewind
42
+ # : Sets the position in the directory stream for `self` to the first
43
+ # entry.
44
+ #
45
+ # #seek
46
+ # : Sets the position in the directory stream for `self` the entry at the
47
+ # given offset.
48
+ #
49
+ #
50
+ #
51
+ # ### Setting
52
+ #
53
+ # ::chdir
54
+ # : Changes the working directory of the current process to the given
55
+ # directory.
56
+ #
57
+ # ::chroot
58
+ # : Changes the file-system root for the current process to the given
59
+ # directory.
60
+ #
61
+ #
62
+ #
63
+ # ### Querying
64
+ #
65
+ # ::[]
66
+ # : Same as ::glob without the ability to pass flags.
67
+ #
68
+ # ::children
69
+ # : Returns an array of names of the children (both files and directories)
70
+ # of the given directory, but not including `.` or `..`.
71
+ #
72
+ # ::empty?
73
+ # : Returns whether the given path is an empty directory.
74
+ #
75
+ # ::entries
76
+ # : Returns an array of names of the children (both files and directories)
77
+ # of the given directory, including `.` and `..`.
78
+ #
79
+ # ::exist?
80
+ # : Returns whether the given path is a directory.
81
+ #
82
+ # ::getwd (aliased as #pwd)
83
+ # : Returns the path to the current working directory.
84
+ #
85
+ # ::glob
86
+ # : Returns an array of file paths matching the given pattern and flags.
87
+ #
88
+ # ::home
89
+ # : Returns the home directory path for a given user or the current user.
90
+ #
91
+ # #children
92
+ # : Returns an array of names of the children (both files and directories)
93
+ # of `self`, but not including `.` or `..`.
94
+ #
95
+ # #fileno
96
+ # : Returns the integer file descriptor for `self`.
97
+ #
98
+ # #path (aliased as #to_path)
99
+ # : Returns the path used to create `self`.
100
+ #
101
+ # #tell (aliased as #pos)
102
+ # : Returns the integer position in the directory stream for `self`.
103
+ #
104
+ #
105
+ #
106
+ # ### Iterating
107
+ #
108
+ # ::each_child
109
+ # : Calls the given block with each entry in the given directory, but not
110
+ # including `.` or `..`.
111
+ #
112
+ # ::foreach
113
+ # : Calls the given block with each entryin the given directory, including
114
+ # `.` and `..`.
115
+ #
116
+ # #each
117
+ # : Calls the given block with each entry in `self`, including `.` and
118
+ # `..`.
119
+ #
120
+ # #each_child
121
+ # : Calls the given block with each entry in `self`, but not including `.`
122
+ # or `..`.
123
+ #
124
+ #
125
+ #
126
+ # ### Other
127
+ #
128
+ # ::mkdir
129
+ # : Creates a directory at the given path, with optional permissions.
130
+ #
131
+ # ::new
132
+ # : Returns a new Dir for the given path, with optional encoding.
133
+ #
134
+ # ::open
135
+ # : Same as ::new, but if a block is given, yields the Dir to the block,
136
+ # closing it upon block exit.
137
+ #
138
+ # ::unlink (aliased as ::delete and ::rmdir)
139
+ # : Removes the given directory.
140
+ #
141
+ # #inspect
142
+ # : Returns a string description of `self`.
143
+ #
9
144
  class Dir
10
145
  include Enumerable[String]
11
146
 
147
+ # <!--
148
+ # rdoc-file=dir.rb
149
+ # - Dir.new( string ) -> aDir
150
+ # - Dir.new( string, encoding: enc ) -> aDir
151
+ # -->
12
152
  # Returns a new directory object for the named directory.
13
153
  #
14
154
  # The optional *encoding* keyword argument specifies the encoding of the
@@ -16,10 +156,19 @@ class Dir
16
156
  #
17
157
  def initialize: (string, ?encoding: encoding | nil) -> void
18
158
 
19
- # Equivalent to calling `Dir.glob([string,...], 0)`.
159
+ # <!--
160
+ # rdoc-file=dir.rb
161
+ # - Dir[ string [, string ...] [, base: path] [, sort: true] ] -> array
162
+ # -->
163
+ # Equivalent to calling `Dir.glob([`*string,...*`], 0)`.
20
164
  #
21
165
  def self.[]: (*string patterns, ?base: string) ?{ (String path) -> void } -> Array[String]
22
166
 
167
+ # <!--
168
+ # rdoc-file=dir.c
169
+ # - Dir.chdir( [ string] ) -> 0
170
+ # - Dir.chdir( [ string] ) {| path | block } -> anObject
171
+ # -->
23
172
  # Changes the current working directory of the process to the given string. When
24
173
  # called without an argument, changes the directory to the value of the
25
174
  # environment variable `HOME`, or `LOGDIR`. SystemCallError (probably
@@ -30,7 +179,8 @@ class Dir
30
179
  # directory is restored when the block exits. The return value of `chdir` is the
31
180
  # value of the block. `chdir` blocks can be nested, but in a multi-threaded
32
181
  # program an error will be raised if a thread attempts to open a `chdir` block
33
- # while another thread has one open.
182
+ # while another thread has one open or a call to `chdir` without a block occurs
183
+ # inside a block passed to `chdir` (even in the same thread).
34
184
  #
35
185
  # Dir.chdir("/var/spool/mail")
36
186
  # puts Dir.pwd
@@ -54,6 +204,11 @@ class Dir
54
204
  def self.chdir: (?string) -> void
55
205
  | [U] (?string) { (String) -> U } -> U
56
206
 
207
+ # <!--
208
+ # rdoc-file=dir.c
209
+ # - Dir.children( dirname ) -> array
210
+ # - Dir.children( dirname, encoding: enc ) -> array
211
+ # -->
57
212
  # Returns an array containing all of the filenames except for "." and ".." in
58
213
  # the given directory. Will raise a SystemCallError if the named directory
59
214
  # doesn't exist.
@@ -65,17 +220,34 @@ class Dir
65
220
  #
66
221
  def self.children: (string dirname, ?encoding: string | Encoding | nil enc) -> Array[String]
67
222
 
223
+ # <!--
224
+ # rdoc-file=dir.c
225
+ # - Dir.chroot( string ) -> 0
226
+ # -->
68
227
  # Changes this process's idea of the file system root. Only a privileged process
69
228
  # may make this call. Not available on all platforms. On Unix systems, see
70
229
  # `chroot(2)` for more information.
71
230
  #
72
231
  def self.chroot: (string) -> void
73
232
 
233
+ # <!--
234
+ # rdoc-file=dir.c
235
+ # - Dir.delete( string ) -> 0
236
+ # - Dir.rmdir( string ) -> 0
237
+ # - Dir.unlink( string ) -> 0
238
+ # -->
74
239
  # Deletes the named directory. Raises a subclass of SystemCallError if the
75
240
  # directory isn't empty.
76
241
  #
77
242
  def self.delete: (string) -> void
78
243
 
244
+ # <!--
245
+ # rdoc-file=dir.c
246
+ # - Dir.each_child( dirname ) {| filename | block } -> nil
247
+ # - Dir.each_child( dirname, encoding: enc ) {| filename | block } -> nil
248
+ # - Dir.each_child( dirname ) -> an_enumerator
249
+ # - Dir.each_child( dirname, encoding: enc ) -> an_enumerator
250
+ # -->
79
251
  # Calls the block once for each entry except for "." and ".." in the named
80
252
  # directory, passing the filename of each entry as a parameter to the block.
81
253
  #
@@ -91,11 +263,20 @@ class Dir
91
263
  def self.each_child: (string dirname, ?encoding: string | Encoding | nil enc) -> Enumerator[String, void]
92
264
  | (string dirname, ?encoding: string | Encoding | nil enc) { (String filename) -> void } -> void
93
265
 
266
+ # <!--
267
+ # rdoc-file=dir.c
268
+ # - Dir.empty?(path_name) -> true or false
269
+ # -->
94
270
  # Returns `true` if the named file is an empty directory, `false` if it is not a
95
271
  # directory or non-empty.
96
272
  #
97
273
  def self.empty?: (string path_name) -> bool
98
274
 
275
+ # <!--
276
+ # rdoc-file=dir.c
277
+ # - Dir.entries( dirname ) -> array
278
+ # - Dir.entries( dirname, encoding: enc ) -> array
279
+ # -->
99
280
  # Returns an array containing all of the filenames in the given directory. Will
100
281
  # raise a SystemCallError if the named directory doesn't exist.
101
282
  #
@@ -106,14 +287,21 @@ class Dir
106
287
  #
107
288
  def self.entries: (string dirname, ?encoding: encoding | nil enc) -> ::Array[String]
108
289
 
290
+ # <!--
291
+ # rdoc-file=dir.c
292
+ # - Dir.exist?(file_name) -> true or false
293
+ # -->
109
294
  # Returns `true` if the named file is a directory, `false` otherwise.
110
295
  #
111
296
  def self.exist?: (string file) -> bool
112
297
 
113
- # Deprecated method. Don't use.
114
- #
115
- def self.exists?: (string file) -> bool
116
-
298
+ # <!--
299
+ # rdoc-file=dir.c
300
+ # - Dir.foreach( dirname ) {| filename | block } -> nil
301
+ # - Dir.foreach( dirname, encoding: enc ) {| filename | block } -> nil
302
+ # - Dir.foreach( dirname ) -> an_enumerator
303
+ # - Dir.foreach( dirname, encoding: enc ) -> an_enumerator
304
+ # -->
117
305
  # Calls the block once for each entry in the named directory, passing the
118
306
  # filename of each entry as a parameter to the block.
119
307
  #
@@ -130,6 +318,11 @@ class Dir
130
318
  #
131
319
  alias self.foreach self.each_child
132
320
 
321
+ # <!--
322
+ # rdoc-file=dir.c
323
+ # - Dir.getwd -> string
324
+ # - Dir.pwd -> string
325
+ # -->
133
326
  # Returns the path to the current working directory of this process as a string.
134
327
  #
135
328
  # Dir.chdir("/tmp") #=> 0
@@ -138,6 +331,11 @@ class Dir
138
331
  #
139
332
  def self.getwd: () -> String
140
333
 
334
+ # <!--
335
+ # rdoc-file=dir.rb
336
+ # - Dir.glob( pattern, [flags], [base: path] [, sort: true] ) -> array
337
+ # - Dir.glob( pattern, [flags], [base: path] [, sort: true] ) { |filename| block } -> nil
338
+ # -->
141
339
  # Expands `pattern`, which is a pattern string or an Array of pattern strings,
142
340
  # and returns an array containing the matching filenames. If a block is given,
143
341
  # calls the block once for each matching filename, passing the filename as a
@@ -148,14 +346,17 @@ class Dir
148
346
  # the results are not prefixed with the base directory name in this case, you
149
347
  # will need to prepend the base directory name if you want real paths.
150
348
  #
349
+ # The results which matched single wildcard or character set are sorted in
350
+ # binary ascending order, unless `false` is given as the optional `sort` keyword
351
+ # argument. The order of an Array of pattern strings and braces are preserved.
352
+ #
151
353
  # Note that the pattern is not a regexp, it's closer to a shell glob. See
152
354
  # File::fnmatch for the meaning of the `flags` parameter. Case sensitivity
153
- # depends on your system (File::FNM_CASEFOLD is ignored), as does the order in
154
- # which the results are returned.
355
+ # depends on your system (`File::FNM_CASEFOLD` is ignored).
155
356
  #
156
357
  # `*`
157
358
  # : Matches any file. Can be restricted by other values in the glob.
158
- # Equivalent to `/ .* /mx` in regexp.
359
+ # Equivalent to `/.*/mx` in regexp.
159
360
  #
160
361
  # `*`
161
362
  # : Matches all files
@@ -173,7 +374,8 @@ class Dir
173
374
  # flag or something like `"{*,.*}"`.
174
375
  #
175
376
  # `**`
176
- # : Matches directories recursively.
377
+ # : Matches directories recursively if followed by `/`. If this path segment
378
+ # contains any other characters, it is the same as the usual `*`.
177
379
  #
178
380
  # `?`
179
381
  # : Matches any one character. Equivalent to `/.{1}/` in regexp.
@@ -189,7 +391,7 @@ class Dir
189
391
  # Matching literals may be more than one character in length. More than two
190
392
  # literals may be specified.
191
393
  #
192
- # ` \\ `
394
+ # `\`
193
395
  # : Escapes the next metacharacter.
194
396
  #
195
397
  # Note that this means you cannot use backslash on windows as part of a
@@ -207,31 +409,36 @@ class Dir
207
409
  # Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
208
410
  # Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
209
411
  #
210
- # rbfiles = File.join("**", "*.rb")
211
- # Dir.glob(rbfiles) #=> ["main.rb",
412
+ # Dir.glob("**/*.rb") #=> ["main.rb",
212
413
  # # "lib/song.rb",
213
414
  # # "lib/song/karaoke.rb"]
214
415
  #
215
- # Dir.glob(rbfiles, base: "lib") #=> ["song.rb",
416
+ # Dir.glob("**/*.rb", base: "lib") #=> ["song.rb",
216
417
  # # "song/karaoke.rb"]
217
418
  #
218
- # libdirs = File.join("**", "lib")
219
- # Dir.glob(libdirs) #=> ["lib"]
419
+ # Dir.glob("**/lib") #=> ["lib"]
220
420
  #
221
- # librbfiles = File.join("**", "lib", "**", "*.rb")
222
- # Dir.glob(librbfiles) #=> ["lib/song.rb",
421
+ # Dir.glob("**/lib/**/*.rb") #=> ["lib/song.rb",
223
422
  # # "lib/song/karaoke.rb"]
224
423
  #
225
- # librbfiles = File.join("**", "lib", "*.rb")
226
- # Dir.glob(librbfiles) #=> ["lib/song.rb"]
424
+ # Dir.glob("**/lib/*.rb") #=> ["lib/song.rb"]
227
425
  #
228
426
  def self.glob: (string | ::Array[string] pattern, ?Integer flags, ?base: string) -> ::Array[String]
229
427
  | (string | ::Array[string] pattern, ?Integer flags, ?base: string) { (String) -> void } -> void
230
428
 
429
+ # <!--
430
+ # rdoc-file=dir.c
431
+ # - Dir.home() -> "/home/me"
432
+ # - Dir.home("root") -> "/root"
433
+ # -->
231
434
  # Returns the home directory of the current user or the named user if given.
232
435
  #
233
436
  def self.home: (?string user) -> String
234
437
 
438
+ # <!--
439
+ # rdoc-file=dir.c
440
+ # - Dir.mkdir( string [, integer] ) -> 0
441
+ # -->
235
442
  # Makes a new directory named by *string*, with permissions specified by the
236
443
  # optional parameter *anInteger*. The permissions may be modified by the value
237
444
  # of File::umask, and are ignored on NT. Raises a SystemCallError if the
@@ -242,6 +449,13 @@ class Dir
242
449
  #
243
450
  def self.mkdir: (string, ?Integer permissions) -> void
244
451
 
452
+ # <!--
453
+ # rdoc-file=dir.rb
454
+ # - Dir.open( string ) -> aDir
455
+ # - Dir.open( string, encoding: enc ) -> aDir
456
+ # - Dir.open( string ) {| aDir | block } -> anObject
457
+ # - Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
458
+ # -->
245
459
  # The optional *encoding* keyword argument specifies the encoding of the
246
460
  # directory. If not specified, the filesystem encoding is used.
247
461
  #
@@ -252,6 +466,11 @@ class Dir
252
466
  def self.open: (string, ?encoding: encoding | nil) -> Dir
253
467
  | [U] (string, ?encoding: encoding | nil) { (Dir) -> U } -> U
254
468
 
469
+ # <!--
470
+ # rdoc-file=dir.c
471
+ # - Dir.getwd -> string
472
+ # - Dir.pwd -> string
473
+ # -->
255
474
  # Returns the path to the current working directory of this process as a string.
256
475
  #
257
476
  # Dir.chdir("/tmp") #=> 0
@@ -260,11 +479,23 @@ class Dir
260
479
  #
261
480
  def self.pwd: () -> String
262
481
 
482
+ # <!--
483
+ # rdoc-file=dir.c
484
+ # - Dir.delete( string ) -> 0
485
+ # - Dir.rmdir( string ) -> 0
486
+ # - Dir.unlink( string ) -> 0
487
+ # -->
263
488
  # Deletes the named directory. Raises a subclass of SystemCallError if the
264
489
  # directory isn't empty.
265
490
  #
266
491
  alias self.rmdir self.delete
267
492
 
493
+ # <!--
494
+ # rdoc-file=dir.c
495
+ # - Dir.delete( string ) -> 0
496
+ # - Dir.rmdir( string ) -> 0
497
+ # - Dir.unlink( string ) -> 0
498
+ # -->
268
499
  # Deletes the named directory. Raises a subclass of SystemCallError if the
269
500
  # directory isn't empty.
270
501
  #
@@ -272,6 +503,10 @@ class Dir
272
503
 
273
504
  public
274
505
 
506
+ # <!--
507
+ # rdoc-file=dir.c
508
+ # - dir.children -> array
509
+ # -->
275
510
  # Returns an array containing all of the filenames except for "." and ".." in
276
511
  # this directory.
277
512
  #
@@ -280,6 +515,10 @@ class Dir
280
515
  #
281
516
  def children: () -> Array[String]
282
517
 
518
+ # <!--
519
+ # rdoc-file=dir.c
520
+ # - dir.close -> nil
521
+ # -->
283
522
  # Closes the directory stream. Calling this method on closed Dir object is
284
523
  # ignored since Ruby 2.3.
285
524
  #
@@ -288,6 +527,11 @@ class Dir
288
527
  #
289
528
  def close: () -> void
290
529
 
530
+ # <!--
531
+ # rdoc-file=dir.c
532
+ # - dir.each { |filename| block } -> dir
533
+ # - dir.each -> an_enumerator
534
+ # -->
291
535
  # Calls the block once for each entry in this directory, passing the filename of
292
536
  # each entry as a parameter to the block.
293
537
  #
@@ -306,6 +550,11 @@ class Dir
306
550
  def each: () { (String) -> void } -> self
307
551
  | () -> ::Enumerator[String, self]
308
552
 
553
+ # <!--
554
+ # rdoc-file=dir.c
555
+ # - dir.each_child {| filename | block } -> dir
556
+ # - dir.each_child -> an_enumerator
557
+ # -->
309
558
  # Calls the block once for each entry except for "." and ".." in this directory,
310
559
  # passing the filename of each entry as a parameter to the block.
311
560
  #
@@ -322,6 +571,10 @@ class Dir
322
571
  def each_child: () { (String) -> void } -> self
323
572
  | () -> ::Enumerator[String, self]
324
573
 
574
+ # <!--
575
+ # rdoc-file=dir.c
576
+ # - dir.fileno -> integer
577
+ # -->
325
578
  # Returns the file descriptor used in *dir*.
326
579
  #
327
580
  # d = Dir.new("..")
@@ -333,10 +586,19 @@ class Dir
333
586
  #
334
587
  def fileno: () -> Integer
335
588
 
589
+ # <!--
590
+ # rdoc-file=dir.c
591
+ # - dir.inspect -> string
592
+ # -->
336
593
  # Return a string describing this Dir object.
337
594
  #
338
595
  def inspect: () -> String
339
596
 
597
+ # <!--
598
+ # rdoc-file=dir.c
599
+ # - dir.path -> string or nil
600
+ # - dir.to_path -> string or nil
601
+ # -->
340
602
  # Returns the path parameter passed to *dir*'s constructor.
341
603
  #
342
604
  # d = Dir.new("..")
@@ -344,6 +606,7 @@ class Dir
344
606
  #
345
607
  def path: () -> String?
346
608
 
609
+ # <!-- rdoc-file=dir.c -->
347
610
  # Returns the current position in *dir*. See also Dir#seek.
348
611
  #
349
612
  # d = Dir.new("testdir")
@@ -353,6 +616,10 @@ class Dir
353
616
  #
354
617
  def pos: () -> Integer
355
618
 
619
+ # <!--
620
+ # rdoc-file=dir.c
621
+ # - dir.pos = integer -> integer
622
+ # -->
356
623
  # Synonym for Dir#seek, but returns the position parameter.
357
624
  #
358
625
  # d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
@@ -364,6 +631,10 @@ class Dir
364
631
  #
365
632
  def pos=: (Integer pos) -> Integer
366
633
 
634
+ # <!--
635
+ # rdoc-file=dir.c
636
+ # - dir.read -> string or nil
637
+ # -->
367
638
  # Reads the next entry from *dir* and returns it as a string. Returns `nil` at
368
639
  # the end of the stream.
369
640
  #
@@ -374,6 +645,10 @@ class Dir
374
645
  #
375
646
  def read: () -> String?
376
647
 
648
+ # <!--
649
+ # rdoc-file=dir.c
650
+ # - dir.rewind -> dir
651
+ # -->
377
652
  # Repositions *dir* to the first entry.
378
653
  #
379
654
  # d = Dir.new("testdir")
@@ -383,6 +658,10 @@ class Dir
383
658
  #
384
659
  def rewind: () -> self
385
660
 
661
+ # <!--
662
+ # rdoc-file=dir.c
663
+ # - dir.seek( integer ) -> dir
664
+ # -->
386
665
  # Seeks to a particular location in *dir*. *integer* must be a value returned by
387
666
  # Dir#tell.
388
667
  #
@@ -395,6 +674,11 @@ class Dir
395
674
  #
396
675
  def seek: (Integer) -> self
397
676
 
677
+ # <!--
678
+ # rdoc-file=dir.c
679
+ # - dir.pos -> integer
680
+ # - dir.tell -> integer
681
+ # -->
398
682
  # Returns the current position in *dir*. See also Dir#seek.
399
683
  #
400
684
  # d = Dir.new("testdir")
@@ -404,6 +688,7 @@ class Dir
404
688
  #
405
689
  def tell: () -> Integer
406
690
 
691
+ # <!-- rdoc-file=dir.c -->
407
692
  # Returns the path parameter passed to *dir*'s constructor.
408
693
  #
409
694
  # d = Dir.new("..")