rbs 4.0.0.dev.4 → 4.0.0.dev.5
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.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +14 -14
- data/.github/workflows/bundle-update.yml +60 -0
- data/.github/workflows/c-check.yml +11 -8
- data/.github/workflows/comments.yml +3 -3
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +17 -34
- data/.github/workflows/typecheck.yml +2 -2
- data/.github/workflows/valgrind.yml +42 -0
- data/.github/workflows/windows.yml +2 -2
- data/.rubocop.yml +1 -1
- data/README.md +1 -1
- data/Rakefile +32 -5
- data/config.yml +46 -0
- data/core/array.rbs +96 -46
- data/core/binding.rbs +0 -2
- data/core/builtin.rbs +2 -2
- data/core/comparable.rbs +13 -6
- data/core/complex.rbs +55 -41
- data/core/dir.rbs +4 -4
- data/core/encoding.rbs +7 -10
- data/core/enumerable.rbs +90 -3
- data/core/enumerator/arithmetic_sequence.rbs +70 -0
- data/core/enumerator.rbs +63 -1
- data/core/errno.rbs +8 -0
- data/core/errors.rbs +28 -1
- data/core/exception.rbs +2 -2
- data/core/fiber.rbs +40 -20
- data/core/file.rbs +108 -78
- data/core/file_test.rbs +1 -1
- data/core/float.rbs +225 -69
- data/core/gc.rbs +417 -281
- data/core/hash.rbs +1023 -727
- data/core/integer.rbs +104 -110
- data/core/io/buffer.rbs +21 -10
- data/core/io/wait.rbs +11 -33
- data/core/io.rbs +82 -19
- data/core/kernel.rbs +70 -59
- data/core/marshal.rbs +1 -1
- data/core/match_data.rbs +1 -1
- data/core/math.rbs +42 -3
- data/core/method.rbs +63 -27
- data/core/module.rbs +103 -26
- data/core/nil_class.rbs +3 -3
- data/core/numeric.rbs +43 -35
- data/core/object.rbs +3 -3
- data/core/object_space.rbs +21 -15
- data/core/pathname.rbs +1272 -0
- data/core/proc.rbs +30 -25
- data/core/process.rbs +4 -2
- data/core/ractor.rbs +361 -509
- data/core/random.rbs +17 -0
- data/core/range.rbs +113 -16
- data/core/rational.rbs +56 -85
- data/core/rbs/unnamed/argf.rbs +2 -2
- data/core/rbs/unnamed/env_class.rbs +1 -1
- data/core/rbs/unnamed/random.rbs +4 -113
- data/core/regexp.rbs +25 -20
- data/core/ruby.rbs +53 -0
- data/core/ruby_vm.rbs +6 -4
- data/core/rubygems/errors.rbs +3 -70
- data/core/rubygems/rubygems.rbs +11 -79
- data/core/rubygems/version.rbs +2 -3
- data/core/set.rbs +488 -359
- data/core/signal.rbs +24 -14
- data/core/string.rbs +3171 -1241
- data/core/struct.rbs +1 -1
- data/core/symbol.rbs +17 -11
- data/core/thread.rbs +95 -33
- data/core/time.rbs +35 -9
- data/core/trace_point.rbs +7 -4
- data/core/unbound_method.rbs +14 -6
- data/docs/aliases.md +79 -0
- data/docs/collection.md +2 -2
- data/docs/encoding.md +56 -0
- data/docs/gem.md +0 -1
- data/docs/inline.md +470 -0
- data/docs/sigs.md +3 -3
- data/docs/syntax.md +33 -4
- data/docs/type_fingerprint.md +21 -0
- data/exe/rbs +1 -1
- data/ext/rbs_extension/ast_translation.c +77 -3
- data/ext/rbs_extension/ast_translation.h +3 -0
- data/ext/rbs_extension/class_constants.c +8 -2
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/extconf.rb +5 -1
- data/ext/rbs_extension/legacy_location.c +5 -5
- data/ext/rbs_extension/main.c +37 -20
- data/include/rbs/ast.h +85 -38
- data/include/rbs/defines.h +27 -0
- data/include/rbs/lexer.h +30 -11
- data/include/rbs/parser.h +6 -6
- data/include/rbs/string.h +0 -2
- data/include/rbs/util/rbs_allocator.h +34 -13
- data/include/rbs/util/rbs_assert.h +12 -1
- data/include/rbs/util/rbs_encoding.h +2 -0
- data/include/rbs/util/rbs_unescape.h +2 -1
- data/lib/rbs/ast/annotation.rb +1 -1
- data/lib/rbs/ast/comment.rb +1 -1
- data/lib/rbs/ast/declarations.rb +10 -10
- data/lib/rbs/ast/members.rb +14 -14
- data/lib/rbs/ast/ruby/annotations.rb +137 -0
- data/lib/rbs/ast/ruby/comment_block.rb +24 -0
- data/lib/rbs/ast/ruby/declarations.rb +198 -3
- data/lib/rbs/ast/ruby/helpers/constant_helper.rb +4 -0
- data/lib/rbs/ast/ruby/members.rb +159 -1
- data/lib/rbs/ast/type_param.rb +24 -4
- data/lib/rbs/buffer.rb +20 -15
- data/lib/rbs/cli/diff.rb +16 -15
- data/lib/rbs/cli/validate.rb +38 -51
- data/lib/rbs/cli.rb +52 -19
- data/lib/rbs/collection/config/lockfile_generator.rb +8 -0
- data/lib/rbs/collection/sources/git.rb +1 -0
- data/lib/rbs/definition.rb +1 -1
- data/lib/rbs/definition_builder/ancestor_builder.rb +62 -9
- data/lib/rbs/definition_builder/method_builder.rb +20 -0
- data/lib/rbs/definition_builder.rb +91 -2
- data/lib/rbs/diff.rb +7 -1
- data/lib/rbs/environment.rb +227 -74
- data/lib/rbs/environment_loader.rb +0 -6
- data/lib/rbs/errors.rb +27 -7
- data/lib/rbs/inline_parser.rb +341 -5
- data/lib/rbs/location_aux.rb +1 -1
- data/lib/rbs/locator.rb +5 -1
- data/lib/rbs/method_type.rb +5 -3
- data/lib/rbs/parser_aux.rb +2 -2
- data/lib/rbs/prototype/rb.rb +2 -2
- data/lib/rbs/prototype/rbi.rb +2 -0
- data/lib/rbs/prototype/runtime.rb +8 -0
- data/lib/rbs/resolver/constant_resolver.rb +2 -2
- data/lib/rbs/resolver/type_name_resolver.rb +116 -38
- data/lib/rbs/subtractor.rb +3 -1
- data/lib/rbs/test/type_check.rb +16 -2
- data/lib/rbs/type_name.rb +1 -1
- data/lib/rbs/types.rb +27 -27
- data/lib/rbs/validator.rb +2 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +1 -1
- data/lib/rdoc/discover.rb +1 -1
- data/lib/rdoc_plugin/parser.rb +1 -1
- data/rbs.gemspec +3 -2
- data/schema/typeParam.json +17 -1
- data/sig/ast/ruby/annotations.rbs +124 -0
- data/sig/ast/ruby/comment_block.rbs +8 -0
- data/sig/ast/ruby/declarations.rbs +102 -4
- data/sig/ast/ruby/members.rbs +87 -1
- data/sig/cli/diff.rbs +5 -11
- data/sig/cli/validate.rbs +13 -4
- data/sig/cli.rbs +18 -18
- data/sig/definition.rbs +6 -1
- data/sig/environment.rbs +70 -12
- data/sig/errors.rbs +13 -6
- data/sig/inline_parser.rbs +39 -2
- data/sig/locator.rbs +0 -2
- data/sig/manifest.yaml +0 -1
- data/sig/method_builder.rbs +3 -1
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +16 -2
- data/sig/resolver/type_name_resolver.rbs +35 -7
- data/sig/source.rbs +3 -3
- data/sig/type_param.rbs +13 -8
- data/sig/types.rbs +4 -4
- data/src/ast.c +80 -1
- data/src/lexer.c +1392 -1313
- data/src/lexer.re +3 -0
- data/src/lexstate.c +58 -37
- data/src/location.c +4 -4
- data/src/parser.c +412 -145
- data/src/string.c +0 -48
- data/src/util/rbs_allocator.c +89 -71
- data/src/util/rbs_assert.c +1 -1
- data/src/util/rbs_buffer.c +2 -2
- data/src/util/rbs_constant_pool.c +10 -10
- data/src/util/rbs_encoding.c +4 -8
- data/src/util/rbs_unescape.c +56 -20
- data/stdlib/bigdecimal/0/big_decimal.rbs +100 -82
- data/stdlib/bigdecimal-math/0/big_math.rbs +169 -8
- data/stdlib/cgi/0/core.rbs +9 -393
- data/stdlib/cgi/0/manifest.yaml +1 -0
- data/stdlib/cgi-escape/0/escape.rbs +171 -0
- data/stdlib/coverage/0/coverage.rbs +3 -1
- data/stdlib/date/0/date.rbs +67 -59
- data/stdlib/date/0/date_time.rbs +1 -1
- data/stdlib/delegate/0/delegator.rbs +10 -7
- data/stdlib/digest/0/digest.rbs +110 -0
- data/stdlib/erb/0/erb.rbs +737 -347
- data/stdlib/fileutils/0/fileutils.rbs +20 -14
- data/stdlib/forwardable/0/forwardable.rbs +3 -0
- data/stdlib/json/0/json.rbs +82 -28
- data/stdlib/net-http/0/net-http.rbs +3 -0
- data/stdlib/objspace/0/objspace.rbs +9 -27
- data/stdlib/open-uri/0/open-uri.rbs +40 -0
- data/stdlib/open3/0/open3.rbs +459 -1
- data/stdlib/openssl/0/openssl.rbs +331 -228
- data/stdlib/optparse/0/optparse.rbs +8 -3
- data/stdlib/pathname/0/pathname.rbs +9 -1379
- data/stdlib/psych/0/psych.rbs +4 -4
- data/stdlib/random-formatter/0/random-formatter.rbs +277 -0
- data/stdlib/rdoc/0/code_object.rbs +2 -1
- data/stdlib/rdoc/0/parser.rbs +1 -1
- data/stdlib/rdoc/0/rdoc.rbs +1 -1
- data/stdlib/rdoc/0/store.rbs +1 -1
- data/stdlib/resolv/0/resolv.rbs +25 -68
- data/stdlib/ripper/0/ripper.rbs +2 -2
- data/stdlib/securerandom/0/manifest.yaml +2 -0
- data/stdlib/securerandom/0/securerandom.rbs +6 -19
- data/stdlib/singleton/0/singleton.rbs +3 -0
- data/stdlib/socket/0/socket.rbs +13 -1
- data/stdlib/socket/0/tcp_socket.rbs +10 -2
- data/stdlib/stringio/0/stringio.rbs +1176 -85
- data/stdlib/strscan/0/string_scanner.rbs +31 -31
- data/stdlib/tempfile/0/tempfile.rbs +3 -3
- data/stdlib/time/0/time.rbs +1 -1
- data/stdlib/timeout/0/timeout.rbs +63 -7
- data/stdlib/tsort/0/cyclic.rbs +3 -0
- data/stdlib/uri/0/common.rbs +16 -2
- data/stdlib/uri/0/file.rbs +1 -1
- data/stdlib/uri/0/generic.rbs +24 -16
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -7
- data/stdlib/zlib/0/gzip_reader.rbs +2 -2
- data/stdlib/zlib/0/gzip_writer.rbs +1 -1
- data/stdlib/zlib/0/zstream.rbs +1 -0
- metadata +30 -4
data/core/file.rbs
CHANGED
|
@@ -847,7 +847,7 @@ class File < IO
|
|
|
847
847
|
# * [Open Options](rdoc-ref:IO@Open+Options).
|
|
848
848
|
# * [Encoding options](rdoc-ref:encodings.rdoc@Encoding+Options).
|
|
849
849
|
#
|
|
850
|
-
def initialize: (
|
|
850
|
+
def initialize: (path | int file_name, ?string | int mode, ?int perm) -> void
|
|
851
851
|
|
|
852
852
|
# <!--
|
|
853
853
|
# rdoc-file=file.c
|
|
@@ -861,7 +861,7 @@ class File < IO
|
|
|
861
861
|
#
|
|
862
862
|
# File.absolute_path("~oracle/bin") #=> "<relative_path>/~oracle/bin"
|
|
863
863
|
#
|
|
864
|
-
def self.absolute_path: (
|
|
864
|
+
def self.absolute_path: (path file_name, ?path dir_string) -> String
|
|
865
865
|
|
|
866
866
|
# <!--
|
|
867
867
|
# rdoc-file=file.c
|
|
@@ -871,7 +871,7 @@ class File < IO
|
|
|
871
871
|
#
|
|
872
872
|
# File.absolute_path?("c:/foo") #=> false (on Linux), true (on Windows)
|
|
873
873
|
#
|
|
874
|
-
def self.absolute_path?: (
|
|
874
|
+
def self.absolute_path?: (path file_name) -> bool
|
|
875
875
|
|
|
876
876
|
# <!--
|
|
877
877
|
# rdoc-file=file.c
|
|
@@ -883,7 +883,7 @@ class File < IO
|
|
|
883
883
|
#
|
|
884
884
|
# File.atime("testfile") #=> Wed Apr 09 08:51:48 CDT 2003
|
|
885
885
|
#
|
|
886
|
-
def self.atime: (
|
|
886
|
+
def self.atime: (path | IO file_name) -> Time
|
|
887
887
|
|
|
888
888
|
# <!--
|
|
889
889
|
# rdoc-file=file.c
|
|
@@ -899,7 +899,7 @@ class File < IO
|
|
|
899
899
|
# File.basename("/home/gumby/work/ruby.rb", ".rb") #=> "ruby"
|
|
900
900
|
# File.basename("/home/gumby/work/ruby.rb", ".*") #=> "ruby"
|
|
901
901
|
#
|
|
902
|
-
def self.basename: (
|
|
902
|
+
def self.basename: (path file_name, ?string suffix) -> String
|
|
903
903
|
|
|
904
904
|
# <!--
|
|
905
905
|
# rdoc-file=file.c
|
|
@@ -913,7 +913,7 @@ class File < IO
|
|
|
913
913
|
#
|
|
914
914
|
# If the platform doesn't have birthtime, raises NotImplementedError.
|
|
915
915
|
#
|
|
916
|
-
def self.birthtime: (
|
|
916
|
+
def self.birthtime: (path | IO file_name) -> Time
|
|
917
917
|
|
|
918
918
|
# <!--
|
|
919
919
|
# rdoc-file=file.c
|
|
@@ -924,7 +924,7 @@ class File < IO
|
|
|
924
924
|
# File.blockdev?('/dev/sda1') # => true
|
|
925
925
|
# File.blockdev?(File.new('t.tmp')) # => false
|
|
926
926
|
#
|
|
927
|
-
def self.blockdev?: (
|
|
927
|
+
def self.blockdev?: (path | IO file_name) -> bool
|
|
928
928
|
|
|
929
929
|
# <!--
|
|
930
930
|
# rdoc-file=file.c
|
|
@@ -935,7 +935,7 @@ class File < IO
|
|
|
935
935
|
# File.chardev?($stdin) # => true
|
|
936
936
|
# File.chardev?('t.txt') # => false
|
|
937
937
|
#
|
|
938
|
-
def self.chardev?: (
|
|
938
|
+
def self.chardev?: (path | IO file_name) -> bool
|
|
939
939
|
|
|
940
940
|
# <!--
|
|
941
941
|
# rdoc-file=file.c
|
|
@@ -948,7 +948,7 @@ class File < IO
|
|
|
948
948
|
#
|
|
949
949
|
# File.chmod(0644, "testfile", "out") #=> 2
|
|
950
950
|
#
|
|
951
|
-
def self.chmod: (int mode, *
|
|
951
|
+
def self.chmod: (int mode, *path file_name) -> Integer
|
|
952
952
|
|
|
953
953
|
# <!--
|
|
954
954
|
# rdoc-file=file.c
|
|
@@ -962,7 +962,7 @@ class File < IO
|
|
|
962
962
|
#
|
|
963
963
|
# File.chown(nil, 100, "testfile")
|
|
964
964
|
#
|
|
965
|
-
def self.chown: (int? owner, int? group, *
|
|
965
|
+
def self.chown: (int? owner, int? group, *path file_name) -> Integer
|
|
966
966
|
|
|
967
967
|
# <!--
|
|
968
968
|
# rdoc-file=file.c
|
|
@@ -977,7 +977,7 @@ class File < IO
|
|
|
977
977
|
#
|
|
978
978
|
# File.ctime("testfile") #=> Wed Apr 09 08:53:13 CDT 2003
|
|
979
979
|
#
|
|
980
|
-
def self.ctime: (
|
|
980
|
+
def self.ctime: (path | IO file_name) -> Time
|
|
981
981
|
|
|
982
982
|
# <!--
|
|
983
983
|
# rdoc-file=file.c
|
|
@@ -1010,7 +1010,7 @@ class File < IO
|
|
|
1010
1010
|
#
|
|
1011
1011
|
# Argument `path` can be an IO object.
|
|
1012
1012
|
#
|
|
1013
|
-
def self.directory?: (
|
|
1013
|
+
def self.directory?: (path | IO path) -> bool
|
|
1014
1014
|
|
|
1015
1015
|
# <!--
|
|
1016
1016
|
# rdoc-file=file.c
|
|
@@ -1028,7 +1028,7 @@ class File < IO
|
|
|
1028
1028
|
# File.dirname("/home/gumby/work/ruby.rb", 2) #=> "/home/gumby"
|
|
1029
1029
|
# File.dirname("/home/gumby/work/ruby.rb", 4) #=> "/"
|
|
1030
1030
|
#
|
|
1031
|
-
def self.dirname: (
|
|
1031
|
+
def self.dirname: (path file_name, ?Integer level) -> String
|
|
1032
1032
|
|
|
1033
1033
|
# <!--
|
|
1034
1034
|
# rdoc-file=file.c
|
|
@@ -1054,7 +1054,7 @@ class File < IO
|
|
|
1054
1054
|
# Note that some OS-level security features may cause this to return true even
|
|
1055
1055
|
# though the file is not executable by the effective user/group.
|
|
1056
1056
|
#
|
|
1057
|
-
def self.executable?: (
|
|
1057
|
+
def self.executable?: (path file_name) -> bool
|
|
1058
1058
|
|
|
1059
1059
|
# <!--
|
|
1060
1060
|
# rdoc-file=file.c
|
|
@@ -1070,7 +1070,7 @@ class File < IO
|
|
|
1070
1070
|
# Note that some OS-level security features may cause this to return true even
|
|
1071
1071
|
# though the file is not executable by the real user/group.
|
|
1072
1072
|
#
|
|
1073
|
-
def self.executable_real?: (
|
|
1073
|
+
def self.executable_real?: (path file_name) -> bool
|
|
1074
1074
|
|
|
1075
1075
|
# <!--
|
|
1076
1076
|
# rdoc-file=file.c
|
|
@@ -1082,7 +1082,7 @@ class File < IO
|
|
|
1082
1082
|
#
|
|
1083
1083
|
# "file exists" means that stat() or fstat() system call is successful.
|
|
1084
1084
|
#
|
|
1085
|
-
def self.exist?: (
|
|
1085
|
+
def self.exist?: (path | IO file_name) -> bool
|
|
1086
1086
|
|
|
1087
1087
|
# <!--
|
|
1088
1088
|
# rdoc-file=file.c
|
|
@@ -1109,7 +1109,7 @@ class File < IO
|
|
|
1109
1109
|
# So first it resolves the parent of __FILE__, that is bin/, then go to the
|
|
1110
1110
|
# parent, the root of the project and appends `lib/mygem.rb`.
|
|
1111
1111
|
#
|
|
1112
|
-
def self.expand_path: (
|
|
1112
|
+
def self.expand_path: (path file_name, ?path dir_string) -> String
|
|
1113
1113
|
|
|
1114
1114
|
# <!--
|
|
1115
1115
|
# rdoc-file=file.c
|
|
@@ -1135,7 +1135,7 @@ class File < IO
|
|
|
1135
1135
|
# File.extname(".profile") #=> ""
|
|
1136
1136
|
# File.extname(".profile.sh") #=> ".sh"
|
|
1137
1137
|
#
|
|
1138
|
-
def self.extname: (
|
|
1138
|
+
def self.extname: (path path) -> String
|
|
1139
1139
|
|
|
1140
1140
|
# <!--
|
|
1141
1141
|
# rdoc-file=file.c
|
|
@@ -1148,7 +1148,7 @@ class File < IO
|
|
|
1148
1148
|
# If the `file` argument is a symbolic link, it will resolve the symbolic link
|
|
1149
1149
|
# and use the file referenced by the link.
|
|
1150
1150
|
#
|
|
1151
|
-
def self.file?: (
|
|
1151
|
+
def self.file?: (path | IO file) -> bool
|
|
1152
1152
|
|
|
1153
1153
|
# <!--
|
|
1154
1154
|
# rdoc-file=dir.rb
|
|
@@ -1252,7 +1252,7 @@ class File < IO
|
|
|
1252
1252
|
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME) #=> false
|
|
1253
1253
|
# File.fnmatch('**/foo', 'a/.b/c/foo', File::FNM_PATHNAME | File::FNM_DOTMATCH) #=> true
|
|
1254
1254
|
#
|
|
1255
|
-
def self.fnmatch: (string pattern,
|
|
1255
|
+
def self.fnmatch: (string pattern, path path, ?int flags) -> bool
|
|
1256
1256
|
|
|
1257
1257
|
# <!--
|
|
1258
1258
|
# rdoc-file=dir.rb
|
|
@@ -1273,7 +1273,7 @@ class File < IO
|
|
|
1273
1273
|
# File.ftype("/dev/tty") #=> "characterSpecial"
|
|
1274
1274
|
# File.ftype("/tmp/.X11-unix/X0") #=> "socket"
|
|
1275
1275
|
#
|
|
1276
|
-
def self.ftype: (
|
|
1276
|
+
def self.ftype: (path file_name) -> String
|
|
1277
1277
|
|
|
1278
1278
|
# <!--
|
|
1279
1279
|
# rdoc-file=file.c
|
|
@@ -1284,7 +1284,7 @@ class File < IO
|
|
|
1284
1284
|
#
|
|
1285
1285
|
# *file_name* can be an IO object.
|
|
1286
1286
|
#
|
|
1287
|
-
def self.grpowned?: (
|
|
1287
|
+
def self.grpowned?: (path | IO file_name) -> bool
|
|
1288
1288
|
|
|
1289
1289
|
# <!--
|
|
1290
1290
|
# rdoc-file=file.c
|
|
@@ -1304,7 +1304,7 @@ class File < IO
|
|
|
1304
1304
|
# open("d", "w") {}
|
|
1305
1305
|
# p File.identical?("a", "d") #=> false
|
|
1306
1306
|
#
|
|
1307
|
-
def self.identical?: (
|
|
1307
|
+
def self.identical?: (path | IO file_1, path | IO file_2) -> bool
|
|
1308
1308
|
|
|
1309
1309
|
# <!--
|
|
1310
1310
|
# rdoc-file=file.c
|
|
@@ -1324,7 +1324,7 @@ class File < IO
|
|
|
1324
1324
|
# change the permissions associated with the link, not the file referenced by
|
|
1325
1325
|
# the link). Often not available.
|
|
1326
1326
|
#
|
|
1327
|
-
def self.lchmod: (int mode, *
|
|
1327
|
+
def self.lchmod: (int mode, *path file_name) -> Integer
|
|
1328
1328
|
|
|
1329
1329
|
# <!--
|
|
1330
1330
|
# rdoc-file=file.c
|
|
@@ -1334,7 +1334,7 @@ class File < IO
|
|
|
1334
1334
|
# change the owner associated with the link, not the file referenced by the
|
|
1335
1335
|
# link). Often not available. Returns number of files in the argument list.
|
|
1336
1336
|
#
|
|
1337
|
-
def self.lchown: (int? owner, int? group, *
|
|
1337
|
+
def self.lchown: (int? owner, int? group, *path file_name) -> Integer
|
|
1338
1338
|
|
|
1339
1339
|
# <!--
|
|
1340
1340
|
# rdoc-file=file.c
|
|
@@ -1347,7 +1347,7 @@ class File < IO
|
|
|
1347
1347
|
# File.link("testfile", ".testfile") #=> 0
|
|
1348
1348
|
# IO.readlines(".testfile")[0] #=> "This is line one\n"
|
|
1349
1349
|
#
|
|
1350
|
-
def self.link: (
|
|
1350
|
+
def self.link: (path old_name, path new_name) -> 0
|
|
1351
1351
|
|
|
1352
1352
|
# <!--
|
|
1353
1353
|
# rdoc-file=file.c
|
|
@@ -1360,7 +1360,7 @@ class File < IO
|
|
|
1360
1360
|
# File.stat('symlink').size # => 47
|
|
1361
1361
|
# File.lstat('symlink').size # => 5
|
|
1362
1362
|
#
|
|
1363
|
-
def self.lstat: (
|
|
1363
|
+
def self.lstat: (path file_name) -> File::Stat
|
|
1364
1364
|
|
|
1365
1365
|
# <!--
|
|
1366
1366
|
# rdoc-file=file.c
|
|
@@ -1371,7 +1371,7 @@ class File < IO
|
|
|
1371
1371
|
# opposed to its referent; for the inverse behavior, see File.utime. Returns the
|
|
1372
1372
|
# number of file names in the argument list.
|
|
1373
1373
|
#
|
|
1374
|
-
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *
|
|
1374
|
+
def self.lutime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
|
|
1375
1375
|
|
|
1376
1376
|
# <!--
|
|
1377
1377
|
# rdoc-file=file.c
|
|
@@ -1381,7 +1381,7 @@ class File < IO
|
|
|
1381
1381
|
# FIFO's permissions. It is modified by the process's umask in the usual way:
|
|
1382
1382
|
# the permissions of the created file are (mode & ~umask).
|
|
1383
1383
|
#
|
|
1384
|
-
def self.mkfifo: (
|
|
1384
|
+
def self.mkfifo: (path file_name, ?int mode) -> 0
|
|
1385
1385
|
|
|
1386
1386
|
# <!--
|
|
1387
1387
|
# rdoc-file=file.c
|
|
@@ -1393,7 +1393,7 @@ class File < IO
|
|
|
1393
1393
|
#
|
|
1394
1394
|
# File.mtime("testfile") #=> Tue Apr 08 12:58:04 CDT 2003
|
|
1395
1395
|
#
|
|
1396
|
-
def self.mtime: (
|
|
1396
|
+
def self.mtime: (path | IO file_name) -> Time
|
|
1397
1397
|
|
|
1398
1398
|
# <!--
|
|
1399
1399
|
# rdoc-file=io.c
|
|
@@ -1407,19 +1407,19 @@ class File < IO
|
|
|
1407
1407
|
# With a block given, calls the block with the File object and returns the
|
|
1408
1408
|
# block's value.
|
|
1409
1409
|
#
|
|
1410
|
-
def self.open: (
|
|
1411
|
-
| [T] (
|
|
1410
|
+
def self.open: (path | int file_name, ?string | int mode, ?int perm) -> instance
|
|
1411
|
+
| [T] (path | int file_name, ?string | int mode, ?int perm) { (File) -> T } -> T
|
|
1412
1412
|
|
|
1413
1413
|
# <!--
|
|
1414
1414
|
# rdoc-file=file.c
|
|
1415
1415
|
# - File.owned?(file_name) -> true or false
|
|
1416
1416
|
# -->
|
|
1417
|
-
# Returns `true` if the named file exists and the effective
|
|
1417
|
+
# Returns `true` if the named file exists and the effective user id of the
|
|
1418
1418
|
# calling process is the owner of the file.
|
|
1419
1419
|
#
|
|
1420
1420
|
# *file_name* can be an IO object.
|
|
1421
1421
|
#
|
|
1422
|
-
def self.owned?: (
|
|
1422
|
+
def self.owned?: (path | IO file_name) -> bool
|
|
1423
1423
|
|
|
1424
1424
|
# <!--
|
|
1425
1425
|
# rdoc-file=file.c
|
|
@@ -1427,10 +1427,27 @@ class File < IO
|
|
|
1427
1427
|
# -->
|
|
1428
1428
|
# Returns the string representation of the path
|
|
1429
1429
|
#
|
|
1430
|
-
#
|
|
1431
|
-
#
|
|
1430
|
+
# File.path(File::NULL) #=> "/dev/null"
|
|
1431
|
+
# File.path(Pathname.new("/tmp")) #=> "/tmp"
|
|
1432
1432
|
#
|
|
1433
|
-
|
|
1433
|
+
# If `path` is not a String:
|
|
1434
|
+
#
|
|
1435
|
+
# 1. If it has the `to_path` method, that method will be called to coerce to a
|
|
1436
|
+
# String.
|
|
1437
|
+
#
|
|
1438
|
+
# 2. Otherwise, or if the coerced result is not a String too, the standard
|
|
1439
|
+
# coersion using `to_str` method will take place on that object. (See also
|
|
1440
|
+
# String.try_convert)
|
|
1441
|
+
#
|
|
1442
|
+
# The coerced string must satisfy the following conditions:
|
|
1443
|
+
#
|
|
1444
|
+
# 1. It must be in an ASCII-compatible encoding; otherwise, an
|
|
1445
|
+
# Encoding::CompatibilityError is raised.
|
|
1446
|
+
#
|
|
1447
|
+
# 2. It must not contain the NUL character (`\0`); otherwise, an ArgumentError
|
|
1448
|
+
# is raised.
|
|
1449
|
+
#
|
|
1450
|
+
def self.path: (path path) -> String
|
|
1434
1451
|
|
|
1435
1452
|
# <!--
|
|
1436
1453
|
# rdoc-file=file.c
|
|
@@ -1442,7 +1459,7 @@ class File < IO
|
|
|
1442
1459
|
# File.pipe?('tmp/fifo') # => true
|
|
1443
1460
|
# File.pipe?('t.txt') # => false
|
|
1444
1461
|
#
|
|
1445
|
-
def self.pipe?: (
|
|
1462
|
+
def self.pipe?: (path | IO file_name) -> bool
|
|
1446
1463
|
|
|
1447
1464
|
# <!--
|
|
1448
1465
|
# rdoc-file=file.c
|
|
@@ -1454,7 +1471,7 @@ class File < IO
|
|
|
1454
1471
|
# Note that some OS-level security features may cause this to return true even
|
|
1455
1472
|
# though the file is not readable by the effective user/group.
|
|
1456
1473
|
#
|
|
1457
|
-
def self.readable?: (
|
|
1474
|
+
def self.readable?: (path file_name) -> bool
|
|
1458
1475
|
|
|
1459
1476
|
# <!--
|
|
1460
1477
|
# rdoc-file=file.c
|
|
@@ -1466,7 +1483,7 @@ class File < IO
|
|
|
1466
1483
|
# Note that some OS-level security features may cause this to return true even
|
|
1467
1484
|
# though the file is not readable by the real user/group.
|
|
1468
1485
|
#
|
|
1469
|
-
def self.readable_real?: (
|
|
1486
|
+
def self.readable_real?: (path file_name) -> bool
|
|
1470
1487
|
|
|
1471
1488
|
# <!--
|
|
1472
1489
|
# rdoc-file=file.c
|
|
@@ -1478,7 +1495,7 @@ class File < IO
|
|
|
1478
1495
|
# File.symlink("testfile", "link2test") #=> 0
|
|
1479
1496
|
# File.readlink("link2test") #=> "testfile"
|
|
1480
1497
|
#
|
|
1481
|
-
def self.readlink: (
|
|
1498
|
+
def self.readlink: (path link_name) -> String
|
|
1482
1499
|
|
|
1483
1500
|
# <!--
|
|
1484
1501
|
# rdoc-file=file.c
|
|
@@ -1492,7 +1509,7 @@ class File < IO
|
|
|
1492
1509
|
#
|
|
1493
1510
|
# The last component of the real pathname can be nonexistent.
|
|
1494
1511
|
#
|
|
1495
|
-
def self.realdirpath: (
|
|
1512
|
+
def self.realdirpath: (path pathname, ?path dir_string) -> String
|
|
1496
1513
|
|
|
1497
1514
|
# <!--
|
|
1498
1515
|
# rdoc-file=file.c
|
|
@@ -1506,7 +1523,7 @@ class File < IO
|
|
|
1506
1523
|
#
|
|
1507
1524
|
# All components of the pathname must exist when this method is called.
|
|
1508
1525
|
#
|
|
1509
|
-
def self.realpath: (
|
|
1526
|
+
def self.realpath: (path pathname, ?path dir_string) -> String
|
|
1510
1527
|
|
|
1511
1528
|
# <!--
|
|
1512
1529
|
# rdoc-file=file.c
|
|
@@ -1517,7 +1534,7 @@ class File < IO
|
|
|
1517
1534
|
#
|
|
1518
1535
|
# File.rename("afile", "afile.bak") #=> 0
|
|
1519
1536
|
#
|
|
1520
|
-
def self.rename: (
|
|
1537
|
+
def self.rename: (path old_name, path new_name) -> 0
|
|
1521
1538
|
|
|
1522
1539
|
# <!--
|
|
1523
1540
|
# rdoc-file=file.c
|
|
@@ -1527,7 +1544,7 @@ class File < IO
|
|
|
1527
1544
|
#
|
|
1528
1545
|
# *file_name* can be an IO object.
|
|
1529
1546
|
#
|
|
1530
|
-
def self.setgid?: (
|
|
1547
|
+
def self.setgid?: (path | IO file_name) -> bool
|
|
1531
1548
|
|
|
1532
1549
|
# <!--
|
|
1533
1550
|
# rdoc-file=file.c
|
|
@@ -1537,7 +1554,7 @@ class File < IO
|
|
|
1537
1554
|
#
|
|
1538
1555
|
# *file_name* can be an IO object.
|
|
1539
1556
|
#
|
|
1540
|
-
def self.setuid?: (
|
|
1557
|
+
def self.setuid?: (path | IO file_name) -> bool
|
|
1541
1558
|
|
|
1542
1559
|
# <!--
|
|
1543
1560
|
# rdoc-file=file.c
|
|
@@ -1547,7 +1564,7 @@ class File < IO
|
|
|
1547
1564
|
#
|
|
1548
1565
|
# *file_name* can be an IO object.
|
|
1549
1566
|
#
|
|
1550
|
-
def self.size: (
|
|
1567
|
+
def self.size: (path | IO file_name) -> Integer
|
|
1551
1568
|
|
|
1552
1569
|
# <!--
|
|
1553
1570
|
# rdoc-file=file.c
|
|
@@ -1558,7 +1575,7 @@ class File < IO
|
|
|
1558
1575
|
#
|
|
1559
1576
|
# *file_name* can be an IO object.
|
|
1560
1577
|
#
|
|
1561
|
-
def self.size?: (
|
|
1578
|
+
def self.size?: (path | IO file_name) -> Integer?
|
|
1562
1579
|
|
|
1563
1580
|
# <!--
|
|
1564
1581
|
# rdoc-file=file.c
|
|
@@ -1570,7 +1587,7 @@ class File < IO
|
|
|
1570
1587
|
# File.socket?(Socket.new(:INET, :STREAM)) # => true
|
|
1571
1588
|
# File.socket?(File.new('t.txt')) # => false
|
|
1572
1589
|
#
|
|
1573
|
-
def self.socket?: (
|
|
1590
|
+
def self.socket?: (path | IO file_name) -> bool
|
|
1574
1591
|
|
|
1575
1592
|
# <!--
|
|
1576
1593
|
# rdoc-file=file.c
|
|
@@ -1581,7 +1598,7 @@ class File < IO
|
|
|
1581
1598
|
#
|
|
1582
1599
|
# File.split("/home/gumby/.profile") #=> ["/home/gumby", ".profile"]
|
|
1583
1600
|
#
|
|
1584
|
-
def self.split: (
|
|
1601
|
+
def self.split: (path file_name) -> [ String, String ]
|
|
1585
1602
|
|
|
1586
1603
|
# <!--
|
|
1587
1604
|
# rdoc-file=file.c
|
|
@@ -1591,7 +1608,7 @@ class File < IO
|
|
|
1591
1608
|
#
|
|
1592
1609
|
# File.stat('t.txt').class # => File::Stat
|
|
1593
1610
|
#
|
|
1594
|
-
def self.stat: (
|
|
1611
|
+
def self.stat: (path file_name) -> File::Stat
|
|
1595
1612
|
|
|
1596
1613
|
# <!--
|
|
1597
1614
|
# rdoc-file=file.c
|
|
@@ -1601,7 +1618,7 @@ class File < IO
|
|
|
1601
1618
|
#
|
|
1602
1619
|
# *file_name* can be an IO object.
|
|
1603
1620
|
#
|
|
1604
|
-
def self.sticky?: (
|
|
1621
|
+
def self.sticky?: (path | IO file_name) -> bool
|
|
1605
1622
|
|
|
1606
1623
|
# <!--
|
|
1607
1624
|
# rdoc-file=file.c
|
|
@@ -1613,7 +1630,7 @@ class File < IO
|
|
|
1613
1630
|
#
|
|
1614
1631
|
# File.symlink("testfile", "link2test") #=> 0
|
|
1615
1632
|
#
|
|
1616
|
-
def self.symlink: (
|
|
1633
|
+
def self.symlink: (path old_name, path new_name) -> 0
|
|
1617
1634
|
|
|
1618
1635
|
# <!--
|
|
1619
1636
|
# rdoc-file=file.c
|
|
@@ -1625,7 +1642,7 @@ class File < IO
|
|
|
1625
1642
|
# File.symlink?('symlink') # => true
|
|
1626
1643
|
# File.symlink?('t.txt') # => false
|
|
1627
1644
|
#
|
|
1628
|
-
def self.symlink?: (
|
|
1645
|
+
def self.symlink?: (path file_name) -> bool
|
|
1629
1646
|
|
|
1630
1647
|
# <!--
|
|
1631
1648
|
# rdoc-file=file.c
|
|
@@ -1640,7 +1657,7 @@ class File < IO
|
|
|
1640
1657
|
# File.truncate("out", 5) #=> 0
|
|
1641
1658
|
# File.size("out") #=> 5
|
|
1642
1659
|
#
|
|
1643
|
-
def self.truncate: (
|
|
1660
|
+
def self.truncate: (path file_name, int length) -> 0
|
|
1644
1661
|
|
|
1645
1662
|
# <!--
|
|
1646
1663
|
# rdoc-file=file.c
|
|
@@ -1670,7 +1687,7 @@ class File < IO
|
|
|
1670
1687
|
#
|
|
1671
1688
|
# See also Dir::rmdir.
|
|
1672
1689
|
#
|
|
1673
|
-
def self.unlink: (*
|
|
1690
|
+
def self.unlink: (*path file_name) -> Integer
|
|
1674
1691
|
|
|
1675
1692
|
# <!--
|
|
1676
1693
|
# rdoc-file=file.c
|
|
@@ -1681,7 +1698,7 @@ class File < IO
|
|
|
1681
1698
|
# than the link itself; for the inverse behavior see File.lutime. Returns the
|
|
1682
1699
|
# number of file names in the argument list.
|
|
1683
1700
|
#
|
|
1684
|
-
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *
|
|
1701
|
+
def self.utime: (Time | Numeric atime, Time | Numeric mtime, *path file_name) -> Integer
|
|
1685
1702
|
|
|
1686
1703
|
# <!--
|
|
1687
1704
|
# rdoc-file=file.c
|
|
@@ -1697,7 +1714,7 @@ class File < IO
|
|
|
1697
1714
|
# m = File.world_readable?("/etc/passwd")
|
|
1698
1715
|
# sprintf("%o", m) #=> "644"
|
|
1699
1716
|
#
|
|
1700
|
-
def self.world_readable?: (
|
|
1717
|
+
def self.world_readable?: (path | IO file_name) -> Integer?
|
|
1701
1718
|
|
|
1702
1719
|
# <!--
|
|
1703
1720
|
# rdoc-file=file.c
|
|
@@ -1713,7 +1730,7 @@ class File < IO
|
|
|
1713
1730
|
# m = File.world_writable?("/tmp")
|
|
1714
1731
|
# sprintf("%o", m) #=> "777"
|
|
1715
1732
|
#
|
|
1716
|
-
def self.world_writable?: (
|
|
1733
|
+
def self.world_writable?: (path | IO file_name) -> Integer?
|
|
1717
1734
|
|
|
1718
1735
|
# <!--
|
|
1719
1736
|
# rdoc-file=file.c
|
|
@@ -1725,7 +1742,7 @@ class File < IO
|
|
|
1725
1742
|
# Note that some OS-level security features may cause this to return true even
|
|
1726
1743
|
# though the file is not writable by the effective user/group.
|
|
1727
1744
|
#
|
|
1728
|
-
def self.writable?: (
|
|
1745
|
+
def self.writable?: (path file_name) -> bool
|
|
1729
1746
|
|
|
1730
1747
|
# <!--
|
|
1731
1748
|
# rdoc-file=file.c
|
|
@@ -1737,7 +1754,7 @@ class File < IO
|
|
|
1737
1754
|
# Note that some OS-level security features may cause this to return true even
|
|
1738
1755
|
# though the file is not writable by the real user/group.
|
|
1739
1756
|
#
|
|
1740
|
-
def self.writable_real?: (
|
|
1757
|
+
def self.writable_real?: (path file_name) -> bool
|
|
1741
1758
|
|
|
1742
1759
|
# <!--
|
|
1743
1760
|
# rdoc-file=file.c
|
|
@@ -1747,7 +1764,7 @@ class File < IO
|
|
|
1747
1764
|
#
|
|
1748
1765
|
# *file_name* can be an IO object.
|
|
1749
1766
|
#
|
|
1750
|
-
def self.zero?: (
|
|
1767
|
+
def self.zero?: (path | IO file_name) -> bool
|
|
1751
1768
|
|
|
1752
1769
|
# <!--
|
|
1753
1770
|
# rdoc-file=file.c
|
|
@@ -1822,12 +1839,12 @@ class File < IO
|
|
|
1822
1839
|
# Returns `false` if `File::LOCK_NB` is specified and the operation would have
|
|
1823
1840
|
# blocked;
|
|
1824
1841
|
# otherwise returns `0`.
|
|
1825
|
-
# Constant | Lock |
|
|
1826
|
-
#
|
|
1827
|
-
#
|
|
1828
|
-
#
|
|
1829
|
-
#
|
|
1830
|
-
#
|
|
1842
|
+
# Constant | Lock | Effect
|
|
1843
|
+
# ---------------|------------|-------------------------------------------------------------------------------------------------------
|
|
1844
|
+
# `File::LOCK_EX`| Exclusive | Only one process may hold an exclusive lock for `self` at a time.
|
|
1845
|
+
# `File::LOCK_NB`|Non-blocking|No blocking; may be combined with `File::LOCK_SH` or `File::LOCK_EX` using the bitwise OR operator `|`.
|
|
1846
|
+
# `File::LOCK_SH`| Shared | Multiple processes may each hold a shared lock for `self` at the same time.
|
|
1847
|
+
# `File::LOCK_UN`| Unlock | Remove an existing lock held by this process.
|
|
1831
1848
|
# Example:
|
|
1832
1849
|
# # Update a counter using an exclusive lock.
|
|
1833
1850
|
# # Don't use File::WRONLY because it truncates the file.
|
|
@@ -2429,10 +2446,8 @@ class File::Stat < Object
|
|
|
2429
2446
|
|
|
2430
2447
|
# <!--
|
|
2431
2448
|
# rdoc-file=file.c
|
|
2432
|
-
# - new(
|
|
2449
|
+
# - File::Stat.new(file_name) -> stat
|
|
2433
2450
|
# -->
|
|
2434
|
-
# File::Stat.new(file_name) -> stat
|
|
2435
|
-
#
|
|
2436
2451
|
# Create a File::Stat object for the given file name (raising an exception if
|
|
2437
2452
|
# the file doesn't exist).
|
|
2438
2453
|
#
|
|
@@ -2440,16 +2455,31 @@ class File::Stat < Object
|
|
|
2440
2455
|
|
|
2441
2456
|
# <!--
|
|
2442
2457
|
# rdoc-file=file.c
|
|
2443
|
-
# -
|
|
2458
|
+
# - self <=> other -> -1, 0, 1, or nil
|
|
2444
2459
|
# -->
|
|
2445
|
-
# Compares
|
|
2460
|
+
# Compares `self` and `other`, by comparing their modification times; that is,
|
|
2461
|
+
# by comparing `self.mtime` and `other.mtime`.
|
|
2462
|
+
#
|
|
2463
|
+
# Returns:
|
|
2446
2464
|
#
|
|
2447
|
-
#
|
|
2465
|
+
# * `-1`, if `self.mtime` is earlier.
|
|
2466
|
+
# * `0`, if the two values are equal.
|
|
2467
|
+
# * `1`, if `self.mtime` is later.
|
|
2468
|
+
# * `nil`, if `other` is not a File::Stat object.
|
|
2469
|
+
#
|
|
2470
|
+
# Examples:
|
|
2448
2471
|
#
|
|
2449
|
-
#
|
|
2450
|
-
#
|
|
2451
|
-
#
|
|
2452
|
-
#
|
|
2472
|
+
# stat0 = File.stat('README.md')
|
|
2473
|
+
# stat1 = File.stat('NEWS.md')
|
|
2474
|
+
# stat0.mtime # => 2025-12-20 15:33:05.6972341 -0600
|
|
2475
|
+
# stat1.mtime # => 2025-12-20 16:02:08.2672945 -0600
|
|
2476
|
+
# stat0 <=> stat1 # => -1
|
|
2477
|
+
# stat0 <=> stat0.dup # => 0
|
|
2478
|
+
# stat1 <=> stat0 # => 1
|
|
2479
|
+
# stat0 <=> :foo # => nil
|
|
2480
|
+
#
|
|
2481
|
+
# Class File::Stat includes module Comparable, each of whose methods uses
|
|
2482
|
+
# File::Stat#<=> for comparison.
|
|
2453
2483
|
#
|
|
2454
2484
|
def <=>: (File::Stat other) -> Integer
|
|
2455
2485
|
| (untyped) -> nil
|
data/core/file_test.rbs
CHANGED
|
@@ -145,7 +145,7 @@ module FileTest
|
|
|
145
145
|
# rdoc-file=file.c
|
|
146
146
|
# - File.owned?(file_name) -> true or false
|
|
147
147
|
# -->
|
|
148
|
-
# Returns `true` if the named file exists and the effective
|
|
148
|
+
# Returns `true` if the named file exists and the effective user id of the
|
|
149
149
|
# calling process is the owner of the file.
|
|
150
150
|
#
|
|
151
151
|
# *file_name* can be an IO object.
|