rbs 1.0.0.pre → 1.0.3
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/workflows/ruby.yml +10 -4
- data/CHANGELOG.md +41 -6
- data/Gemfile +7 -2
- data/README.md +1 -1
- data/Rakefile +11 -4
- data/Steepfile +2 -1
- data/bin/annotate-with-rdoc +0 -4
- data/bin/test_runner.rb +4 -5
- data/core/encoding.rbs +1 -1
- data/core/file.rbs +4 -0
- data/core/io.rbs +81 -5
- data/core/kernel.rbs +56 -56
- data/core/module.rbs +43 -2
- data/core/unbound_method.rbs +16 -0
- data/docs/CONTRIBUTING.md +2 -2
- data/docs/stdlib.md +50 -12
- data/docs/syntax.md +0 -17
- data/goodcheck.yml +3 -3
- data/lib/rbs/ast/declarations.rb +0 -47
- data/lib/rbs/definition_builder.rb +102 -64
- data/lib/rbs/definition_builder/ancestor_builder.rb +52 -3
- data/lib/rbs/environment.rb +1 -7
- data/lib/rbs/environment_loader.rb +7 -3
- data/lib/rbs/errors.rb +22 -57
- data/lib/rbs/parser.rb +1003 -1027
- data/lib/rbs/parser.y +12 -21
- data/lib/rbs/prototype/rb.rb +18 -4
- data/lib/rbs/prototype/runtime.rb +30 -14
- data/lib/rbs/test/hook.rb +7 -6
- data/lib/rbs/test/setup_helper.rb +0 -1
- data/lib/rbs/types.rb +6 -2
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs/writer.rb +4 -3
- data/rbs.gemspec +1 -0
- data/sig/ancestor_builder.rbs +98 -0
- data/sig/declarations.rbs +4 -16
- data/sig/definition_builder.rbs +17 -71
- data/sig/errors.rbs +141 -2
- data/sig/method_builder.rbs +71 -0
- data/sig/substitution.rbs +3 -0
- data/sig/types.rbs +1 -15
- data/stdlib/csv/0/csv.rbs +3 -0
- data/stdlib/fileutils/0/fileutils.rbs +585 -0
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/prettyprint/0/prettyprint.rbs +366 -0
- data/stdlib/prime/0/prime.rbs +6 -0
- data/stdlib/securerandom/0/securerandom.rbs +2 -0
- data/stdlib/uri/0/common.rbs +1 -1
- metadata +10 -7
- data/core/data.rbs +0 -5
data/stdlib/csv/0/csv.rbs
CHANGED
@@ -160,6 +160,7 @@
|
|
160
160
|
#
|
161
161
|
class CSV < Object
|
162
162
|
include Enumerable[untyped]
|
163
|
+
extend Forwardable
|
163
164
|
|
164
165
|
# This method is intended as the primary interface for reading CSV files. You
|
165
166
|
# pass a `path` and any `options` you wish to set for the read. Each row of file
|
@@ -408,6 +409,7 @@ CSV::VERSION: String
|
|
408
409
|
#
|
409
410
|
class CSV::Row < Object
|
410
411
|
include Enumerable[untyped]
|
412
|
+
extend Forwardable
|
411
413
|
|
412
414
|
# If a two-element Array is provided, it is assumed to be a header and field and
|
413
415
|
# the pair is appended. A Hash works the same way with the key being the header
|
@@ -579,6 +581,7 @@ end
|
|
579
581
|
#
|
580
582
|
class CSV::Table[out Elem] < Object
|
581
583
|
include Enumerable[untyped]
|
584
|
+
extend Forwardable
|
582
585
|
|
583
586
|
# Constructs a new CSV::Table from `array_of_rows`, which are expected to be
|
584
587
|
# CSV::Row objects. All rows are assumed to have the same headers.
|
@@ -0,0 +1,585 @@
|
|
1
|
+
# # fileutils.rb
|
2
|
+
#
|
3
|
+
# Copyright (c) 2000-2007 Minero Aoki
|
4
|
+
#
|
5
|
+
# This program is free software. You can distribute/modify this program under
|
6
|
+
# the same terms of ruby.
|
7
|
+
#
|
8
|
+
# ## module FileUtils
|
9
|
+
#
|
10
|
+
# Namespace for several file utility methods for copying, moving, removing, etc.
|
11
|
+
#
|
12
|
+
# ### Module Functions
|
13
|
+
#
|
14
|
+
# require 'fileutils'
|
15
|
+
#
|
16
|
+
# FileUtils.cd(dir, **options)
|
17
|
+
# FileUtils.cd(dir, **options) {|dir| block }
|
18
|
+
# FileUtils.pwd()
|
19
|
+
# FileUtils.mkdir(dir, **options)
|
20
|
+
# FileUtils.mkdir(list, **options)
|
21
|
+
# FileUtils.mkdir_p(dir, **options)
|
22
|
+
# FileUtils.mkdir_p(list, **options)
|
23
|
+
# FileUtils.rmdir(dir, **options)
|
24
|
+
# FileUtils.rmdir(list, **options)
|
25
|
+
# FileUtils.ln(target, link, **options)
|
26
|
+
# FileUtils.ln(targets, dir, **options)
|
27
|
+
# FileUtils.ln_s(target, link, **options)
|
28
|
+
# FileUtils.ln_s(targets, dir, **options)
|
29
|
+
# FileUtils.ln_sf(target, link, **options)
|
30
|
+
# FileUtils.cp(src, dest, **options)
|
31
|
+
# FileUtils.cp(list, dir, **options)
|
32
|
+
# FileUtils.cp_r(src, dest, **options)
|
33
|
+
# FileUtils.cp_r(list, dir, **options)
|
34
|
+
# FileUtils.mv(src, dest, **options)
|
35
|
+
# FileUtils.mv(list, dir, **options)
|
36
|
+
# FileUtils.rm(list, **options)
|
37
|
+
# FileUtils.rm_r(list, **options)
|
38
|
+
# FileUtils.rm_rf(list, **options)
|
39
|
+
# FileUtils.install(src, dest, **options)
|
40
|
+
# FileUtils.chmod(mode, list, **options)
|
41
|
+
# FileUtils.chmod_R(mode, list, **options)
|
42
|
+
# FileUtils.chown(user, group, list, **options)
|
43
|
+
# FileUtils.chown_R(user, group, list, **options)
|
44
|
+
# FileUtils.touch(list, **options)
|
45
|
+
#
|
46
|
+
# Possible `options` are:
|
47
|
+
#
|
48
|
+
# `:force`
|
49
|
+
# : forced operation (rewrite files if exist, remove directories if not empty,
|
50
|
+
# etc.);
|
51
|
+
# `:verbose`
|
52
|
+
# : print command to be run, in bash syntax, before performing it;
|
53
|
+
# `:preserve`
|
54
|
+
# : preserve object's group, user and modification time on copying;
|
55
|
+
# `:noop`
|
56
|
+
# : no changes are made (usable in combination with `:verbose` which will
|
57
|
+
# print the command to run)
|
58
|
+
#
|
59
|
+
#
|
60
|
+
# Each method documents the options that it honours. See also ::commands,
|
61
|
+
# ::options and ::options_of methods to introspect which command have which
|
62
|
+
# options.
|
63
|
+
#
|
64
|
+
# All methods that have the concept of a "source" file or directory can take
|
65
|
+
# either one file or a list of files in that argument. See the method
|
66
|
+
# documentation for examples.
|
67
|
+
#
|
68
|
+
# There are some `low level' methods, which do not accept keyword arguments:
|
69
|
+
#
|
70
|
+
# FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
71
|
+
# FileUtils.copy_file(src, dest, preserve = false, dereference = true)
|
72
|
+
# FileUtils.copy_stream(srcstream, deststream)
|
73
|
+
# FileUtils.remove_entry(path, force = false)
|
74
|
+
# FileUtils.remove_entry_secure(path, force = false)
|
75
|
+
# FileUtils.remove_file(path, force = false)
|
76
|
+
# FileUtils.compare_file(path_a, path_b)
|
77
|
+
# FileUtils.compare_stream(stream_a, stream_b)
|
78
|
+
# FileUtils.uptodate?(file, cmp_list)
|
79
|
+
#
|
80
|
+
# ## module FileUtils::Verbose
|
81
|
+
#
|
82
|
+
# This module has all methods of FileUtils module, but it outputs messages
|
83
|
+
# before acting. This equates to passing the `:verbose` flag to methods in
|
84
|
+
# FileUtils.
|
85
|
+
#
|
86
|
+
# ## module FileUtils::NoWrite
|
87
|
+
#
|
88
|
+
# This module has all methods of FileUtils module, but never changes
|
89
|
+
# files/directories. This equates to passing the `:noop` flag to methods in
|
90
|
+
# FileUtils.
|
91
|
+
#
|
92
|
+
# ## module FileUtils::DryRun
|
93
|
+
#
|
94
|
+
# This module has all methods of FileUtils module, but never changes
|
95
|
+
# files/directories. This equates to passing the `:noop` and `:verbose` flags
|
96
|
+
# to methods in FileUtils.
|
97
|
+
#
|
98
|
+
module FileUtils
|
99
|
+
VERSION: String
|
100
|
+
|
101
|
+
type mode = Integer | String
|
102
|
+
|
103
|
+
type path = string | _ToPath
|
104
|
+
|
105
|
+
type pathlist = path | Array[path]
|
106
|
+
|
107
|
+
# Changes the current directory to the directory `dir`.
|
108
|
+
#
|
109
|
+
# If this method is called with block, resumes to the previous working directory
|
110
|
+
# after the block execution has finished.
|
111
|
+
#
|
112
|
+
# FileUtils.cd('/') # change directory
|
113
|
+
#
|
114
|
+
# FileUtils.cd('/', verbose: true) # change directory and report it
|
115
|
+
#
|
116
|
+
# FileUtils.cd('/') do # change directory
|
117
|
+
# # ... # do something
|
118
|
+
# end # return to original directory
|
119
|
+
#
|
120
|
+
def self?.cd: (path dir, ?verbose: boolish) -> void
|
121
|
+
| [X] (path dir, ?verbose: boolish) { (String) -> X } -> X
|
122
|
+
|
123
|
+
alias self.chdir self.cd
|
124
|
+
alias chdir cd
|
125
|
+
|
126
|
+
# Changes permission bits on the named files (in `list`) to the bit pattern
|
127
|
+
# represented by `mode`.
|
128
|
+
#
|
129
|
+
# `mode` is the symbolic and absolute mode can be used.
|
130
|
+
#
|
131
|
+
# Absolute mode is
|
132
|
+
# FileUtils.chmod 0755, 'somecommand'
|
133
|
+
# FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
|
134
|
+
# FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
|
135
|
+
#
|
136
|
+
# Symbolic mode is
|
137
|
+
# FileUtils.chmod "u=wrx,go=rx", 'somecommand'
|
138
|
+
# FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
|
139
|
+
# FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
|
140
|
+
#
|
141
|
+
# "a"
|
142
|
+
# : is user, group, other mask.
|
143
|
+
# "u"
|
144
|
+
# : is user's mask.
|
145
|
+
# "g"
|
146
|
+
# : is group's mask.
|
147
|
+
# "o"
|
148
|
+
# : is other's mask.
|
149
|
+
# "w"
|
150
|
+
# : is write permission.
|
151
|
+
# "r"
|
152
|
+
# : is read permission.
|
153
|
+
# "x"
|
154
|
+
# : is execute permission.
|
155
|
+
# "X"
|
156
|
+
# : is execute permission for directories only, must be used in conjunction
|
157
|
+
# with "+"
|
158
|
+
# "s"
|
159
|
+
# : is uid, gid.
|
160
|
+
# "t"
|
161
|
+
# : is sticky bit.
|
162
|
+
# "+"
|
163
|
+
# : is added to a class given the specified mode.
|
164
|
+
# "-"
|
165
|
+
# : Is removed from a given class given mode.
|
166
|
+
# "="
|
167
|
+
# : Is the exact nature of the class will be given a specified mode.
|
168
|
+
#
|
169
|
+
def self?.chmod: (mode mode, pathlist list, ?noop: boolish, ?verbose: boolish) -> void
|
170
|
+
|
171
|
+
# Changes permission bits on the named files (in `list`) to the bit pattern
|
172
|
+
# represented by `mode`.
|
173
|
+
#
|
174
|
+
# FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
|
175
|
+
# FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
|
176
|
+
#
|
177
|
+
def self?.chmod_R: (mode mode, pathlist list, ?noop: boolish, ?verbose: boolish, ?force: boolish) -> void
|
178
|
+
|
179
|
+
# Changes owner and group on the named files (in `list`) to the user `user` and
|
180
|
+
# the group `group`. `user` and `group` may be an ID (Integer/String) or a name
|
181
|
+
# (String). If `user` or `group` is nil, this method does not change the
|
182
|
+
# attribute.
|
183
|
+
#
|
184
|
+
# FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
|
185
|
+
# FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
|
186
|
+
#
|
187
|
+
def self?.chown: (String? user, String? group, pathlist list, ?noop: boolish, ?verbose: boolish) -> void
|
188
|
+
|
189
|
+
# Changes owner and group on the named files (in `list`) to the user `user` and
|
190
|
+
# the group `group` recursively. `user` and `group` may be an ID
|
191
|
+
# (Integer/String) or a name (String). If `user` or `group` is nil, this method
|
192
|
+
# does not change the attribute.
|
193
|
+
#
|
194
|
+
# FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
|
195
|
+
# FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
|
196
|
+
#
|
197
|
+
def self?.chown_R: (String? user, String? group, pathlist list, ?noop: boolish, ?verbose: boolish, ?force: boolish) -> void
|
198
|
+
|
199
|
+
# Returns an Array of methods names which have the option `opt`.
|
200
|
+
#
|
201
|
+
# p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
|
202
|
+
#
|
203
|
+
def self.collect_method: (Symbol opt) -> Array[String]
|
204
|
+
|
205
|
+
# Returns an Array of names of high-level methods that accept any keyword
|
206
|
+
# arguments.
|
207
|
+
#
|
208
|
+
# p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
|
209
|
+
#
|
210
|
+
def self.commands: () -> Array[String]
|
211
|
+
|
212
|
+
# Returns true if the contents of a file `a` and a file `b` are identical.
|
213
|
+
#
|
214
|
+
# FileUtils.compare_file('somefile', 'somefile') #=> true
|
215
|
+
# FileUtils.compare_file('/dev/null', '/dev/urandom') #=> false
|
216
|
+
#
|
217
|
+
def self?.compare_file: (path a, path b) -> bool
|
218
|
+
|
219
|
+
alias self.cmp self.compare_file
|
220
|
+
alias cmp compare_file
|
221
|
+
|
222
|
+
alias self.identical? self.compare_file
|
223
|
+
alias identical? compare_file
|
224
|
+
|
225
|
+
# Returns true if the contents of a stream `a` and `b` are identical.
|
226
|
+
#
|
227
|
+
def self?.compare_stream: (IO a, IO b) -> bool
|
228
|
+
|
229
|
+
# Copies a file system entry `src` to `dest`. If `src` is a directory, this
|
230
|
+
# method copies its contents recursively. This method preserves file types, c.f.
|
231
|
+
# symlink, directory... (FIFO, device files and etc. are not supported yet)
|
232
|
+
#
|
233
|
+
# Both of `src` and `dest` must be a path name. `src` must exist, `dest` must
|
234
|
+
# not exist.
|
235
|
+
#
|
236
|
+
# If `preserve` is true, this method preserves owner, group, and modified time.
|
237
|
+
# Permissions are copied regardless `preserve`.
|
238
|
+
#
|
239
|
+
# If `dereference_root` is true, this method dereference tree root.
|
240
|
+
#
|
241
|
+
# If `remove_destination` is true, this method removes each destination file
|
242
|
+
# before copy.
|
243
|
+
#
|
244
|
+
def self?.copy_entry: (path src, path dest, ?boolish preserve, ?boolish dereference_root, ?boolish remove_destination) -> void
|
245
|
+
|
246
|
+
# Copies file contents of `src` to `dest`. Both of `src` and `dest` must be a
|
247
|
+
# path name.
|
248
|
+
#
|
249
|
+
def self?.copy_file: (path src, path dest, ?boolish preserve, ?boolish dereference) -> void
|
250
|
+
|
251
|
+
# Copies stream `src` to `dest`. `src` must respond to #read(n) and `dest` must
|
252
|
+
# respond to #write(str).
|
253
|
+
#
|
254
|
+
def self?.copy_stream: (_Reader src, _Writer dest) -> void
|
255
|
+
|
256
|
+
# Copies a file content `src` to `dest`. If `dest` is a directory, copies `src`
|
257
|
+
# to `dest/src`.
|
258
|
+
#
|
259
|
+
# If `src` is a list of files, then `dest` must be a directory.
|
260
|
+
#
|
261
|
+
# FileUtils.cp 'eval.c', 'eval.c.org'
|
262
|
+
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
|
263
|
+
# FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
|
264
|
+
# FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
|
265
|
+
#
|
266
|
+
def self?.cp: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
267
|
+
|
268
|
+
alias self.copy self.cp
|
269
|
+
alias copy cp
|
270
|
+
|
271
|
+
# Hard link `src` to `dest`. If `src` is a directory, this method links all its
|
272
|
+
# contents recursively. If `dest` is a directory, links `src` to `dest/src`.
|
273
|
+
#
|
274
|
+
# `src` can be a list of files.
|
275
|
+
#
|
276
|
+
# If `dereference_root` is true, this method dereference tree root.
|
277
|
+
#
|
278
|
+
# If `remove_destination` is true, this method removes each destination file
|
279
|
+
# before copy.
|
280
|
+
#
|
281
|
+
# FileUtils.rm_r site_ruby + '/mylib', force: true
|
282
|
+
# FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
|
283
|
+
#
|
284
|
+
# # Examples of linking several files to target directory.
|
285
|
+
# FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
286
|
+
# FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
|
287
|
+
#
|
288
|
+
# # If you want to link all contents of a directory instead of the
|
289
|
+
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
290
|
+
# # use the following code.
|
291
|
+
# FileUtils.cp_lr 'src/.', 'dest' # cp_lr('src', 'dest') makes dest/src, but this doesn't.
|
292
|
+
#
|
293
|
+
def self?.cp_lr: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
|
294
|
+
|
295
|
+
# Copies `src` to `dest`. If `src` is a directory, this method copies all its
|
296
|
+
# contents recursively. If `dest` is a directory, copies `src` to `dest/src`.
|
297
|
+
#
|
298
|
+
# `src` can be a list of files.
|
299
|
+
#
|
300
|
+
# If `dereference_root` is true, this method dereference tree root.
|
301
|
+
#
|
302
|
+
# If `remove_destination` is true, this method removes each destination file
|
303
|
+
# before copy.
|
304
|
+
#
|
305
|
+
# # Installing Ruby library "mylib" under the site_ruby
|
306
|
+
# FileUtils.rm_r site_ruby + '/mylib', force: true
|
307
|
+
# FileUtils.cp_r 'lib/', site_ruby + '/mylib'
|
308
|
+
#
|
309
|
+
# # Examples of copying several files to target directory.
|
310
|
+
# FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
311
|
+
# FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
|
312
|
+
#
|
313
|
+
# # If you want to copy all contents of a directory instead of the
|
314
|
+
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
315
|
+
# # use following code.
|
316
|
+
# FileUtils.cp_r 'src/.', 'dest' # cp_r('src', 'dest') makes dest/src,
|
317
|
+
# # but this doesn't.
|
318
|
+
#
|
319
|
+
def self?.cp_r: (pathlist src, path dest, ?preserve: boolish, ?noop: boolish, ?verbose: boolish, ?dereference_root: boolish, ?remove_destination: boolish) -> void
|
320
|
+
|
321
|
+
# Returns true if the method `mid` have an option `opt`.
|
322
|
+
#
|
323
|
+
# p FileUtils.have_option?(:cp, :noop) #=> true
|
324
|
+
# p FileUtils.have_option?(:rm, :force) #=> true
|
325
|
+
# p FileUtils.have_option?(:rm, :preserve) #=> false
|
326
|
+
#
|
327
|
+
def self.have_option?: (Symbol mid, Symbol opt) -> bool
|
328
|
+
|
329
|
+
# If `src` is not same as `dest`, copies it and changes the permission mode to
|
330
|
+
# `mode`. If `dest` is a directory, destination is `dest`/`src`. This method
|
331
|
+
# removes destination before copy.
|
332
|
+
#
|
333
|
+
# FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
|
334
|
+
# FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
|
335
|
+
#
|
336
|
+
def self?.install: (path src, path dest, ?mode: mode?, ?owner: String?, ?group: String?, ?preserve: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
337
|
+
|
338
|
+
# Hard links a file system entry `src` to `dest`. If `src` is a directory, this
|
339
|
+
# method links its contents recursively.
|
340
|
+
#
|
341
|
+
# Both of `src` and `dest` must be a path name. `src` must exist, `dest` must
|
342
|
+
# not exist.
|
343
|
+
#
|
344
|
+
# If `dereference_root` is true, this method dereferences the tree root.
|
345
|
+
#
|
346
|
+
# If `remove_destination` is true, this method removes each destination file
|
347
|
+
# before copy.
|
348
|
+
#
|
349
|
+
def self?.link_entry: (path src, path dest, ?boolish dereference_root, ?boolish remove_destination) -> void
|
350
|
+
|
351
|
+
# In the first form, creates a hard link `link` which points to `target`. If
|
352
|
+
# `link` already exists, raises Errno::EEXIST. But if the `force` option is set,
|
353
|
+
# overwrites `link`.
|
354
|
+
#
|
355
|
+
# FileUtils.ln 'gcc', 'cc', verbose: true
|
356
|
+
# FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
|
357
|
+
#
|
358
|
+
# In the second form, creates a link `dir/target` pointing to `target`. In the
|
359
|
+
# third form, creates several hard links in the directory `dir`, pointing to
|
360
|
+
# each item in `targets`. If `dir` is not a directory, raises Errno::ENOTDIR.
|
361
|
+
#
|
362
|
+
# FileUtils.cd '/sbin'
|
363
|
+
# FileUtils.ln %w(cp mv mkdir), '/bin' # Now /sbin/cp and /bin/cp are linked.
|
364
|
+
#
|
365
|
+
def self?.ln: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
366
|
+
|
367
|
+
alias self.link self.ln
|
368
|
+
alias link ln
|
369
|
+
|
370
|
+
# In the first form, creates a symbolic link `link` which points to `target`. If
|
371
|
+
# `link` already exists, raises Errno::EEXIST. But if the `force` option is set,
|
372
|
+
# overwrites `link`.
|
373
|
+
#
|
374
|
+
# FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
|
375
|
+
# FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
|
376
|
+
#
|
377
|
+
# In the second form, creates a link `dir/target` pointing to `target`. In the
|
378
|
+
# third form, creates several symbolic links in the directory `dir`, pointing to
|
379
|
+
# each item in `targets`. If `dir` is not a directory, raises Errno::ENOTDIR.
|
380
|
+
#
|
381
|
+
# FileUtils.ln_s Dir.glob('/bin/*.rb'), '/home/foo/bin'
|
382
|
+
#
|
383
|
+
def self?.ln_s: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
384
|
+
|
385
|
+
alias self.symlink self.ln_s
|
386
|
+
alias symlink ln_s
|
387
|
+
|
388
|
+
# Same as
|
389
|
+
#
|
390
|
+
# FileUtils.ln_s(*args, force: true)
|
391
|
+
#
|
392
|
+
def self?.ln_sf: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish) -> void
|
393
|
+
|
394
|
+
# Creates one or more directories.
|
395
|
+
#
|
396
|
+
# FileUtils.mkdir 'test'
|
397
|
+
# FileUtils.mkdir %w(tmp data)
|
398
|
+
# FileUtils.mkdir 'notexist', noop: true # Does not really create.
|
399
|
+
# FileUtils.mkdir 'tmp', mode: 0700
|
400
|
+
#
|
401
|
+
def self?.mkdir: (pathlist list, ?mode: Integer?, ?noop: boolish, ?verbose: boolish) -> void
|
402
|
+
|
403
|
+
# Creates a directory and all its parent directories. For example,
|
404
|
+
#
|
405
|
+
# FileUtils.mkdir_p '/usr/local/lib/ruby'
|
406
|
+
#
|
407
|
+
# causes to make following directories, if they do not exist.
|
408
|
+
#
|
409
|
+
# * /usr
|
410
|
+
# * /usr/local
|
411
|
+
# * /usr/local/lib
|
412
|
+
# * /usr/local/lib/ruby
|
413
|
+
#
|
414
|
+
#
|
415
|
+
# You can pass several directories at a time in a list.
|
416
|
+
#
|
417
|
+
def self?.mkdir_p: (pathlist list, ?mode: mode?, ?noop: boolish, ?verbose: boolish) -> void
|
418
|
+
|
419
|
+
alias self.makedirs self.mkdir_p
|
420
|
+
alias makedirs mkdir_p
|
421
|
+
|
422
|
+
alias self.mkpath self.mkdir_p
|
423
|
+
alias mkpath mkdir_p
|
424
|
+
|
425
|
+
# Moves file(s) `src` to `dest`. If `file` and `dest` exist on the different
|
426
|
+
# disk partition, the file is copied then the original file is removed.
|
427
|
+
#
|
428
|
+
# FileUtils.mv 'badname.rb', 'goodname.rb'
|
429
|
+
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
|
430
|
+
#
|
431
|
+
# FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
|
432
|
+
# FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
|
433
|
+
#
|
434
|
+
def self?.mv: (pathlist src, path dest, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
|
435
|
+
|
436
|
+
alias self.move self.mv
|
437
|
+
alias move mv
|
438
|
+
|
439
|
+
# Returns an Array of option names.
|
440
|
+
#
|
441
|
+
# p FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
|
442
|
+
#
|
443
|
+
def self.options: () -> Array[String]
|
444
|
+
|
445
|
+
# Returns an Array of option names of the method `mid`.
|
446
|
+
#
|
447
|
+
# p FileUtils.options_of(:rm) #=> ["noop", "verbose", "force"]
|
448
|
+
#
|
449
|
+
def self.options_of: (Symbol mid) -> Array[String]
|
450
|
+
|
451
|
+
# Returns the name of the current directory.
|
452
|
+
#
|
453
|
+
def self?.pwd: () -> String
|
454
|
+
|
455
|
+
alias self.getwd self.pwd
|
456
|
+
alias getwd pwd
|
457
|
+
|
458
|
+
# Removes a directory `dir` and its contents recursively. This method ignores
|
459
|
+
# StandardError if `force` is true.
|
460
|
+
#
|
461
|
+
def self?.remove_dir: (path path, ?boolish force) -> void
|
462
|
+
|
463
|
+
# This method removes a file system entry `path`. `path` might be a regular
|
464
|
+
# file, a directory, or something. If `path` is a directory, remove it
|
465
|
+
# recursively.
|
466
|
+
#
|
467
|
+
# See also remove_entry_secure.
|
468
|
+
#
|
469
|
+
def self?.remove_entry: (path path, ?boolish force) -> void
|
470
|
+
|
471
|
+
# This method removes a file system entry `path`. `path` shall be a regular
|
472
|
+
# file, a directory, or something. If `path` is a directory, remove it
|
473
|
+
# recursively. This method is required to avoid TOCTTOU
|
474
|
+
# (time-of-check-to-time-of-use) local security vulnerability of rm_r. #rm_r
|
475
|
+
# causes security hole when:
|
476
|
+
#
|
477
|
+
# * Parent directory is world writable (including /tmp).
|
478
|
+
# * Removing directory tree includes world writable directory.
|
479
|
+
# * The system has symbolic link.
|
480
|
+
#
|
481
|
+
#
|
482
|
+
# To avoid this security hole, this method applies special preprocess. If `path`
|
483
|
+
# is a directory, this method chown(2) and chmod(2) all removing directories.
|
484
|
+
# This requires the current process is the owner of the removing whole directory
|
485
|
+
# tree, or is the super user (root).
|
486
|
+
#
|
487
|
+
# WARNING: You must ensure that **ALL** parent directories cannot be moved by
|
488
|
+
# other untrusted users. For example, parent directories should not be owned by
|
489
|
+
# untrusted users, and should not be world writable except when the sticky bit
|
490
|
+
# set.
|
491
|
+
#
|
492
|
+
# WARNING: Only the owner of the removing directory tree, or Unix super user
|
493
|
+
# (root) should invoke this method. Otherwise this method does not work.
|
494
|
+
#
|
495
|
+
# For details of this security vulnerability, see Perl's case:
|
496
|
+
#
|
497
|
+
# * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2005-0448
|
498
|
+
# * https://cve.mitre.org/cgi-bin/cvename.cgi?name=CAN-2004-0452
|
499
|
+
#
|
500
|
+
#
|
501
|
+
# For fileutils.rb, this vulnerability is reported in [ruby-dev:26100].
|
502
|
+
#
|
503
|
+
def self?.remove_entry_secure: (path path, ?boolish force) -> void
|
504
|
+
|
505
|
+
# Removes a file `path`. This method ignores StandardError if `force` is true.
|
506
|
+
#
|
507
|
+
def self?.remove_file: (path path, ?void force) -> void
|
508
|
+
|
509
|
+
# Remove file(s) specified in `list`. This method cannot remove directories.
|
510
|
+
# All StandardErrors are ignored when the :force option is set.
|
511
|
+
#
|
512
|
+
# FileUtils.rm %w( junk.txt dust.txt )
|
513
|
+
# FileUtils.rm Dir.glob('*.so')
|
514
|
+
# FileUtils.rm 'NotExistFile', force: true # never raises exception
|
515
|
+
#
|
516
|
+
def self?.rm: (pathlist list, ?force: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
517
|
+
|
518
|
+
alias self.remove self.rm
|
519
|
+
alias remove rm
|
520
|
+
|
521
|
+
# Equivalent to
|
522
|
+
#
|
523
|
+
# FileUtils.rm(list, force: true)
|
524
|
+
#
|
525
|
+
def self?.rm_f: (pathlist list, ?noop: boolish, ?verbose: boolish) -> void
|
526
|
+
|
527
|
+
alias self.safe_unlink self.rm_f
|
528
|
+
alias safe_unlink rm_f
|
529
|
+
|
530
|
+
# remove files `list[0]` `list[1]`... If `list[n]` is a directory, removes its
|
531
|
+
# all contents recursively. This method ignores StandardError when :force option
|
532
|
+
# is set.
|
533
|
+
#
|
534
|
+
# FileUtils.rm_r Dir.glob('/tmp/*')
|
535
|
+
# FileUtils.rm_r 'some_dir', force: true
|
536
|
+
#
|
537
|
+
# WARNING: This method causes local vulnerability if one of parent directories
|
538
|
+
# or removing directory tree are world writable (including /tmp, whose
|
539
|
+
# permission is 1777), and the current process has strong privilege such as Unix
|
540
|
+
# super user (root), and the system has symbolic link. For secure removing,
|
541
|
+
# read the documentation of remove_entry_secure carefully, and set :secure
|
542
|
+
# option to true. Default is `secure: false`.
|
543
|
+
#
|
544
|
+
# NOTE: This method calls remove_entry_secure if :secure option is set. See also
|
545
|
+
# remove_entry_secure.
|
546
|
+
#
|
547
|
+
def self?.rm_r: (pathlist list, ?force: boolish, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
|
548
|
+
|
549
|
+
# Equivalent to
|
550
|
+
#
|
551
|
+
# FileUtils.rm_r(list, force: true)
|
552
|
+
#
|
553
|
+
# WARNING: This method causes local vulnerability. Read the documentation of
|
554
|
+
# rm_r first.
|
555
|
+
#
|
556
|
+
def self?.rm_rf: (pathlist list, ?noop: boolish, ?verbose: boolish, ?secure: boolish) -> void
|
557
|
+
|
558
|
+
alias self.rmtree self.rm_rf
|
559
|
+
alias rmtree rm_rf
|
560
|
+
|
561
|
+
# Removes one or more directories.
|
562
|
+
#
|
563
|
+
# FileUtils.rmdir 'somedir'
|
564
|
+
# FileUtils.rmdir %w(somedir anydir otherdir)
|
565
|
+
# # Does not really remove directory; outputs message.
|
566
|
+
# FileUtils.rmdir 'somedir', verbose: true, noop: true
|
567
|
+
#
|
568
|
+
def self?.rmdir: (pathlist list, ?parents: boolish, ?noop: boolish, ?verbose: boolish) -> void
|
569
|
+
|
570
|
+
# Updates modification time (mtime) and access time (atime) of file(s) in
|
571
|
+
# `list`. Files are created if they don't exist.
|
572
|
+
#
|
573
|
+
# FileUtils.touch 'timestamp'
|
574
|
+
# FileUtils.touch Dir.glob('*.c'); system 'make'
|
575
|
+
#
|
576
|
+
def self?.touch: (pathlist list, ?noop: boolish, ?verbose: boolish, ?mtime: (Time | Numeric)?, ?nocreate: boolish) -> void
|
577
|
+
|
578
|
+
# Returns true if `new` is newer than all `old_list`. Non-existent files are
|
579
|
+
# older than any file.
|
580
|
+
#
|
581
|
+
# FileUtils.uptodate?('hello.o', %w(hello.c hello.h)) or \
|
582
|
+
# system 'make hello.o'
|
583
|
+
#
|
584
|
+
def self?.uptodate?: (path new, pathlist old_list) -> bool
|
585
|
+
end
|