steep 0.11.1 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +27 -0
- data/.gitmodules +3 -0
- data/CHANGELOG.md +5 -0
- data/README.md +48 -90
- data/Rakefile +10 -6
- data/Steepfile +1 -0
- data/bin/setup +1 -0
- data/bin/smoke_runner.rb +9 -14
- data/exe/rbs +3 -0
- data/exe/ruby-signature +3 -0
- data/exe/steep +1 -0
- data/lib/steep.rb +32 -26
- data/lib/steep/annotation_parser.rb +167 -0
- data/lib/steep/ast/annotation/collection.rb +7 -7
- data/lib/steep/ast/types.rb +60 -0
- data/lib/steep/ast/types/any.rb +1 -1
- data/lib/steep/ast/types/factory.rb +535 -0
- data/lib/steep/ast/types/name.rb +3 -3
- data/lib/steep/ast/types/var.rb +1 -1
- data/lib/steep/cli.rb +56 -240
- data/lib/steep/drivers/annotations.rb +36 -19
- data/lib/steep/drivers/check.rb +55 -91
- data/lib/steep/drivers/init.rb +54 -0
- data/lib/steep/drivers/langserver.rb +241 -150
- data/lib/steep/drivers/print_project.rb +56 -0
- data/lib/steep/drivers/signature_error_printer.rb +25 -0
- data/lib/steep/drivers/trace_printer.rb +25 -0
- data/lib/steep/drivers/utils/driver_helper.rb +26 -0
- data/lib/steep/drivers/validate.rb +18 -38
- data/lib/steep/drivers/vendor.rb +46 -0
- data/lib/steep/drivers/watch.rb +78 -140
- data/lib/steep/errors.rb +22 -13
- data/lib/steep/interface/interface.rb +91 -0
- data/lib/steep/interface/method.rb +0 -4
- data/lib/steep/interface/method_type.rb +362 -2
- data/lib/steep/interface/substitution.rb +22 -0
- data/lib/steep/project.rb +25 -233
- data/lib/steep/project/dsl.rb +132 -0
- data/lib/steep/project/file.rb +93 -76
- data/lib/steep/project/file_loader.rb +63 -0
- data/lib/steep/project/options.rb +7 -0
- data/lib/steep/project/target.rb +190 -0
- data/lib/steep/signature/errors.rb +25 -77
- data/lib/steep/signature/validator.rb +122 -0
- data/lib/steep/source.rb +12 -7
- data/lib/steep/subtyping/check.rb +357 -633
- data/lib/steep/subtyping/constraints.rb +2 -2
- data/lib/steep/subtyping/trace.rb +23 -0
- data/lib/steep/type_construction.rb +509 -455
- data/lib/steep/type_inference/constant_env.rb +16 -24
- data/lib/steep/type_inference/type_env.rb +26 -18
- data/lib/steep/version.rb +1 -1
- data/sample/Steepfile +6 -0
- data/sample/lib/conference.rb +12 -0
- data/sample/sig/conference.rbs +6 -0
- data/smoke/alias/Steepfile +4 -0
- data/smoke/alias/a.rb +2 -2
- data/smoke/alias/{a.rbi → a.rbs} +1 -1
- data/smoke/and/Steepfile +4 -0
- data/smoke/array/Steepfile +4 -0
- data/smoke/array/a.rb +2 -2
- data/smoke/array/b.rb +4 -4
- data/smoke/array/c.rb +2 -2
- data/smoke/block/Steepfile +5 -0
- data/smoke/block/{a.rbi → a.rbs} +1 -1
- data/smoke/block/{c.rbi → c.rbs} +0 -0
- data/smoke/block/d.rb +6 -6
- data/smoke/case/Steepfile +4 -0
- data/smoke/case/a.rb +4 -3
- data/smoke/class/Steepfile +4 -0
- data/smoke/class/a.rb +1 -4
- data/smoke/class/a.rbs +24 -0
- data/smoke/class/h.rb +6 -2
- data/smoke/class/{h.rbi → h.rbs} +1 -2
- data/smoke/class/i.rb +1 -2
- data/smoke/class/i.rbs +9 -0
- data/smoke/const/Steepfile +4 -0
- data/smoke/dstr/Steepfile +4 -0
- data/smoke/ensure/Steepfile +4 -0
- data/smoke/ensure/a.rb +1 -1
- data/smoke/enumerator/Steepfile +4 -0
- data/smoke/enumerator/a.rb +7 -7
- data/smoke/enumerator/b.rb +6 -6
- data/smoke/extension/Steepfile +4 -0
- data/smoke/extension/{a.rbi → a.rbs} +2 -2
- data/smoke/extension/{e.rbi → e.rbs} +2 -2
- data/smoke/hash/Steepfile +4 -0
- data/smoke/hash/{a.rbi → a.rbs} +0 -0
- data/smoke/hash/b.rb +2 -2
- data/smoke/hash/c.rb +1 -1
- data/smoke/hash/e.rbs +3 -0
- data/smoke/hash/f.rb +1 -1
- data/smoke/hello/Steepfile +4 -0
- data/smoke/hello/hello.rbs +7 -0
- data/smoke/if/Steepfile +4 -0
- data/smoke/implements/Steepfile +4 -0
- data/smoke/implements/a.rbs +6 -0
- data/smoke/initialize/Steepfile +4 -0
- data/smoke/initialize/a.rbs +3 -0
- data/smoke/integer/Steepfile +4 -0
- data/smoke/integer/a.rb +5 -3
- data/smoke/interface/Steepfile +4 -0
- data/smoke/interface/{a.rbi → a.rbs} +0 -0
- data/smoke/kwbegin/Steepfile +4 -0
- data/smoke/lambda/Steepfile +4 -0
- data/smoke/lambda/a.rb +9 -2
- data/smoke/literal/Steepfile +4 -0
- data/smoke/literal/{literal_methods.rbi → literal_methods.rbs} +0 -0
- data/smoke/map/Steepfile +4 -0
- data/smoke/map/a.rb +1 -1
- data/smoke/method/Steepfile +4 -0
- data/smoke/method/{a.rbi → a.rbs} +0 -0
- data/smoke/method/b.rb +1 -4
- data/smoke/method/d.rb +1 -0
- data/smoke/method/d.rbs +3 -0
- data/smoke/module/Steepfile +4 -0
- data/smoke/module/a.rb +1 -1
- data/smoke/module/a.rbs +16 -0
- data/smoke/module/c.rb +1 -1
- data/smoke/regexp/Steepfile +4 -0
- data/smoke/regexp/a.rb +2 -2
- data/smoke/regexp/b.rb +16 -16
- data/smoke/regression/Steepfile +5 -0
- data/smoke/regression/array.rb +2 -2
- data/smoke/regression/hash.rb +2 -2
- data/smoke/regression/poly_new.rb +2 -0
- data/smoke/regression/poly_new.rbs +4 -0
- data/smoke/regression/set_divide.rb +2 -2
- data/smoke/rescue/Steepfile +4 -0
- data/smoke/rescue/a.rb +1 -1
- data/smoke/self/Steepfile +4 -0
- data/smoke/self/a.rbs +4 -0
- data/smoke/skip/Steepfile +4 -0
- data/smoke/stdout/Steepfile +4 -0
- data/smoke/stdout/{a.rbi → a.rbs} +1 -1
- data/smoke/super/Steepfile +4 -0
- data/smoke/super/a.rbs +10 -0
- data/smoke/type_case/Steepfile +4 -0
- data/smoke/type_case/a.rb +1 -1
- data/smoke/yield/Steepfile +4 -0
- data/smoke/yield/a.rb +2 -2
- data/steep.gemspec +14 -7
- data/vendor/ruby-signature/.github/workflows/ruby.yml +27 -0
- data/vendor/ruby-signature/.gitignore +12 -0
- data/vendor/ruby-signature/.rubocop.yml +15 -0
- data/vendor/ruby-signature/BSDL +22 -0
- data/vendor/ruby-signature/COPYING +56 -0
- data/vendor/ruby-signature/Gemfile +6 -0
- data/vendor/ruby-signature/README.md +93 -0
- data/vendor/ruby-signature/Rakefile +66 -0
- data/vendor/ruby-signature/bin/annotate-with-rdoc +156 -0
- data/vendor/ruby-signature/bin/console +14 -0
- data/vendor/ruby-signature/bin/query-rdoc +103 -0
- data/vendor/ruby-signature/bin/setup +10 -0
- data/vendor/ruby-signature/bin/sort +88 -0
- data/vendor/ruby-signature/bin/test_runner.rb +17 -0
- data/vendor/ruby-signature/docs/CONTRIBUTING.md +97 -0
- data/vendor/ruby-signature/docs/sigs.md +148 -0
- data/vendor/ruby-signature/docs/stdlib.md +152 -0
- data/vendor/ruby-signature/docs/syntax.md +528 -0
- data/vendor/ruby-signature/exe/rbs +3 -0
- data/vendor/ruby-signature/exe/ruby-signature +7 -0
- data/vendor/ruby-signature/lib/ruby/signature.rb +64 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/annotation.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/comment.rb +29 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/declarations.rb +391 -0
- data/vendor/ruby-signature/lib/ruby/signature/ast/members.rb +364 -0
- data/vendor/ruby-signature/lib/ruby/signature/buffer.rb +52 -0
- data/vendor/ruby-signature/lib/ruby/signature/builtin_names.rb +54 -0
- data/vendor/ruby-signature/lib/ruby/signature/cli.rb +534 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/constant_table.rb +152 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition.rb +172 -0
- data/vendor/ruby-signature/lib/ruby/signature/definition_builder.rb +921 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment.rb +283 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_loader.rb +138 -0
- data/vendor/ruby-signature/lib/ruby/signature/environment_walker.rb +126 -0
- data/vendor/ruby-signature/lib/ruby/signature/errors.rb +189 -0
- data/vendor/ruby-signature/lib/ruby/signature/location.rb +104 -0
- data/vendor/ruby-signature/lib/ruby/signature/method_type.rb +125 -0
- data/vendor/ruby-signature/lib/ruby/signature/namespace.rb +93 -0
- data/vendor/ruby-signature/lib/ruby/signature/parser.y +1343 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rb.rb +441 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/rbi.rb +579 -0
- data/vendor/ruby-signature/lib/ruby/signature/prototype/runtime.rb +383 -0
- data/vendor/ruby-signature/lib/ruby/signature/substitution.rb +48 -0
- data/vendor/ruby-signature/lib/ruby/signature/test.rb +28 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/errors.rb +63 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/hook.rb +290 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/setup.rb +58 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/spy.rb +324 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/test_helper.rb +185 -0
- data/vendor/ruby-signature/lib/ruby/signature/test/type_check.rb +256 -0
- data/vendor/ruby-signature/lib/ruby/signature/type_name.rb +72 -0
- data/vendor/ruby-signature/lib/ruby/signature/types.rb +932 -0
- data/vendor/ruby-signature/lib/ruby/signature/variance_calculator.rb +140 -0
- data/vendor/ruby-signature/lib/ruby/signature/vendorer.rb +49 -0
- data/vendor/ruby-signature/lib/ruby/signature/version.rb +5 -0
- data/vendor/ruby-signature/lib/ruby/signature/writer.rb +271 -0
- data/vendor/ruby-signature/ruby-signature.gemspec +45 -0
- data/vendor/ruby-signature/stdlib/abbrev/abbrev.rbs +3 -0
- data/vendor/ruby-signature/stdlib/base64/base64.rbs +15 -0
- data/vendor/ruby-signature/stdlib/builtin/array.rbs +1997 -0
- data/vendor/ruby-signature/stdlib/builtin/basic_object.rbs +280 -0
- data/vendor/ruby-signature/stdlib/builtin/binding.rbs +177 -0
- data/vendor/ruby-signature/stdlib/builtin/builtin.rbs +35 -0
- data/vendor/ruby-signature/stdlib/builtin/class.rbs +145 -0
- data/vendor/ruby-signature/stdlib/builtin/comparable.rbs +116 -0
- data/vendor/ruby-signature/stdlib/builtin/complex.rbs +400 -0
- data/vendor/ruby-signature/stdlib/builtin/constants.rbs +37 -0
- data/vendor/ruby-signature/stdlib/builtin/data.rbs +5 -0
- data/vendor/ruby-signature/stdlib/builtin/deprecated.rbs +2 -0
- data/vendor/ruby-signature/stdlib/builtin/dir.rbs +419 -0
- data/vendor/ruby-signature/stdlib/builtin/encoding.rbs +606 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerable.rbs +404 -0
- data/vendor/ruby-signature/stdlib/builtin/enumerator.rbs +260 -0
- data/vendor/ruby-signature/stdlib/builtin/errno.rbs +781 -0
- data/vendor/ruby-signature/stdlib/builtin/errors.rbs +582 -0
- data/vendor/ruby-signature/stdlib/builtin/exception.rbs +193 -0
- data/vendor/ruby-signature/stdlib/builtin/false_class.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber.rbs +68 -0
- data/vendor/ruby-signature/stdlib/builtin/fiber_error.rbs +12 -0
- data/vendor/ruby-signature/stdlib/builtin/file.rbs +476 -0
- data/vendor/ruby-signature/stdlib/builtin/file_test.rbs +59 -0
- data/vendor/ruby-signature/stdlib/builtin/float.rbs +696 -0
- data/vendor/ruby-signature/stdlib/builtin/gc.rbs +121 -0
- data/vendor/ruby-signature/stdlib/builtin/hash.rbs +1029 -0
- data/vendor/ruby-signature/stdlib/builtin/integer.rbs +710 -0
- data/vendor/ruby-signature/stdlib/builtin/io.rbs +683 -0
- data/vendor/ruby-signature/stdlib/builtin/kernel.rbs +574 -0
- data/vendor/ruby-signature/stdlib/builtin/marshal.rbs +135 -0
- data/vendor/ruby-signature/stdlib/builtin/match_data.rbs +141 -0
- data/vendor/ruby-signature/stdlib/builtin/math.rbs +66 -0
- data/vendor/ruby-signature/stdlib/builtin/method.rbs +182 -0
- data/vendor/ruby-signature/stdlib/builtin/module.rbs +248 -0
- data/vendor/ruby-signature/stdlib/builtin/nil_class.rbs +82 -0
- data/vendor/ruby-signature/stdlib/builtin/numeric.rbs +409 -0
- data/vendor/ruby-signature/stdlib/builtin/object.rbs +824 -0
- data/vendor/ruby-signature/stdlib/builtin/proc.rbs +426 -0
- data/vendor/ruby-signature/stdlib/builtin/process.rbs +354 -0
- data/vendor/ruby-signature/stdlib/builtin/random.rbs +93 -0
- data/vendor/ruby-signature/stdlib/builtin/range.rbs +226 -0
- data/vendor/ruby-signature/stdlib/builtin/rational.rbs +424 -0
- data/vendor/ruby-signature/stdlib/builtin/rb_config.rbs +10 -0
- data/vendor/ruby-signature/stdlib/builtin/regexp.rbs +131 -0
- data/vendor/ruby-signature/stdlib/builtin/ruby_vm.rbs +14 -0
- data/vendor/ruby-signature/stdlib/builtin/signal.rbs +55 -0
- data/vendor/ruby-signature/stdlib/builtin/string.rbs +770 -0
- data/vendor/ruby-signature/stdlib/builtin/string_io.rbs +13 -0
- data/vendor/ruby-signature/stdlib/builtin/struct.rbs +40 -0
- data/vendor/ruby-signature/stdlib/builtin/symbol.rbs +230 -0
- data/vendor/ruby-signature/stdlib/builtin/thread.rbs +1112 -0
- data/vendor/ruby-signature/stdlib/builtin/thread_group.rbs +23 -0
- data/vendor/ruby-signature/stdlib/builtin/time.rbs +739 -0
- data/vendor/ruby-signature/stdlib/builtin/trace_point.rbs +91 -0
- data/vendor/ruby-signature/stdlib/builtin/true_class.rbs +46 -0
- data/vendor/ruby-signature/stdlib/builtin/unbound_method.rbs +159 -0
- data/vendor/ruby-signature/stdlib/builtin/warning.rbs +17 -0
- data/vendor/ruby-signature/stdlib/erb/erb.rbs +18 -0
- data/vendor/ruby-signature/stdlib/find/find.rbs +44 -0
- data/vendor/ruby-signature/stdlib/pathname/pathname.rbs +21 -0
- data/vendor/ruby-signature/stdlib/prime/integer-extension.rbs +23 -0
- data/vendor/ruby-signature/stdlib/prime/prime.rbs +188 -0
- data/vendor/ruby-signature/stdlib/securerandom/securerandom.rbs +9 -0
- data/vendor/ruby-signature/stdlib/set/set.rbs +77 -0
- data/vendor/ruby-signature/stdlib/tmpdir/tmpdir.rbs +53 -0
- metadata +244 -54
- data/.travis.yml +0 -7
- data/lib/steep/ast/signature/alias.rb +0 -19
- data/lib/steep/ast/signature/class.rb +0 -33
- data/lib/steep/ast/signature/const.rb +0 -17
- data/lib/steep/ast/signature/env.rb +0 -138
- data/lib/steep/ast/signature/extension.rb +0 -21
- data/lib/steep/ast/signature/gvar.rb +0 -17
- data/lib/steep/ast/signature/interface.rb +0 -31
- data/lib/steep/ast/signature/members.rb +0 -115
- data/lib/steep/ast/signature/module.rb +0 -21
- data/lib/steep/drivers/print_interface.rb +0 -94
- data/lib/steep/drivers/scaffold.rb +0 -321
- data/lib/steep/drivers/utils/each_signature.rb +0 -31
- data/lib/steep/interface/abstract.rb +0 -68
- data/lib/steep/interface/builder.rb +0 -637
- data/lib/steep/interface/instantiated.rb +0 -163
- data/lib/steep/interface/ivar_chain.rb +0 -26
- data/lib/steep/parser.y +0 -1278
- data/lib/steep/project/listener.rb +0 -53
- data/smoke/class/a.rbi +0 -24
- data/smoke/class/d.rb +0 -9
- data/smoke/class/e.rb +0 -12
- data/smoke/class/i.rbi +0 -9
- data/smoke/hash/e.rbi +0 -3
- data/smoke/hello/hello.rbi +0 -7
- data/smoke/implements/a.rbi +0 -6
- data/smoke/initialize/a.rbi +0 -3
- data/smoke/module/a.rbi +0 -16
- data/smoke/self/a.rbi +0 -4
- data/smoke/super/a.rbi +0 -10
- data/stdlib/builtin.rbi +0 -787
@@ -0,0 +1,37 @@
|
|
1
|
+
::ARGF: Object
|
2
|
+
|
3
|
+
::ARGV: Array[String]
|
4
|
+
|
5
|
+
::CROSS_COMPILING: NilClass
|
6
|
+
|
7
|
+
::FALSE: FalseClass
|
8
|
+
|
9
|
+
::NIL: NilClass
|
10
|
+
|
11
|
+
::RUBY_COPYRIGHT: String
|
12
|
+
|
13
|
+
::RUBY_DESCRIPTION: String
|
14
|
+
|
15
|
+
::RUBY_ENGINE: String
|
16
|
+
|
17
|
+
::RUBY_ENGINE_VERSION: String
|
18
|
+
|
19
|
+
::RUBY_PATCHLEVEL: Integer
|
20
|
+
|
21
|
+
::RUBY_PLATFORM: String
|
22
|
+
|
23
|
+
::RUBY_RELEASE_DATE: String
|
24
|
+
|
25
|
+
::RUBY_REVISION: Integer
|
26
|
+
|
27
|
+
::RUBY_VERSION: String
|
28
|
+
|
29
|
+
::STDERR: IO
|
30
|
+
|
31
|
+
::STDIN: IO
|
32
|
+
|
33
|
+
::STDOUT: IO
|
34
|
+
|
35
|
+
::TOPLEVEL_BINDING: Binding
|
36
|
+
|
37
|
+
::TRUE: TrueClass
|
@@ -0,0 +1,419 @@
|
|
1
|
+
# Objects of class Dir are directory streams representing directories in the
|
2
|
+
# underlying file system. They provide a variety of ways to list directories and
|
3
|
+
# their contents. See also File.
|
4
|
+
#
|
5
|
+
# The directory used in these examples contains the two regular files
|
6
|
+
# (`config.h` and `main.rb`), the parent directory (`..`), and the directory
|
7
|
+
# itself (`.`).
|
8
|
+
#
|
9
|
+
class Dir
|
10
|
+
include Enumerable[String, Dir]
|
11
|
+
|
12
|
+
# Returns a new directory object for the named directory.
|
13
|
+
#
|
14
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
15
|
+
# directory. If not specified, the filesystem encoding is used.
|
16
|
+
#
|
17
|
+
def initialize: (string, ?encoding: Encoding | string | nil) -> void
|
18
|
+
|
19
|
+
# Equivalent to calling `Dir.glob([string,...], 0)`.
|
20
|
+
#
|
21
|
+
def self.[]: (*string patterns, ?base: string) ?{ (String path) -> void } -> Array[String]
|
22
|
+
|
23
|
+
# Changes the current working directory of the process to the given string. When
|
24
|
+
# called without an argument, changes the directory to the value of the
|
25
|
+
# environment variable `HOME`, or `LOGDIR`. SystemCallError (probably
|
26
|
+
# Errno::ENOENT) if the target directory does not exist.
|
27
|
+
#
|
28
|
+
# If a block is given, it is passed the name of the new current directory, and
|
29
|
+
# the block is executed with that as the current directory. The original working
|
30
|
+
# directory is restored when the block exits. The return value of `chdir` is the
|
31
|
+
# value of the block. `chdir` blocks can be nested, but in a multi-threaded
|
32
|
+
# program an error will be raised if a thread attempts to open a `chdir` block
|
33
|
+
# while another thread has one open.
|
34
|
+
#
|
35
|
+
# Dir.chdir("/var/spool/mail")
|
36
|
+
# puts Dir.pwd
|
37
|
+
# Dir.chdir("/tmp") do
|
38
|
+
# puts Dir.pwd
|
39
|
+
# Dir.chdir("/usr") do
|
40
|
+
# puts Dir.pwd
|
41
|
+
# end
|
42
|
+
# puts Dir.pwd
|
43
|
+
# end
|
44
|
+
# puts Dir.pwd
|
45
|
+
#
|
46
|
+
# *produces:*
|
47
|
+
#
|
48
|
+
# /var/spool/mail
|
49
|
+
# /tmp
|
50
|
+
# /usr
|
51
|
+
# /tmp
|
52
|
+
# /var/spool/mail
|
53
|
+
#
|
54
|
+
def self.chdir: (?string) -> void
|
55
|
+
| [U] (?string) { (String) -> U } -> U
|
56
|
+
|
57
|
+
# Returns an array containing all of the filenames except for "." and ".." in
|
58
|
+
# the given directory. Will raise a SystemCallError if the named directory
|
59
|
+
# doesn't exist.
|
60
|
+
#
|
61
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
62
|
+
# directory. If not specified, the filesystem encoding is used.
|
63
|
+
#
|
64
|
+
# Dir.children("testdir") #=> ["config.h", "main.rb"]
|
65
|
+
#
|
66
|
+
def self.children: (string dirname, ?encoding: string | Encoding | nil enc) -> Array[String]
|
67
|
+
|
68
|
+
# Changes this process's idea of the file system root. Only a privileged process
|
69
|
+
# may make this call. Not available on all platforms. On Unix systems, see
|
70
|
+
# `chroot(2)` for more information.
|
71
|
+
#
|
72
|
+
def self.chroot: (string) -> void
|
73
|
+
|
74
|
+
# Deletes the named directory. Raises a subclass of SystemCallError if the
|
75
|
+
# directory isn't empty.
|
76
|
+
#
|
77
|
+
def self.delete: (string) -> void
|
78
|
+
|
79
|
+
# Calls the block once for each entry except for "." and ".." in the named
|
80
|
+
# directory, passing the filename of each entry as a parameter to the block.
|
81
|
+
#
|
82
|
+
# If no block is given, an enumerator is returned instead.
|
83
|
+
#
|
84
|
+
# Dir.each_child("testdir") {|x| puts "Got #{x}" }
|
85
|
+
#
|
86
|
+
# *produces:*
|
87
|
+
#
|
88
|
+
# Got config.h
|
89
|
+
# Got main.rb
|
90
|
+
#
|
91
|
+
def self.each_child: (string dirname, ?encoding: string | Encoding | nil enc) -> Enumerator[String, void]
|
92
|
+
| (string dirname, ?encoding: string | Encoding | nil enc) { (String filename) -> void } -> void
|
93
|
+
|
94
|
+
# Returns `true` if the named file is an empty directory, `false` if it is not a
|
95
|
+
# directory or non-empty.
|
96
|
+
#
|
97
|
+
def self.empty?: (string path_name) -> bool
|
98
|
+
|
99
|
+
# Returns an array containing all of the filenames in the given directory. Will
|
100
|
+
# raise a SystemCallError if the named directory doesn't exist.
|
101
|
+
#
|
102
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
103
|
+
# directory. If not specified, the filesystem encoding is used.
|
104
|
+
#
|
105
|
+
# Dir.entries("testdir") #=> [".", "..", "config.h", "main.rb"]
|
106
|
+
#
|
107
|
+
def self.entries: (string dirname, ?encoding: Encoding | string | nil enc) -> ::Array[String]
|
108
|
+
|
109
|
+
# Returns `true` if the named file is a directory, `false` otherwise.
|
110
|
+
#
|
111
|
+
def self.exist?: (string file) -> bool
|
112
|
+
|
113
|
+
# Deprecated method. Don't use.
|
114
|
+
#
|
115
|
+
def self.exists?: (string file) -> bool
|
116
|
+
|
117
|
+
# Calls the block once for each entry in the named directory, passing the
|
118
|
+
# filename of each entry as a parameter to the block.
|
119
|
+
#
|
120
|
+
# If no block is given, an enumerator is returned instead.
|
121
|
+
#
|
122
|
+
# Dir.foreach("testdir") {|x| puts "Got #{x}" }
|
123
|
+
#
|
124
|
+
# *produces:*
|
125
|
+
#
|
126
|
+
# Got .
|
127
|
+
# Got ..
|
128
|
+
# Got config.h
|
129
|
+
# Got main.rb
|
130
|
+
#
|
131
|
+
alias self.foreach self.each_child
|
132
|
+
|
133
|
+
# Returns the path to the current working directory of this process as a string.
|
134
|
+
#
|
135
|
+
# Dir.chdir("/tmp") #=> 0
|
136
|
+
# Dir.getwd #=> "/tmp"
|
137
|
+
# Dir.pwd #=> "/tmp"
|
138
|
+
#
|
139
|
+
def self.getwd: () -> String
|
140
|
+
|
141
|
+
# Expands `pattern`, which is a pattern string or an Array of pattern strings,
|
142
|
+
# and returns an array containing the matching filenames. If a block is given,
|
143
|
+
# calls the block once for each matching filename, passing the filename as a
|
144
|
+
# parameter to the block.
|
145
|
+
#
|
146
|
+
# The optional `base` keyword argument specifies the base directory for
|
147
|
+
# interpreting relative pathnames instead of the current working directory. As
|
148
|
+
# the results are not prefixed with the base directory name in this case, you
|
149
|
+
# will need to prepend the base directory name if you want real paths.
|
150
|
+
#
|
151
|
+
# Note that the pattern is not a regexp, it's closer to a shell glob. See
|
152
|
+
# 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.
|
155
|
+
#
|
156
|
+
# `*`
|
157
|
+
# : Matches any file. Can be restricted by other values in the glob.
|
158
|
+
# Equivalent to `/ .* /mx` in regexp.
|
159
|
+
#
|
160
|
+
# `*`
|
161
|
+
# : Matches all files
|
162
|
+
# `c*`
|
163
|
+
# : Matches all files beginning with `c`
|
164
|
+
# `*c`
|
165
|
+
# : Matches all files ending with `c`
|
166
|
+
# `*c*`
|
167
|
+
# : Match all files that have `c` in them (including at the beginning or
|
168
|
+
# end).
|
169
|
+
#
|
170
|
+
#
|
171
|
+
# Note, this will not match Unix-like hidden files (dotfiles). In order to
|
172
|
+
# include those in the match results, you must use the File::FNM_DOTMATCH
|
173
|
+
# flag or something like `"{*,.*}"`.
|
174
|
+
#
|
175
|
+
# `**`
|
176
|
+
# : Matches directories recursively.
|
177
|
+
#
|
178
|
+
# `?`
|
179
|
+
# : Matches any one character. Equivalent to `/.{1}/` in regexp.
|
180
|
+
#
|
181
|
+
# `[set]`
|
182
|
+
# : Matches any one character in `set`. Behaves exactly like character sets
|
183
|
+
# in Regexp, including set negation (`[^a-z]`).
|
184
|
+
#
|
185
|
+
# `{p,q}`
|
186
|
+
# : Matches either literal `p` or literal `q`. Equivalent to pattern
|
187
|
+
# alternation in regexp.
|
188
|
+
#
|
189
|
+
# Matching literals may be more than one character in length. More than two
|
190
|
+
# literals may be specified.
|
191
|
+
#
|
192
|
+
# ` \\ `
|
193
|
+
# : Escapes the next metacharacter.
|
194
|
+
#
|
195
|
+
# Note that this means you cannot use backslash on windows as part of a
|
196
|
+
# glob, i.e. `Dir["c:\\foo*"]` will not work, use `Dir["c:/foo*"]` instead.
|
197
|
+
#
|
198
|
+
#
|
199
|
+
# Examples:
|
200
|
+
#
|
201
|
+
# Dir["config.?"] #=> ["config.h"]
|
202
|
+
# Dir.glob("config.?") #=> ["config.h"]
|
203
|
+
# Dir.glob("*.[a-z][a-z]") #=> ["main.rb"]
|
204
|
+
# Dir.glob("*.[^r]*") #=> ["config.h"]
|
205
|
+
# Dir.glob("*.{rb,h}") #=> ["main.rb", "config.h"]
|
206
|
+
# Dir.glob("*") #=> ["config.h", "main.rb"]
|
207
|
+
# Dir.glob("*", File::FNM_DOTMATCH) #=> [".", "..", "config.h", "main.rb"]
|
208
|
+
# Dir.glob(["*.rb", "*.h"]) #=> ["main.rb", "config.h"]
|
209
|
+
#
|
210
|
+
# rbfiles = File.join("**", "*.rb")
|
211
|
+
# Dir.glob(rbfiles) #=> ["main.rb",
|
212
|
+
# # "lib/song.rb",
|
213
|
+
# # "lib/song/karaoke.rb"]
|
214
|
+
#
|
215
|
+
# Dir.glob(rbfiles, base: "lib") #=> ["song.rb",
|
216
|
+
# # "song/karaoke.rb"]
|
217
|
+
#
|
218
|
+
# libdirs = File.join("**", "lib")
|
219
|
+
# Dir.glob(libdirs) #=> ["lib"]
|
220
|
+
#
|
221
|
+
# librbfiles = File.join("**", "lib", "**", "*.rb")
|
222
|
+
# Dir.glob(librbfiles) #=> ["lib/song.rb",
|
223
|
+
# # "lib/song/karaoke.rb"]
|
224
|
+
#
|
225
|
+
# librbfiles = File.join("**", "lib", "*.rb")
|
226
|
+
# Dir.glob(librbfiles) #=> ["lib/song.rb"]
|
227
|
+
#
|
228
|
+
def self.glob: (string | ::Array[string] pattern, ?Integer flags, ?base: string) -> ::Array[String]
|
229
|
+
| (string | ::Array[string] pattern, ?Integer flags, ?base: string) { (String) -> void } -> void
|
230
|
+
|
231
|
+
# Returns the home directory of the current user or the named user if given.
|
232
|
+
#
|
233
|
+
def self.home: (?string user) -> String
|
234
|
+
|
235
|
+
# Makes a new directory named by *string*, with permissions specified by the
|
236
|
+
# optional parameter *anInteger*. The permissions may be modified by the value
|
237
|
+
# of File::umask, and are ignored on NT. Raises a SystemCallError if the
|
238
|
+
# directory cannot be created. See also the discussion of permissions in the
|
239
|
+
# class documentation for File.
|
240
|
+
#
|
241
|
+
# Dir.mkdir(File.join(Dir.home, ".foo"), 0700) #=> 0
|
242
|
+
#
|
243
|
+
def self.mkdir: (string, ?Integer permissions) -> void
|
244
|
+
|
245
|
+
# The optional *encoding* keyword argument specifies the encoding of the
|
246
|
+
# directory. If not specified, the filesystem encoding is used.
|
247
|
+
#
|
248
|
+
# With no block, `open` is a synonym for Dir::new. If a block is present, it is
|
249
|
+
# passed *aDir* as a parameter. The directory is closed at the end of the block,
|
250
|
+
# and Dir::open returns the value of the block.
|
251
|
+
#
|
252
|
+
# # arglists 💪👽🚨 << Delete this section
|
253
|
+
# Dir.open( string ) -> aDir
|
254
|
+
# Dir.open( string, encoding: enc ) -> aDir
|
255
|
+
# Dir.open( string ) {| aDir | block } -> anObject
|
256
|
+
# Dir.open( string, encoding: enc ) {| aDir | block } -> anObject
|
257
|
+
#
|
258
|
+
def self.open: (string, ?encoding: Encoding | string | nil) -> Dir
|
259
|
+
| [U] (string, ?encoding: Encoding) { (Dir) -> U } -> U
|
260
|
+
|
261
|
+
# Returns the path to the current working directory of this process as a string.
|
262
|
+
#
|
263
|
+
# Dir.chdir("/tmp") #=> 0
|
264
|
+
# Dir.getwd #=> "/tmp"
|
265
|
+
# Dir.pwd #=> "/tmp"
|
266
|
+
#
|
267
|
+
def self.pwd: () -> String
|
268
|
+
|
269
|
+
# Deletes the named directory. Raises a subclass of SystemCallError if the
|
270
|
+
# directory isn't empty.
|
271
|
+
#
|
272
|
+
alias self.rmdir self.delete
|
273
|
+
|
274
|
+
# Deletes the named directory. Raises a subclass of SystemCallError if the
|
275
|
+
# directory isn't empty.
|
276
|
+
#
|
277
|
+
alias self.unlink self.delete
|
278
|
+
|
279
|
+
public
|
280
|
+
|
281
|
+
# Returns an array containing all of the filenames except for "." and ".." in
|
282
|
+
# this directory.
|
283
|
+
#
|
284
|
+
# d = Dir.new("testdir")
|
285
|
+
# d.children #=> ["config.h", "main.rb"]
|
286
|
+
#
|
287
|
+
def children: () -> Array[String]
|
288
|
+
|
289
|
+
# Closes the directory stream. Calling this method on closed Dir object is
|
290
|
+
# ignored since Ruby 2.3.
|
291
|
+
#
|
292
|
+
# d = Dir.new("testdir")
|
293
|
+
# d.close #=> nil
|
294
|
+
#
|
295
|
+
def close: () -> void
|
296
|
+
|
297
|
+
# Calls the block once for each entry in this directory, passing the filename of
|
298
|
+
# each entry as a parameter to the block.
|
299
|
+
#
|
300
|
+
# If no block is given, an enumerator is returned instead.
|
301
|
+
#
|
302
|
+
# d = Dir.new("testdir")
|
303
|
+
# d.each {|x| puts "Got #{x}" }
|
304
|
+
#
|
305
|
+
# *produces:*
|
306
|
+
#
|
307
|
+
# Got .
|
308
|
+
# Got ..
|
309
|
+
# Got config.h
|
310
|
+
# Got main.rb
|
311
|
+
#
|
312
|
+
def each: () { (String) -> void } -> self
|
313
|
+
| () -> ::Enumerator[String, self]
|
314
|
+
|
315
|
+
# Calls the block once for each entry except for "." and ".." in this directory,
|
316
|
+
# passing the filename of each entry as a parameter to the block.
|
317
|
+
#
|
318
|
+
# If no block is given, an enumerator is returned instead.
|
319
|
+
#
|
320
|
+
# d = Dir.new("testdir")
|
321
|
+
# d.each_child {|x| puts "Got #{x}" }
|
322
|
+
#
|
323
|
+
# *produces:*
|
324
|
+
#
|
325
|
+
# Got config.h
|
326
|
+
# Got main.rb
|
327
|
+
#
|
328
|
+
def each_child: () { (String) -> void } -> self
|
329
|
+
| () -> ::Enumerator[String, self]
|
330
|
+
|
331
|
+
# Returns the file descriptor used in *dir*.
|
332
|
+
#
|
333
|
+
# d = Dir.new("..")
|
334
|
+
# d.fileno #=> 8
|
335
|
+
#
|
336
|
+
# This method uses dirfd() function defined by POSIX 2008. NotImplementedError
|
337
|
+
# is raised on other platforms, such as Windows, which doesn't provide the
|
338
|
+
# function.
|
339
|
+
#
|
340
|
+
def fileno: () -> Integer
|
341
|
+
|
342
|
+
# Return a string describing this Dir object.
|
343
|
+
#
|
344
|
+
def inspect: () -> String
|
345
|
+
|
346
|
+
# Returns the path parameter passed to *dir*'s constructor.
|
347
|
+
#
|
348
|
+
# d = Dir.new("..")
|
349
|
+
# d.path #=> ".."
|
350
|
+
#
|
351
|
+
def path: () -> String?
|
352
|
+
|
353
|
+
# Returns the current position in *dir*. See also Dir#seek.
|
354
|
+
#
|
355
|
+
# d = Dir.new("testdir")
|
356
|
+
# d.tell #=> 0
|
357
|
+
# d.read #=> "."
|
358
|
+
# d.tell #=> 12
|
359
|
+
#
|
360
|
+
def pos: () -> Integer
|
361
|
+
|
362
|
+
# Synonym for Dir#seek, but returns the position parameter.
|
363
|
+
#
|
364
|
+
# d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
|
365
|
+
# d.read #=> "."
|
366
|
+
# i = d.pos #=> 12
|
367
|
+
# d.read #=> ".."
|
368
|
+
# d.pos = i #=> 12
|
369
|
+
# d.read #=> ".."
|
370
|
+
#
|
371
|
+
def pos=: (Integer pos) -> Integer
|
372
|
+
|
373
|
+
# Reads the next entry from *dir* and returns it as a string. Returns `nil` at
|
374
|
+
# the end of the stream.
|
375
|
+
#
|
376
|
+
# d = Dir.new("testdir")
|
377
|
+
# d.read #=> "."
|
378
|
+
# d.read #=> ".."
|
379
|
+
# d.read #=> "config.h"
|
380
|
+
#
|
381
|
+
def read: () -> String?
|
382
|
+
|
383
|
+
# Repositions *dir* to the first entry.
|
384
|
+
#
|
385
|
+
# d = Dir.new("testdir")
|
386
|
+
# d.read #=> "."
|
387
|
+
# d.rewind #=> #<Dir:0x401b3fb0>
|
388
|
+
# d.read #=> "."
|
389
|
+
#
|
390
|
+
def rewind: () -> self
|
391
|
+
|
392
|
+
# Seeks to a particular location in *dir*. *integer* must be a value returned by
|
393
|
+
# Dir#tell.
|
394
|
+
#
|
395
|
+
# d = Dir.new("testdir") #=> #<Dir:0x401b3c40>
|
396
|
+
# d.read #=> "."
|
397
|
+
# i = d.tell #=> 12
|
398
|
+
# d.read #=> ".."
|
399
|
+
# d.seek(i) #=> #<Dir:0x401b3c40>
|
400
|
+
# d.read #=> ".."
|
401
|
+
#
|
402
|
+
def seek: (Integer) -> self
|
403
|
+
|
404
|
+
# Returns the current position in *dir*. See also Dir#seek.
|
405
|
+
#
|
406
|
+
# d = Dir.new("testdir")
|
407
|
+
# d.tell #=> 0
|
408
|
+
# d.read #=> "."
|
409
|
+
# d.tell #=> 12
|
410
|
+
#
|
411
|
+
def tell: () -> Integer
|
412
|
+
|
413
|
+
# Returns the path parameter passed to *dir*'s constructor.
|
414
|
+
#
|
415
|
+
# d = Dir.new("..")
|
416
|
+
# d.path #=> ".."
|
417
|
+
#
|
418
|
+
alias to_path path
|
419
|
+
end
|