rbs 1.0.0 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +10 -4
  3. data/CHANGELOG.md +47 -0
  4. data/Gemfile +6 -2
  5. data/README.md +1 -1
  6. data/Rakefile +3 -4
  7. data/bin/test_runner.rb +4 -5
  8. data/core/array.rbs +2 -2
  9. data/core/complex.rbs +1 -1
  10. data/core/encoding.rbs +1 -1
  11. data/core/enumerable.rbs +15 -1
  12. data/core/file.rbs +3 -1
  13. data/core/integer.rbs +2 -1
  14. data/core/io.rbs +75 -4
  15. data/core/kernel.rbs +56 -56
  16. data/core/module.rbs +3 -3
  17. data/core/rational.rbs +2 -1
  18. data/core/string.rbs +2 -1
  19. data/core/symbol.rbs +2 -1
  20. data/core/time.rbs +2 -1
  21. data/core/unbound_method.rbs +16 -0
  22. data/docs/CONTRIBUTING.md +2 -2
  23. data/docs/stdlib.md +50 -12
  24. data/goodcheck.yml +1 -1
  25. data/lib/rbs/ast/members.rb +13 -0
  26. data/lib/rbs/definition_builder.rb +36 -25
  27. data/lib/rbs/definition_builder/method_builder.rb +9 -2
  28. data/lib/rbs/errors.rb +3 -0
  29. data/lib/rbs/parser.rb +347 -333
  30. data/lib/rbs/parser.y +12 -2
  31. data/lib/rbs/prototype/rb.rb +14 -4
  32. data/lib/rbs/test/setup_helper.rb +0 -1
  33. data/lib/rbs/version.rb +1 -1
  34. data/rbs.gemspec +1 -0
  35. data/sig/definition_builder.rbs +3 -2
  36. data/sig/members.rbs +2 -0
  37. data/stdlib/bigdecimal/0/big_decimal.rbs +1 -1
  38. data/stdlib/date/0/date.rbs +1 -1
  39. data/stdlib/fileutils/0/fileutils.rbs +585 -0
  40. data/stdlib/json/0/json.rbs +64 -0
  41. data/stdlib/pathname/0/pathname.rbs +3 -2
  42. data/stdlib/prettyprint/0/prettyprint.rbs +366 -0
  43. data/stdlib/set/0/set.rbs +7 -0
  44. data/stdlib/timeout/0/timeout.rbs +57 -0
  45. data/stdlib/uri/0/common.rbs +1 -1
  46. data/stdlib/uri/0/rfc2396_parser.rbs +144 -7
  47. data/steep/Gemfile.lock +17 -19
  48. metadata +7 -5
  49. data/core/data.rbs +0 -5
data/lib/rbs/parser.y CHANGED
@@ -611,7 +611,7 @@ rule
611
611
  }
612
612
 
613
613
  type_decl:
614
- annotations kTYPE qualified_name kEQ type {
614
+ annotations kTYPE type_alias_name kEQ type {
615
615
  location = val[1].location + val[4].location
616
616
  result = Declarations::Alias.new(name: val[2].value,
617
617
  type: val[4],
@@ -1037,6 +1037,16 @@ rule
1037
1037
  result = LocatedValue.new(value: type_name, location: location)
1038
1038
  }
1039
1039
 
1040
+ type_alias_name:
1041
+ namespace tLIDENT {
1042
+ namespace = val[0]&.value || Namespace.empty
1043
+ name = val[1].value.to_sym
1044
+ type_name = TypeName.new(namespace: namespace, name: name)
1045
+ location = (loc0 = val[0]&.location) ? loc0 + val[1].location : val[1].location
1046
+ result = LocatedValue.new(value: type_name, location: location)
1047
+ }
1048
+
1049
+
1040
1050
  namespace:
1041
1051
  {
1042
1052
  result = nil
@@ -1361,7 +1371,7 @@ def next_token
1361
1371
  new_token(:tWRITE_ATTR)
1362
1372
  when input.scan(KEYWORDS_RE)
1363
1373
  new_token(KEYWORDS[input.matched], input.matched.to_sym)
1364
- when input.scan(/:((@{,2}|\$)?\w+(\?|\!)?|\+|\-)\b?/)
1374
+ when input.scan(/:((@{,2}|\$)?\w+(\?|\!)?|[|&\/%~`^]|<=>|={2,3}|=~|[<>]{2}|[<>]=?|[-+]@?|\*{1,2}|\[\]=?|![=~]?)\b?/)
1365
1375
  s = input.matched.yield_self {|s| s[1, s.length] }.to_sym
1366
1376
  new_token(:tSYMBOL, s)
1367
1377
  when input.scan(/[+-]?\d[\d_]*/)
@@ -380,7 +380,7 @@ module RBS
380
380
  def function_type_from_body(node)
381
381
  table_node, args_node, *_ = node.children
382
382
 
383
- pre_num, _pre_init, opt, _first_post, post_num, _post_init, rest, kw, kwrest, _block = args_node.children
383
+ pre_num, _pre_init, opt, _first_post, post_num, _post_init, rest, kw, kwrest, _block = args_from_node(args_node)
384
384
 
385
385
  return_type = function_return_type_from_body(node)
386
386
 
@@ -400,7 +400,8 @@ module RBS
400
400
  end
401
401
 
402
402
  if rest
403
- fun = fun.update(rest_positionals: Types::Function::Param.new(name: rest, type: untyped))
403
+ rest_name = rest == :* ? nil : rest # # For `def f(...) end` syntax
404
+ fun = fun.update(rest_positionals: Types::Function::Param.new(name: rest_name, type: untyped))
404
405
  end
405
406
 
406
407
  table_node.drop(fun.required_positionals.size + fun.optional_positionals.size + (fun.rest_positionals ? 1 : 0)).take(post_num).each do |name|
@@ -559,13 +560,16 @@ module RBS
559
560
  def block_from_body(node)
560
561
  _, args_node, body_node = node.children
561
562
 
562
- _pre_num, _pre_init, _opt, _first_post, _post_num, _post_init, _rest, _kw, _kwrest, block = args_node.children
563
+ _pre_num, _pre_init, _opt, _first_post, _post_num, _post_init, _rest, _kw, _kwrest, block = args_from_node(args_node)
563
564
 
564
565
  method_block = nil
565
566
 
566
567
  if block
567
568
  method_block = Types::Block.new(
568
- required: true,
569
+ # HACK: The `block` is :& on `def m(...)` syntax.
570
+ # In this case the block looks optional in most cases, so it marks optional.
571
+ # In other cases, we can't determine which is required or optional, so it marks required.
572
+ required: block != :&,
569
573
  type: Types::Function.empty(untyped)
570
574
  )
571
575
  end
@@ -614,6 +618,12 @@ module RBS
614
618
  method_block
615
619
  end
616
620
 
621
+ # NOTE: args_node may be a nil by a bug
622
+ # https://bugs.ruby-lang.org/issues/17495
623
+ def args_from_node(args_node)
624
+ args_node&.children || [0, nil, nil, nil, 0, nil, nil, nil, nil, nil]
625
+ end
626
+
617
627
  def keyword_hash?(node)
618
628
  if node
619
629
  if node.type == :HASH
@@ -38,7 +38,6 @@ module RBS
38
38
  nil
39
39
  end
40
40
  end
41
-
42
41
  end
43
42
  end
44
43
  end
data/lib/rbs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module RBS
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.5"
3
3
  end
data/rbs.gemspec CHANGED
@@ -34,4 +34,5 @@ Gem::Specification.new do |spec|
34
34
  spec.bindir = "exe"
35
35
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
36
  spec.require_paths = ["lib"]
37
+ spec.required_ruby_version = ">= 2.6"
37
38
  end
@@ -5,7 +5,7 @@ module RBS
5
5
  attr_reader ancestor_builder: AncestorBuilder
6
6
  attr_reader method_builder: MethodBuilder
7
7
 
8
- attr_reader instance_cache: Hash[TypeName, Definition | false | nil]
8
+ attr_reader instance_cache: Hash[[TypeName, bool], Definition | false | nil]
9
9
  attr_reader singleton_cache: Hash[TypeName, Definition | false | nil]
10
10
  attr_reader singleton0_cache: Hash[TypeName, Definition | false | nil]
11
11
  attr_reader interface_cache: Hash[TypeName, Definition | false | nil]
@@ -18,7 +18,7 @@ module RBS
18
18
 
19
19
  def build_interface: (TypeName) -> Definition
20
20
 
21
- def build_instance: (TypeName) -> Definition
21
+ def build_instance: (TypeName, ?no_self_types: bool) -> Definition
22
22
 
23
23
  def build_singleton0: (TypeName) -> Definition
24
24
 
@@ -31,6 +31,7 @@ module RBS
31
31
  def merge_variable: (Hash[Symbol, Definition::Variable], Symbol, Definition::Variable, Substitution, ?keep_super: bool) -> void
32
32
 
33
33
  def try_cache: (TypeName, cache: Hash[TypeName, Definition | false | nil]) { () -> Definition } -> Definition
34
+ | [A] (TypeName, cache: Hash[A, Definition | false | nil], key: A) { () -> Definition } -> Definition
34
35
 
35
36
  def validate_params_with: (AST::Declarations::ModuleTypeParams, result: VarianceCalculator::Result) { (AST::Declarations::ModuleTypeParams::TypeParam) -> void } -> void
36
37
 
data/sig/members.rbs CHANGED
@@ -104,6 +104,8 @@ module RBS
104
104
  def initialize: (name: Symbol, type: Types::t, ivar_name: Symbol | false | nil, kind: kind, annotations: Array[Annotation], location: Location?, comment: Comment?) -> void
105
105
 
106
106
  include _HashEqual
107
+
108
+ def update: (?name: Symbol, ?type: Types::t, ?ivar_name: Symbol | false | nil, ?kind: kind, ?annotations: Array[Annotation], ?location: Location?, ?comment: Comment?) -> instance
107
109
  end
108
110
 
109
111
  class AttrReader < Base
@@ -321,7 +321,7 @@ class BigDecimal < Numeric
321
321
 
322
322
  # The comparison operator. a <=> b is 0 if a == b, 1 if a > b, -1 if a < b.
323
323
  #
324
- def <=>: (Numeric) -> Integer?
324
+ def <=>: (untyped) -> Integer?
325
325
 
326
326
  # Tests for value equality; returns true if the values are equal.
327
327
  #
@@ -496,7 +496,7 @@ class Date
496
496
  #
497
497
  # See also Comparable.
498
498
  #
499
- def <=>: (Date | Rational | Object other) -> Integer?
499
+ def <=>: (untyped other) -> Integer?
500
500
 
501
501
  # Returns true if they are the same day.
502
502
  #
@@ -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