rbs 3.3.2 → 3.4.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/comments.yml +2 -5
  3. data/.github/workflows/ruby.yml +7 -8
  4. data/.github/workflows/typecheck.yml +37 -0
  5. data/CHANGELOG.md +50 -0
  6. data/Gemfile +1 -1
  7. data/Gemfile.lock +11 -11
  8. data/Steepfile +2 -2
  9. data/core/array.rbs +19 -49
  10. data/core/basic_object.rbs +2 -2
  11. data/core/comparable.rbs +17 -8
  12. data/core/complex.rbs +82 -43
  13. data/core/data.rbs +2 -4
  14. data/core/dir.rbs +635 -295
  15. data/core/enumerable.rbs +11 -18
  16. data/core/enumerator.rbs +37 -31
  17. data/core/errors.rbs +4 -0
  18. data/core/false_class.rbs +34 -15
  19. data/core/fiber.rbs +23 -0
  20. data/core/file.rbs +329 -120
  21. data/core/float.rbs +17 -32
  22. data/core/gc.rbs +17 -11
  23. data/core/hash.rbs +22 -44
  24. data/core/integer.rbs +82 -113
  25. data/core/io/buffer.rbs +90 -47
  26. data/core/io.rbs +39 -116
  27. data/core/kernel.rbs +442 -489
  28. data/core/match_data.rbs +55 -56
  29. data/core/module.rbs +45 -1
  30. data/core/nil_class.rbs +98 -35
  31. data/core/numeric.rbs +22 -32
  32. data/core/object_space/weak_key_map.rbs +102 -0
  33. data/core/process.rbs +1242 -655
  34. data/core/ractor.rbs +139 -120
  35. data/core/range.rbs +100 -4
  36. data/core/rational.rbs +0 -4
  37. data/core/rbs/unnamed/argf.rbs +16 -8
  38. data/core/rbs/unnamed/env_class.rbs +0 -24
  39. data/core/refinement.rbs +8 -0
  40. data/core/regexp.rbs +1149 -598
  41. data/core/ruby_vm.rbs +126 -12
  42. data/core/rubygems/platform.rbs +9 -0
  43. data/core/rubygems/rubygems.rbs +1 -1
  44. data/core/rubygems/version.rbs +5 -1
  45. data/core/set.rbs +20 -22
  46. data/core/signal.rbs +4 -4
  47. data/core/string.rbs +283 -230
  48. data/core/string_io.rbs +2 -14
  49. data/core/struct.rbs +404 -24
  50. data/core/symbol.rbs +1 -19
  51. data/core/thread.rbs +29 -12
  52. data/core/time.rbs +227 -104
  53. data/core/trace_point.rbs +2 -5
  54. data/core/true_class.rbs +54 -21
  55. data/core/warning.rbs +14 -11
  56. data/docs/data_and_struct.md +29 -0
  57. data/docs/syntax.md +3 -5
  58. data/docs/tools.md +1 -0
  59. data/ext/rbs_extension/lexer.c +643 -559
  60. data/ext/rbs_extension/lexer.re +5 -1
  61. data/ext/rbs_extension/parser.c +12 -3
  62. data/ext/rbs_extension/unescape.c +7 -47
  63. data/lib/rbs/cli/diff.rb +4 -1
  64. data/lib/rbs/cli/validate.rb +280 -0
  65. data/lib/rbs/cli.rb +2 -194
  66. data/lib/rbs/collection/config.rb +5 -6
  67. data/lib/rbs/collection/sources/git.rb +1 -1
  68. data/lib/rbs/collection.rb +1 -0
  69. data/lib/rbs/diff.rb +7 -4
  70. data/lib/rbs/errors.rb +11 -0
  71. data/lib/rbs/test/errors.rb +4 -1
  72. data/lib/rbs/test/guaranteed.rb +2 -3
  73. data/lib/rbs/test/type_check.rb +15 -10
  74. data/lib/rbs/test.rb +3 -3
  75. data/lib/rbs/types.rb +29 -0
  76. data/lib/rbs/unit_test/convertibles.rb +176 -0
  77. data/lib/rbs/unit_test/spy.rb +136 -0
  78. data/lib/rbs/unit_test/type_assertions.rb +341 -0
  79. data/lib/rbs/unit_test/with_aliases.rb +143 -0
  80. data/lib/rbs/unit_test.rb +6 -0
  81. data/lib/rbs/version.rb +1 -1
  82. data/sig/cli/validate.rbs +43 -0
  83. data/sig/diff.rbs +3 -1
  84. data/sig/errors.rbs +8 -0
  85. data/sig/rbs.rbs +1 -1
  86. data/sig/test/errors.rbs +52 -0
  87. data/sig/test/guranteed.rbs +9 -0
  88. data/sig/test/type_check.rbs +19 -0
  89. data/sig/test.rbs +82 -0
  90. data/sig/types.rbs +6 -1
  91. data/sig/unit_test/convertibles.rbs +154 -0
  92. data/sig/unit_test/spy.rbs +28 -0
  93. data/sig/unit_test/type_assertions.rbs +194 -0
  94. data/sig/unit_test/with_aliases.rbs +136 -0
  95. data/stdlib/base64/0/base64.rbs +307 -45
  96. data/stdlib/bigdecimal/0/big_decimal.rbs +35 -15
  97. data/stdlib/coverage/0/coverage.rbs +2 -2
  98. data/stdlib/csv/0/csv.rbs +25 -55
  99. data/stdlib/date/0/date.rbs +1 -43
  100. data/stdlib/date/0/date_time.rbs +1 -13
  101. data/stdlib/delegate/0/delegator.rbs +186 -0
  102. data/stdlib/delegate/0/kernel.rbs +47 -0
  103. data/stdlib/delegate/0/simple_delegator.rbs +98 -0
  104. data/stdlib/did_you_mean/0/did_you_mean.rbs +1 -1
  105. data/stdlib/erb/0/erb.rbs +2 -2
  106. data/stdlib/fileutils/0/fileutils.rbs +0 -19
  107. data/stdlib/io-console/0/io-console.rbs +12 -1
  108. data/stdlib/ipaddr/0/ipaddr.rbs +2 -1
  109. data/stdlib/json/0/json.rbs +320 -81
  110. data/stdlib/logger/0/logger.rbs +9 -5
  111. data/stdlib/monitor/0/monitor.rbs +78 -0
  112. data/stdlib/net-http/0/net-http.rbs +1880 -543
  113. data/stdlib/objspace/0/objspace.rbs +19 -13
  114. data/stdlib/openssl/0/openssl.rbs +508 -127
  115. data/stdlib/optparse/0/optparse.rbs +25 -11
  116. data/stdlib/pathname/0/pathname.rbs +1 -1
  117. data/stdlib/pp/0/pp.rbs +2 -5
  118. data/stdlib/prettyprint/0/prettyprint.rbs +2 -2
  119. data/stdlib/pstore/0/pstore.rbs +2 -4
  120. data/stdlib/rdoc/0/comment.rbs +1 -2
  121. data/stdlib/resolv/0/resolv.rbs +4 -2
  122. data/stdlib/socket/0/socket.rbs +2 -2
  123. data/stdlib/socket/0/unix_socket.rbs +2 -2
  124. data/stdlib/strscan/0/string_scanner.rbs +3 -2
  125. data/stdlib/tempfile/0/tempfile.rbs +1 -1
  126. data/stdlib/uri/0/common.rbs +245 -123
  127. metadata +23 -4
  128. data/lib/rbs/test/spy.rb +0 -6
data/core/file.rbs CHANGED
@@ -4,7 +4,7 @@
4
4
  # Class File extends module FileTest, supporting such singleton methods as
5
5
  # `File.exist?`.
6
6
  #
7
- # ### About the Examples
7
+ # ## About the Examples
8
8
  #
9
9
  # Many examples here use these variables:
10
10
  #
@@ -643,7 +643,7 @@
643
643
  # of an actual file in the underlying platform.
644
644
  #
645
645
  # Note that file permissions are quite different from the *mode* of a file
646
- # stream (File object). See IO@Modes.
646
+ # stream (File object).
647
647
  #
648
648
  # In a File object, the permissions are available thus, where method `mode`,
649
649
  # despite its name, returns permissions:
@@ -697,8 +697,7 @@
697
697
  #
698
698
  # * Inherits from [class IO](rdoc-ref:IO@What-27s+Here), in particular,
699
699
  # methods for creating, reading, and writing files
700
- # * Includes [module FileTest](rdoc-ref:FileTest@What-27s+Here). which
701
- # provides dozens of additional methods.
700
+ # * Includes module FileTest, which provides dozens of additional methods.
702
701
  #
703
702
  #
704
703
  # Here, class File provides methods that are useful for:
@@ -932,8 +931,15 @@ class File < IO
932
931
 
933
932
  # <!--
934
933
  # rdoc-file=file.c
935
- # - birthtime(p1)
934
+ # - File.birthtime(file_name) -> time
936
935
  # -->
936
+ # Returns the birth time for the named file.
937
+ #
938
+ # *file_name* can be an IO object.
939
+ #
940
+ # File.birthtime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
941
+ #
942
+ # If the platform doesn't have birthtime, raises NotImplementedError.
937
943
  #
938
944
  def self.birthtime: (string | _ToPath | IO file_name) -> Time
939
945
 
@@ -1441,7 +1447,7 @@ class File < IO
1441
1447
  # -->
1442
1448
  # Returns the string representation of the path
1443
1449
  #
1444
- # File.path("/dev/null") #=> "/dev/null"
1450
+ # File.path(File::NULL) #=> "/dev/null"
1445
1451
  # File.path(Pathname.new("/tmp")) #=> "/tmp"
1446
1452
  #
1447
1453
  def self.path: (string | _ToPath path) -> String
@@ -1915,8 +1921,11 @@ class File < IO
1915
1921
 
1916
1922
  # <!--
1917
1923
  # rdoc-file=file.c
1918
- # - size()
1924
+ # - file.size -> integer
1919
1925
  # -->
1926
+ # Returns the size of *file* in bytes.
1927
+ #
1928
+ # File.new("testfile").size #=> 66
1920
1929
  #
1921
1930
  def size: () -> Integer
1922
1931
 
@@ -1972,170 +1981,375 @@ File::SEPARATOR: String
1972
1981
  File::Separator: String
1973
1982
 
1974
1983
  # <!-- rdoc-file=file.c -->
1975
- # File::Constants provides file-related constants. All possible file constants
1976
- # are listed in the documentation but they may not all be present on your
1977
- # platform.
1984
+ # Module `File::Constants` defines file-related constants.
1985
+ #
1986
+ # There are two families of constants here:
1987
+ #
1988
+ # * Those having to do with [file
1989
+ # access](rdoc-ref:File::Constants@File+Access).
1990
+ # * Those having to do with [filename
1991
+ # globbing](rdoc-ref:File::Constants@Filename+Globbing+Constants+-28File-3A-
1992
+ # 3AFNM_-2A-29).
1993
+ #
1994
+ #
1995
+ # File constants defined for the local process may be retrieved with method
1996
+ # File::Constants.constants:
1997
+ #
1998
+ # File::Constants.constants.take(5)
1999
+ # # => [:RDONLY, :WRONLY, :RDWR, :APPEND, :CREAT]
2000
+ #
2001
+ # ## File Access
2002
+ #
2003
+ # File-access constants may be used with optional argument `mode` in calls to
2004
+ # the following methods:
2005
+ #
2006
+ # * File.new.
2007
+ # * File.open.
2008
+ # * IO.for_fd.
2009
+ # * IO.new.
2010
+ # * IO.open.
2011
+ # * IO.popen.
2012
+ # * IO.reopen.
2013
+ # * IO.sysopen.
2014
+ # * StringIO.new.
2015
+ # * StringIO.open.
2016
+ # * StringIO#reopen.
2017
+ #
2018
+ #
2019
+ # ### Read/Write Access
2020
+ #
2021
+ # Read-write access for a stream may be specified by a file-access constant.
2022
+ #
2023
+ # The constant may be specified as part of a bitwise OR of other such constants.
2024
+ #
2025
+ # Any combination of the constants in this section may be specified.
2026
+ #
2027
+ # #### File::RDONLY
2028
+ #
2029
+ # Flag File::RDONLY specifies the the stream should be opened for reading only:
2030
+ #
2031
+ # filepath = '/tmp/t.tmp'
2032
+ # f = File.new(filepath, File::RDONLY)
2033
+ # f.write('Foo') # Raises IOError (not opened for writing).
2034
+ #
2035
+ # #### File::WRONLY
2036
+ #
2037
+ # Flag File::WRONLY specifies that the stream should be opened for writing only:
2038
+ #
2039
+ # f = File.new(filepath, File::WRONLY)
2040
+ # f.read # Raises IOError (not opened for reading).
2041
+ #
2042
+ # #### File::RDWR
2043
+ #
2044
+ # Flag File::RDWR specifies that the stream should be opened for both reading
2045
+ # and writing:
2046
+ #
2047
+ # f = File.new(filepath, File::RDWR)
2048
+ # f.write('Foo') # => 3
2049
+ # f.rewind # => 0
2050
+ # f.read # => "Foo"
2051
+ #
2052
+ # ### File Positioning
2053
+ #
2054
+ # #### File::APPEND
2055
+ #
2056
+ # Flag File::APPEND specifies that the stream should be opened in append mode.
2057
+ #
2058
+ # Before each write operation, the position is set to end-of-stream. The
2059
+ # modification of the position and the following write operation are performed
2060
+ # as a single atomic step.
2061
+ #
2062
+ # #### File::TRUNC
2063
+ #
2064
+ # Flag File::TRUNC specifies that the stream should be truncated at its
2065
+ # beginning. If the file exists and is successfully opened for writing, it is to
2066
+ # be truncated to position zero; its ctime and mtime are updated.
2067
+ #
2068
+ # There is no effect on a FIFO special file or a terminal device. The effect on
2069
+ # other file types is implementation-defined. The result of using File::TRUNC
2070
+ # with File::RDONLY is undefined.
2071
+ #
2072
+ # ### Creating and Preserving
2073
+ #
2074
+ # #### File::CREAT
2075
+ #
2076
+ # Flag File::CREAT specifies that the stream should be created if it does not
2077
+ # already exist.
2078
+ #
2079
+ # If the file exists:
2080
+ #
2081
+ # - Raise an exception if File::EXCL is also specified.
2082
+ # - Otherwise, do nothing.
2083
+ #
2084
+ # If the file does not exist, then it is created. Upon successful completion,
2085
+ # the atime, ctime, and mtime of the file are updated, and the ctime and mtime
2086
+ # of the parent directory are updated.
2087
+ #
2088
+ # #### File::EXCL
2089
+ #
2090
+ # Flag File::EXCL specifies that the stream should not already exist; If flags
2091
+ # File::CREAT and File::EXCL are both specified and the stream already exists,
2092
+ # an exception is raised.
2093
+ #
2094
+ # The check for the existence and creation of the file is performed as an atomic
2095
+ # operation.
2096
+ #
2097
+ # If both File::EXCL and File::CREAT are specified and the path names a symbolic
2098
+ # link, an exception is raised regardless of the contents of the symbolic link.
2099
+ #
2100
+ # If File::EXCL is specified and File::CREAT is not specified, the result is
2101
+ # undefined.
2102
+ #
2103
+ # ### POSIX File Constants
2104
+ #
2105
+ # Some file-access constants are defined only on POSIX-compliant systems; those
2106
+ # are:
2107
+ #
2108
+ # * File::SYNC.
2109
+ # * File::DSYNC.
2110
+ # * File::RSYNC.
2111
+ # * File::DIRECT.
2112
+ # * File::NOATIME.
2113
+ # * File::NOCTTY.
2114
+ # * File::NOFOLLOW.
2115
+ # * File::TMPFILE.
2116
+ #
2117
+ #
2118
+ # #### File::SYNC, File::RSYNC, and File::DSYNC
2119
+ #
2120
+ # Flag File::SYNC, File::RSYNC, or File::DSYNC specifies synchronization of I/O
2121
+ # operations with the underlying file system.
2122
+ #
2123
+ # These flags are valid only for POSIX-compliant systems.
2124
+ #
2125
+ # * File::SYNC specifies that all write operations (both data and metadata)
2126
+ # are immediately to be flushed to the underlying storage device. This means
2127
+ # that the data is written to the storage device, and the file's metadata
2128
+ # (e.g., file size, timestamps, permissions) are also synchronized. This
2129
+ # guarantees that data is safely stored on the storage medium before
2130
+ # returning control to the calling program. This flag can have a significant
2131
+ # impact on performance since it requires synchronous writes, which can be
2132
+ # slower compared to asynchronous writes.
2133
+ #
2134
+ # * File::RSYNC specifies that any read operations on the file will not return
2135
+ # until all outstanding write operations (those that have been issued but
2136
+ # not completed) are also synchronized. This is useful when you want to read
2137
+ # the most up-to-date data, which may still be in the process of being
2138
+ # written.
2139
+ #
2140
+ # * File::DSYNC specifies that all *data* write operations are immediately to
2141
+ # be flushed to the underlying storage device; this differs from File::SYNC,
2142
+ # which requires that *metadata* also be synchronized.
2143
+ #
2144
+ #
2145
+ # Note that the behavior of these flags may vary slightly depending on the
2146
+ # operating system and filesystem being used. Additionally, using these flags
2147
+ # can have an impact on performance due to the synchronous nature of the I/O
2148
+ # operations, so they should be used judiciously, especially in
2149
+ # performance-critical applications.
2150
+ #
2151
+ # #### File::NOCTTY
2152
+ #
2153
+ # Flag File::NOCTTY specifies that if the stream is a terminal device, that
2154
+ # device does not become the controlling terminal for the process.
2155
+ #
2156
+ # Defined only for POSIX-compliant systems.
2157
+ #
2158
+ # #### File::DIRECT
2159
+ #
2160
+ # Flag File::DIRECT requests that cache effects of the I/O to and from the
2161
+ # stream be minimized.
2162
+ #
2163
+ # Defined only for POSIX-compliant systems.
2164
+ #
2165
+ # #### File::NOATIME
2166
+ #
2167
+ # Flag File::NOATIME specifies that act of opening the stream should not modify
2168
+ # its access time (atime).
2169
+ #
2170
+ # Defined only for POSIX-compliant systems.
2171
+ #
2172
+ # #### File::NOFOLLOW
2173
+ #
2174
+ # Flag File::NOFOLLOW specifies that if path is a symbolic link, it should not
2175
+ # be followed.
2176
+ #
2177
+ # Defined only for POSIX-compliant systems.
2178
+ #
2179
+ # #### File::TMPFILE
2180
+ #
2181
+ # Flag File::TMPFILE specifies that the opened stream should be a new temporary
2182
+ # file.
2183
+ #
2184
+ # Defined only for POSIX-compliant systems.
2185
+ #
2186
+ # ### Other File-Access Constants
2187
+ #
2188
+ # #### File::NONBLOCK
2189
+ #
2190
+ # When possible, the file is opened in nonblocking mode. Neither the open
2191
+ # operation nor any subsequent I/O operations on the file will cause the calling
2192
+ # process to wait.
2193
+ #
2194
+ # #### File::BINARY
2195
+ #
2196
+ # Flag File::BINARY specifies that the stream is to be accessed in binary mode.
2197
+ #
2198
+ # #### File::SHARE_DELETE (Windows Only)
2199
+ #
2200
+ # Flag File::SHARE_DELETE enables other processes to open the stream with delete
2201
+ # access.
2202
+ #
2203
+ # If the stream is opened for (local) delete access without File::SHARE_DELETE,
2204
+ # and another process attempts to open it with delete access, the attempt fails
2205
+ # and the stream is not opened for that process.
2206
+ #
2207
+ # ## Locking
2208
+ #
2209
+ # Four file constants relate to stream locking; see File#flock:
2210
+ #
2211
+ # #### File::LOCK_EX
2212
+ #
2213
+ # Flag File::LOCK_EX specifies an exclusive lock; only one process a a time may
2214
+ # lock the stream.
2215
+ #
2216
+ # #### File::LOCK_NB
2217
+ #
2218
+ # Flag File::LOCK_NB specifies non-blocking locking for the stream; may be
2219
+ # combined with File::LOCK_EX or File::LOCK_SH.
2220
+ #
2221
+ # #### File::LOCK_SH
2222
+ #
2223
+ # Flag File::LOCK_SH specifies that multiple processes may lock the stream at
2224
+ # the same time.
1978
2225
  #
1979
- # If the underlying platform doesn't define a constant the corresponding Ruby
1980
- # constant is not defined.
2226
+ # #### File::LOCK_UN
1981
2227
  #
1982
- # Your platform documentations (e.g. man open(2)) may describe more detailed
1983
- # information.
2228
+ # Flag File::LOCK_UN specifies that the stream is not to be locked.
2229
+ #
2230
+ # ## Filename Globbing Constants (File::FNM_*)
2231
+ #
2232
+ # Filename-globbing constants may be used with optional argument `flags` in
2233
+ # calls to the following methods:
2234
+ #
2235
+ # * Dir.glob.
2236
+ # * File.fnmatch.
2237
+ # * Pathname#fnmatch.
2238
+ # * Pathname.glob.
2239
+ # * Pathname#glob.
2240
+ #
2241
+ #
2242
+ # The constants are:
2243
+ #
2244
+ # #### File::FNM_CASEFOLD
2245
+ #
2246
+ # Flag File::FNM_CASEFOLD makes patterns case insensitive for File.fnmatch (but
2247
+ # not Dir.glob).
2248
+ #
2249
+ # #### File::FNM_DOTMATCH
2250
+ #
2251
+ # Flag File::FNM_DOTMATCH makes the `'*'` pattern match a filename starting with
2252
+ # `'.'`.
2253
+ #
2254
+ # #### File::FNM_EXTGLOB
2255
+ #
2256
+ # Flag File::FNM_EXTGLOB enables pattern `'{*a*,*b*}'`, which matches pattern
2257
+ # '*a*' and pattern '*b*'; behaves like a [regexp union](rdoc-ref:Regexp.union)
2258
+ # (e.g., `'(?:*a*|*b*)'`):
2259
+ #
2260
+ # pattern = '{LEGAL,BSDL}'
2261
+ # Dir.glob(pattern) # => ["LEGAL", "BSDL"]
2262
+ # Pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
2263
+ # pathname.glob(pattern) # => [#<Pathname:LEGAL>, #<Pathname:BSDL>]
2264
+ #
2265
+ # #### File::FNM_NOESCAPE
2266
+ #
2267
+ # Flag File::FNM_NOESCAPE disables `'\'` escaping.
2268
+ #
2269
+ # #### File::FNM_PATHNAME
2270
+ #
2271
+ # Flag File::FNM_PATHNAME specifies that patterns `'*'` and `'?'` do not match
2272
+ # the directory separator (the value of constant File::SEPARATOR).
2273
+ #
2274
+ # #### File::FNM_SHORTNAME (Windows Only)
2275
+ #
2276
+ # Flag File::FNM_SHORTNAME Allows patterns to match short names if they exist.
2277
+ #
2278
+ # #### File::FNM_SYSCASE
2279
+ #
2280
+ # Flag File::FNM_SYSCASE specifies that case sensitivity is the same as in the
2281
+ # underlying operating system; effective for File.fnmatch, but not Dir.glob.
2282
+ #
2283
+ # ## Other Constants
2284
+ #
2285
+ # #### File::NULL
2286
+ #
2287
+ # Flag File::NULL contains the string value of the null device:
2288
+ #
2289
+ # * On a Unix-like OS, `'/dev/null'`.
2290
+ # * On Windows, `'NUL'`.
1984
2291
  #
1985
2292
  module File::Constants
1986
2293
  end
1987
2294
 
1988
- # <!-- rdoc-file=file.c -->
1989
- # append on each write
1990
- #
1991
2295
  File::Constants::APPEND: Integer
1992
2296
 
1993
- # <!-- rdoc-file=file.c -->
1994
- # disable line code conversion
1995
- #
1996
2297
  File::Constants::BINARY: Integer
1997
2298
 
1998
- # <!-- rdoc-file=file.c -->
1999
- # create file if it does not exist
2000
- #
2001
2299
  File::Constants::CREAT: Integer
2002
2300
 
2003
- # <!-- rdoc-file=file.c -->
2004
- # Try to minimize cache effects of the I/O to and from this file.
2005
- #
2006
2301
  File::Constants::DIRECT: Integer
2007
2302
 
2008
- # <!-- rdoc-file=file.c -->
2009
- # any write operation perform synchronously except some meta data
2010
- #
2011
2303
  File::Constants::DSYNC: Integer
2012
2304
 
2013
- # <!-- rdoc-file=file.c -->
2014
- # error if CREAT and the file exists
2015
- #
2016
2305
  File::Constants::EXCL: Integer
2017
2306
 
2018
- # <!-- rdoc-file=dir.c -->
2019
- # Makes File.fnmatch patterns case insensitive (but not Dir.glob patterns).
2020
- #
2021
2307
  File::Constants::FNM_CASEFOLD: Integer
2022
2308
 
2023
- # <!-- rdoc-file=dir.c -->
2024
- # The '*' wildcard matches filenames starting with "." in File.fnmatch and
2025
- # Dir.glob patterns
2026
- #
2027
2309
  File::Constants::FNM_DOTMATCH: Integer
2028
2310
 
2029
- # <!-- rdoc-file=dir.c -->
2030
- # Allows file globbing through "{a,b}" in File.fnmatch patterns.
2031
- #
2032
2311
  File::Constants::FNM_EXTGLOB: Integer
2033
2312
 
2034
- # <!-- rdoc-file=dir.c -->
2035
- # Disables escapes in File.fnmatch and Dir.glob patterns
2036
- #
2037
2313
  File::Constants::FNM_NOESCAPE: Integer
2038
2314
 
2039
- # <!-- rdoc-file=dir.c -->
2040
- # Wildcards in File.fnmatch and Dir.glob patterns do not match directory
2041
- # separators
2042
- #
2043
2315
  File::Constants::FNM_PATHNAME: Integer
2044
2316
 
2045
- # <!-- rdoc-file=dir.c -->
2046
- # Makes patterns to match short names if existing. Valid only on Microsoft
2047
- # Windows.
2048
- #
2049
2317
  File::Constants::FNM_SHORTNAME: Integer
2050
2318
 
2051
- # <!-- rdoc-file=dir.c -->
2052
- # System default case insensitiveness, equals to FNM_CASEFOLD or 0.
2053
- #
2054
2319
  File::Constants::FNM_SYSCASE: Integer
2055
2320
 
2056
- # <!-- rdoc-file=file.c -->
2057
- # exclusive lock. see File#flock
2058
- #
2059
2321
  File::Constants::LOCK_EX: Integer
2060
2322
 
2061
- # <!-- rdoc-file=file.c -->
2062
- # non-blocking lock. used with LOCK_SH or LOCK_EX. see File#flock
2063
- #
2064
2323
  File::Constants::LOCK_NB: Integer
2065
2324
 
2066
- # <!-- rdoc-file=file.c -->
2067
- # shared lock. see File#flock
2068
- #
2069
2325
  File::Constants::LOCK_SH: Integer
2070
2326
 
2071
- # <!-- rdoc-file=file.c -->
2072
- # unlock. see File#flock
2073
- #
2074
2327
  File::Constants::LOCK_UN: Integer
2075
2328
 
2076
- # <!-- rdoc-file=file.c -->
2077
- # do not change atime
2078
- #
2079
2329
  File::Constants::NOATIME: Integer
2080
2330
 
2081
- # <!-- rdoc-file=file.c -->
2082
- # not to make opened IO the controlling terminal device
2083
- #
2084
2331
  File::Constants::NOCTTY: Integer
2085
2332
 
2086
- # <!-- rdoc-file=file.c -->
2087
- # do not follow symlinks
2088
- #
2089
2333
  File::Constants::NOFOLLOW: Integer
2090
2334
 
2091
- # <!-- rdoc-file=file.c -->
2092
- # do not block on open or for data to become available
2093
- #
2094
2335
  File::Constants::NONBLOCK: Integer
2095
2336
 
2096
- # <!-- rdoc-file=file.c -->
2097
- # Name of the null device
2098
- #
2099
2337
  File::Constants::NULL: String
2100
2338
 
2101
- # <!-- rdoc-file=file.c -->
2102
- # open for reading only
2103
- #
2104
2339
  File::Constants::RDONLY: Integer
2105
2340
 
2106
- # <!-- rdoc-file=file.c -->
2107
- # open for reading and writing
2108
- #
2109
2341
  File::Constants::RDWR: Integer
2110
2342
 
2111
- # <!-- rdoc-file=file.c -->
2112
- # any read operation perform synchronously. used with SYNC or DSYNC.
2113
- #
2114
2343
  File::Constants::RSYNC: Integer
2115
2344
 
2116
- # <!-- rdoc-file=file.c -->
2117
- # can delete opened file
2118
- #
2119
2345
  File::Constants::SHARE_DELETE: Integer
2120
2346
 
2121
- # <!-- rdoc-file=file.c -->
2122
- # any write operation perform synchronously
2123
- #
2124
2347
  File::Constants::SYNC: Integer
2125
2348
 
2126
- # <!-- rdoc-file=file.c -->
2127
- # Create an unnamed temporary file
2128
- #
2129
2349
  File::Constants::TMPFILE: Integer
2130
2350
 
2131
- # <!-- rdoc-file=file.c -->
2132
- # truncate size to 0
2133
- #
2134
2351
  File::Constants::TRUNC: Integer
2135
2352
 
2136
- # <!-- rdoc-file=file.c -->
2137
- # open for writing only
2138
- #
2139
2353
  File::Constants::WRONLY: Integer
2140
2354
 
2141
2355
  # <!-- rdoc-file=file.c -->
@@ -2151,8 +2365,10 @@ class File::Stat < Object
2151
2365
 
2152
2366
  # <!--
2153
2367
  # rdoc-file=file.c
2154
- # - File::Stat.new(file_name) -> stat
2368
+ # - new(p1)
2155
2369
  # -->
2370
+ # File::Stat.new(file_name) -> stat
2371
+ #
2156
2372
  # Create a File::Stat object for the given file name (raising an exception if
2157
2373
  # the file doesn't exist).
2158
2374
  #
@@ -2298,19 +2514,12 @@ class File::Stat < Object
2298
2514
 
2299
2515
  # <!--
2300
2516
  # rdoc-file=file.c
2301
- # - File.directory?(path) -> true or false
2517
+ # - stat.directory? -> true or false
2302
2518
  # -->
2303
- # With string `object` given, returns `true` if `path` is a string path leading
2304
- # to a directory, or to a symbolic link to a directory; `false` otherwise:
2519
+ # Returns `true` if *stat* is a directory, `false` otherwise.
2305
2520
  #
2306
- # File.directory?('.') # => true
2307
- # File.directory?('foo') # => false
2308
- # File.symlink('.', 'dirlink') # => 0
2309
- # File.directory?('dirlink') # => true
2310
- # File.symlink('t,txt', 'filelink') # => 0
2311
- # File.directory?('filelink') # => false
2312
- #
2313
- # Argument `path` can be an IO object.
2521
+ # File.stat("testfile").directory? #=> false
2522
+ # File.stat(".").directory? #=> true
2314
2523
  #
2315
2524
  def directory?: () -> bool
2316
2525
 
@@ -2554,7 +2763,7 @@ class File::Stat < Object
2554
2763
  # Returns `nil` if *stat* is a zero-length file, the size of the file otherwise.
2555
2764
  #
2556
2765
  # File.stat("testfile").size? #=> 66
2557
- # File.stat("/dev/null").size? #=> nil
2766
+ # File.stat(File::NULL).size? #=> nil
2558
2767
  #
2559
2768
  def size?: () -> Integer?
2560
2769