rbs 4.0.0.dev.5 → 4.0.1.dev.1
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/.clang-format +1 -0
- data/.github/workflows/c-check.yml +8 -4
- data/.github/workflows/comments.yml +3 -1
- data/.github/workflows/dependabot.yml +1 -1
- data/.github/workflows/ruby.yml +10 -0
- data/.github/workflows/rust.yml +95 -0
- data/CHANGELOG.md +323 -0
- data/Rakefile +12 -29
- data/Steepfile +1 -0
- data/config.yml +393 -37
- data/core/array.rbs +218 -188
- data/core/basic_object.rbs +9 -8
- data/core/class.rbs +6 -5
- data/core/comparable.rbs +45 -31
- data/core/complex.rbs +52 -40
- data/core/dir.rbs +57 -45
- data/core/encoding.rbs +5 -5
- data/core/enumerable.rbs +96 -91
- data/core/enumerator.rbs +4 -3
- data/core/errno.rbs +3 -2
- data/core/errors.rbs +31 -29
- data/core/exception.rbs +12 -12
- data/core/fiber.rbs +36 -36
- data/core/file.rbs +186 -113
- data/core/file_test.rbs +2 -2
- data/core/float.rbs +41 -32
- data/core/gc.rbs +78 -70
- data/core/hash.rbs +70 -60
- data/core/integer.rbs +32 -28
- data/core/io/buffer.rbs +36 -36
- data/core/io/wait.rbs +7 -7
- data/core/io.rbs +120 -135
- data/core/kernel.rbs +189 -139
- data/core/marshal.rbs +3 -3
- data/core/match_data.rbs +14 -12
- data/core/math.rbs +69 -67
- data/core/method.rbs +6 -6
- data/core/module.rbs +146 -85
- data/core/nil_class.rbs +4 -3
- data/core/numeric.rbs +35 -32
- data/core/object.rbs +6 -8
- data/core/object_space.rbs +11 -10
- data/core/pathname.rbs +131 -81
- data/core/proc.rbs +65 -33
- data/core/process.rbs +219 -201
- data/core/ractor.rbs +15 -11
- data/core/random.rbs +4 -3
- data/core/range.rbs +52 -47
- data/core/rational.rbs +5 -5
- data/core/rbs/unnamed/argf.rbs +58 -51
- data/core/rbs/unnamed/env_class.rbs +18 -13
- data/core/rbs/unnamed/main_class.rbs +123 -0
- data/core/rbs/unnamed/random.rbs +7 -5
- data/core/regexp.rbs +236 -197
- data/core/ruby.rbs +1 -1
- data/core/ruby_vm.rbs +32 -30
- data/core/rubygems/config_file.rbs +5 -5
- data/core/rubygems/errors.rbs +1 -1
- data/core/rubygems/requirement.rbs +5 -5
- data/core/rubygems/rubygems.rbs +5 -3
- data/core/set.rbs +17 -16
- data/core/signal.rbs +2 -2
- data/core/string.rbs +311 -292
- data/core/struct.rbs +26 -25
- data/core/symbol.rbs +25 -24
- data/core/thread.rbs +40 -34
- data/core/time.rbs +47 -42
- data/core/trace_point.rbs +34 -31
- data/core/true_class.rbs +2 -2
- data/core/unbound_method.rbs +10 -10
- data/core/warning.rbs +7 -7
- data/docs/collection.md +1 -1
- data/docs/config.md +171 -0
- data/docs/inline.md +110 -4
- data/docs/syntax.md +13 -12
- data/ext/rbs_extension/ast_translation.c +489 -135
- data/ext/rbs_extension/class_constants.c +8 -0
- data/ext/rbs_extension/class_constants.h +4 -0
- data/ext/rbs_extension/legacy_location.c +28 -51
- data/ext/rbs_extension/legacy_location.h +37 -0
- data/ext/rbs_extension/main.c +12 -20
- data/include/rbs/ast.h +423 -195
- data/include/rbs/lexer.h +2 -2
- data/include/rbs/location.h +25 -44
- data/include/rbs/parser.h +2 -2
- data/include/rbs/util/rbs_constant_pool.h +0 -3
- data/include/rbs.h +8 -0
- data/lib/rbs/ast/ruby/annotations.rb +157 -4
- data/lib/rbs/ast/ruby/members.rb +374 -22
- data/lib/rbs/cli/validate.rb +5 -60
- data/lib/rbs/collection/config/lockfile_generator.rb +6 -2
- data/lib/rbs/definition_builder.rb +60 -27
- data/lib/rbs/errors.rb +0 -11
- data/lib/rbs/inline_parser.rb +1 -1
- data/lib/rbs/parser_aux.rb +20 -7
- data/lib/rbs/prototype/helpers.rb +57 -0
- data/lib/rbs/prototype/rb.rb +1 -26
- data/lib/rbs/prototype/rbi.rb +1 -20
- data/lib/rbs/test/type_check.rb +3 -0
- data/lib/rbs/types.rb +62 -52
- data/lib/rbs/unit_test/type_assertions.rb +35 -8
- data/lib/rbs/version.rb +1 -1
- data/lib/rbs.rb +0 -1
- data/rbs.gemspec +1 -1
- data/rust/.gitignore +1 -0
- data/rust/Cargo.lock +378 -0
- data/rust/Cargo.toml +7 -0
- data/rust/ruby-rbs/Cargo.toml +22 -0
- data/rust/ruby-rbs/build.rs +764 -0
- data/rust/ruby-rbs/examples/locations.rs +60 -0
- data/rust/ruby-rbs/src/lib.rs +1 -0
- data/rust/ruby-rbs/src/node/mod.rs +742 -0
- data/rust/ruby-rbs/tests/sanity.rs +47 -0
- data/rust/ruby-rbs/vendor/rbs/config.yml +1 -0
- data/rust/ruby-rbs-sys/Cargo.toml +23 -0
- data/rust/ruby-rbs-sys/build.rs +204 -0
- data/rust/ruby-rbs-sys/src/lib.rs +50 -0
- data/rust/ruby-rbs-sys/vendor/rbs/include +1 -0
- data/rust/ruby-rbs-sys/vendor/rbs/src +1 -0
- data/rust/ruby-rbs-sys/wrapper.h +1 -0
- data/sig/ast/ruby/annotations.rbs +191 -4
- data/sig/ast/ruby/members.rbs +21 -1
- data/sig/cli/validate.rbs +1 -6
- data/sig/definition_builder.rbs +2 -0
- data/sig/errors.rbs +0 -8
- data/sig/method_types.rbs +1 -1
- data/sig/parser.rbs +17 -13
- data/sig/prototype/helpers.rbs +2 -0
- data/sig/types.rbs +10 -11
- data/sig/unit_test/spy.rbs +0 -8
- data/sig/unit_test/type_assertions.rbs +11 -0
- data/src/ast.c +339 -161
- data/src/lexstate.c +1 -1
- data/src/location.c +7 -47
- data/src/parser.c +674 -480
- data/src/util/rbs_constant_pool.c +0 -4
- data/stdlib/bigdecimal/0/big_decimal.rbs +16 -16
- data/stdlib/cgi-escape/0/escape.rbs +4 -4
- data/stdlib/coverage/0/coverage.rbs +4 -3
- data/stdlib/date/0/date.rbs +33 -28
- data/stdlib/date/0/date_time.rbs +24 -23
- data/stdlib/did_you_mean/0/did_you_mean.rbs +17 -16
- data/stdlib/erb/0/erb.rbs +64 -53
- data/stdlib/etc/0/etc.rbs +55 -50
- data/stdlib/fileutils/0/fileutils.rbs +138 -125
- data/stdlib/forwardable/0/forwardable.rbs +10 -10
- data/stdlib/io-console/0/io-console.rbs +2 -2
- data/stdlib/json/0/json.rbs +135 -108
- data/stdlib/monitor/0/monitor.rbs +3 -3
- data/stdlib/net-http/0/net-http.rbs +159 -134
- data/stdlib/objspace/0/objspace.rbs +8 -7
- data/stdlib/open-uri/0/open-uri.rbs +8 -8
- data/stdlib/open3/0/open3.rbs +36 -35
- data/stdlib/openssl/0/openssl.rbs +144 -129
- data/stdlib/optparse/0/optparse.rbs +18 -14
- data/stdlib/pathname/0/pathname.rbs +2 -2
- data/stdlib/pp/0/pp.rbs +9 -8
- data/stdlib/prettyprint/0/prettyprint.rbs +7 -7
- data/stdlib/pstore/0/pstore.rbs +35 -30
- data/stdlib/psych/0/psych.rbs +61 -8
- data/stdlib/psych/0/store.rbs +2 -4
- data/stdlib/pty/0/pty.rbs +9 -6
- data/stdlib/random-formatter/0/random-formatter.rbs +2 -2
- data/stdlib/ripper/0/ripper.rbs +20 -17
- data/stdlib/securerandom/0/securerandom.rbs +1 -1
- data/stdlib/shellwords/0/shellwords.rbs +2 -2
- data/stdlib/socket/0/addrinfo.rbs +7 -7
- data/stdlib/socket/0/basic_socket.rbs +3 -3
- data/stdlib/socket/0/ip_socket.rbs +10 -8
- data/stdlib/socket/0/socket.rbs +10 -9
- data/stdlib/socket/0/tcp_server.rbs +1 -1
- data/stdlib/socket/0/tcp_socket.rbs +1 -1
- data/stdlib/socket/0/udp_socket.rbs +1 -1
- data/stdlib/socket/0/unix_server.rbs +1 -1
- data/stdlib/stringio/0/stringio.rbs +55 -54
- data/stdlib/strscan/0/string_scanner.rbs +46 -44
- data/stdlib/tempfile/0/tempfile.rbs +24 -20
- data/stdlib/time/0/time.rbs +7 -5
- data/stdlib/tsort/0/tsort.rbs +7 -6
- data/stdlib/uri/0/common.rbs +26 -18
- data/stdlib/uri/0/file.rbs +2 -2
- data/stdlib/uri/0/generic.rbs +2 -2
- data/stdlib/uri/0/http.rbs +2 -2
- data/stdlib/uri/0/ldap.rbs +2 -2
- data/stdlib/uri/0/mailto.rbs +3 -3
- data/stdlib/uri/0/rfc2396_parser.rbs +6 -5
- data/stdlib/zlib/0/deflate.rbs +4 -3
- data/stdlib/zlib/0/gzip_reader.rbs +4 -4
- data/stdlib/zlib/0/gzip_writer.rbs +14 -12
- data/stdlib/zlib/0/inflate.rbs +1 -1
- data/stdlib/zlib/0/need_dict.rbs +1 -1
- metadata +23 -5
- data/.github/workflows/valgrind.yml +0 -42
|
@@ -95,8 +95,10 @@
|
|
|
95
95
|
# paths to filesystem entries:
|
|
96
96
|
#
|
|
97
97
|
# * If the argument is a string, that value is the path.
|
|
98
|
-
# * If the argument has method
|
|
99
|
-
#
|
|
98
|
+
# * If the argument has method <code>:to_path</code>, it is converted via that
|
|
99
|
+
# method.
|
|
100
|
+
# * If the argument has method <code>:to_str</code>, it is converted via that
|
|
101
|
+
# method.
|
|
100
102
|
#
|
|
101
103
|
# ## About the Examples
|
|
102
104
|
#
|
|
@@ -132,7 +134,7 @@
|
|
|
132
134
|
# TOCTTOU, vulnerability that can exist when:
|
|
133
135
|
#
|
|
134
136
|
# * An ancestor directory of the entry at the target path is world writable;
|
|
135
|
-
# such directories include
|
|
137
|
+
# such directories include <code>/tmp</code>.
|
|
136
138
|
# * The directory tree at the target path includes:
|
|
137
139
|
#
|
|
138
140
|
# * A world-writable descendant directory.
|
|
@@ -146,14 +148,14 @@
|
|
|
146
148
|
# Also available are these methods, each of which calls
|
|
147
149
|
# FileUtils.remove_entry_secure:
|
|
148
150
|
#
|
|
149
|
-
# * FileUtils.rm_r with keyword argument
|
|
150
|
-
# * FileUtils.rm_rf with keyword argument
|
|
151
|
+
# * FileUtils.rm_r with keyword argument <code>secure: true</code>.
|
|
152
|
+
# * FileUtils.rm_rf with keyword argument <code>secure: true</code>.
|
|
151
153
|
#
|
|
152
154
|
# Finally, this method for moving entries calls FileUtils.remove_entry_secure if
|
|
153
155
|
# the source and destination are on different file systems (which means that the
|
|
154
156
|
# "move" is really a copy and remove):
|
|
155
157
|
#
|
|
156
|
-
# * FileUtils.mv with keyword argument
|
|
158
|
+
# * FileUtils.mv with keyword argument <code>secure: true</code>.
|
|
157
159
|
#
|
|
158
160
|
# Method FileUtils.remove_entry_secure removes securely by applying a special
|
|
159
161
|
# pre-process:
|
|
@@ -214,7 +216,7 @@ module FileUtils
|
|
|
214
216
|
#
|
|
215
217
|
# Keyword arguments:
|
|
216
218
|
#
|
|
217
|
-
# *
|
|
219
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
218
220
|
#
|
|
219
221
|
# FileUtils.cd('..')
|
|
220
222
|
# FileUtils.cd('fileutils')
|
|
@@ -249,7 +251,7 @@ module FileUtils
|
|
|
249
251
|
# -->
|
|
250
252
|
# Changes permissions on the entries at the paths given in `list` (a single path
|
|
251
253
|
# or an array of paths) to the permissions given by `mode`; returns `list` if it
|
|
252
|
-
# is an array,
|
|
254
|
+
# is an array, <code>[list]</code> otherwise:
|
|
253
255
|
#
|
|
254
256
|
# * Modifies each entry that is a regular file using
|
|
255
257
|
# [File.chmod](rdoc-ref:File.chmod).
|
|
@@ -268,30 +270,33 @@ module FileUtils
|
|
|
268
270
|
#
|
|
269
271
|
# * String `mode`: represents the permissions to be set:
|
|
270
272
|
#
|
|
271
|
-
# The string is of the form
|
|
273
|
+
# The string is of the form
|
|
274
|
+
# <code>[targets][[operator][perms[,perms]]</code>, where:
|
|
272
275
|
#
|
|
273
276
|
# * `targets` may be any combination of these letters:
|
|
274
277
|
#
|
|
275
|
-
# *
|
|
276
|
-
# *
|
|
277
|
-
# *
|
|
278
|
-
#
|
|
278
|
+
# * <code>'u'</code>: permissions apply to the file's owner.
|
|
279
|
+
# * <code>'g'</code>: permissions apply to users in the file's group.
|
|
280
|
+
# * <code>'o'</code>: permissions apply to other users not in the
|
|
281
|
+
# file's group.
|
|
282
|
+
# * <code>'a'</code> (the default): permissions apply to all users.
|
|
279
283
|
#
|
|
280
284
|
# * `operator` may be one of these letters:
|
|
281
285
|
#
|
|
282
|
-
# *
|
|
283
|
-
# *
|
|
284
|
-
# *
|
|
286
|
+
# * <code>'+'</code>: adds permissions.
|
|
287
|
+
# * <code>'-'</code>: removes permissions.
|
|
288
|
+
# * <code>'='</code>: sets (replaces) permissions.
|
|
285
289
|
#
|
|
286
290
|
# * `perms` (may be repeated, with separating commas) may be any
|
|
287
291
|
# combination of these letters:
|
|
288
292
|
#
|
|
289
|
-
# *
|
|
290
|
-
# *
|
|
291
|
-
# *
|
|
292
|
-
# *
|
|
293
|
-
#
|
|
294
|
-
# *
|
|
293
|
+
# * <code>'r'</code>: Read.
|
|
294
|
+
# * <code>'w'</code>: Write.
|
|
295
|
+
# * <code>'x'</code>: Execute (search, for a directory).
|
|
296
|
+
# * <code>'X'</code>: Search (for a directories only; must be used
|
|
297
|
+
# with <code>'+'</code>)
|
|
298
|
+
# * <code>'s'</code>: Uid or gid.
|
|
299
|
+
# * <code>'t'</code>: Sticky bit.
|
|
295
300
|
#
|
|
296
301
|
# Examples:
|
|
297
302
|
#
|
|
@@ -300,8 +305,8 @@ module FileUtils
|
|
|
300
305
|
#
|
|
301
306
|
# Keyword arguments:
|
|
302
307
|
#
|
|
303
|
-
# *
|
|
304
|
-
# *
|
|
308
|
+
# * <code>noop: true</code> - does not change permissions; returns `nil`.
|
|
309
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
305
310
|
#
|
|
306
311
|
# FileUtils.chmod(0755, 'src0.txt', noop: true, verbose: true)
|
|
307
312
|
# FileUtils.chmod(0644, ['src0.txt', 'src0.dat'], noop: true, verbose: true)
|
|
@@ -333,7 +338,7 @@ module FileUtils
|
|
|
333
338
|
# -->
|
|
334
339
|
# Changes the owner and group on the entries at the paths given in `list` (a
|
|
335
340
|
# single path or an array of paths) to the given `user` and `group`; returns
|
|
336
|
-
# `list` if it is an array,
|
|
341
|
+
# `list` if it is an array, <code>[list]</code> otherwise:
|
|
337
342
|
#
|
|
338
343
|
# * Modifies each entry that is a regular file using
|
|
339
344
|
# [File.chown](rdoc-ref:File.chown).
|
|
@@ -345,10 +350,10 @@ module FileUtils
|
|
|
345
350
|
#
|
|
346
351
|
# User and group:
|
|
347
352
|
#
|
|
348
|
-
# * Argument `user` may be a user name or a user id; if `nil` or
|
|
349
|
-
# user is not changed.
|
|
350
|
-
# * Argument `group` may be a group name or a group id; if `nil` or
|
|
351
|
-
# group is not changed.
|
|
353
|
+
# * Argument `user` may be a user name or a user id; if `nil` or
|
|
354
|
+
# <code>-1</code>, the user is not changed.
|
|
355
|
+
# * Argument `group` may be a group name or a group id; if `nil` or
|
|
356
|
+
# <code>-1</code>, the group is not changed.
|
|
352
357
|
# * The user must be a member of the group.
|
|
353
358
|
#
|
|
354
359
|
# Examples:
|
|
@@ -374,8 +379,8 @@ module FileUtils
|
|
|
374
379
|
#
|
|
375
380
|
# Keyword arguments:
|
|
376
381
|
#
|
|
377
|
-
# *
|
|
378
|
-
# *
|
|
382
|
+
# * <code>noop: true</code> - does not change permissions; returns `nil`.
|
|
383
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
379
384
|
#
|
|
380
385
|
# FileUtils.chown('user2', 'group1', 'src0.txt', noop: true, verbose: true)
|
|
381
386
|
# FileUtils.chown(1004, 1004, 'src0.txt', noop: true, verbose: true)
|
|
@@ -591,7 +596,7 @@ module FileUtils
|
|
|
591
596
|
# File.file?('dest0.txt') # => true
|
|
592
597
|
#
|
|
593
598
|
# If `src` is the path to a file and `dest` is the path to a directory, copies
|
|
594
|
-
# `src` to
|
|
599
|
+
# `src` to <code>dest/src</code>:
|
|
595
600
|
#
|
|
596
601
|
# FileUtils.touch('src1.txt')
|
|
597
602
|
# FileUtils.mkdir('dest1')
|
|
@@ -610,9 +615,9 @@ module FileUtils
|
|
|
610
615
|
#
|
|
611
616
|
# Keyword arguments:
|
|
612
617
|
#
|
|
613
|
-
# *
|
|
614
|
-
# *
|
|
615
|
-
# *
|
|
618
|
+
# * <code>preserve: true</code> - preserves file times.
|
|
619
|
+
# * <code>noop: true</code> - does not copy files.
|
|
620
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
616
621
|
#
|
|
617
622
|
# FileUtils.cp('src0.txt', 'dest0.txt', noop: true, verbose: true)
|
|
618
623
|
# FileUtils.cp('src1.txt', 'dest1', noop: true, verbose: true)
|
|
@@ -675,8 +680,8 @@ module FileUtils
|
|
|
675
680
|
# # |-- src2.txt
|
|
676
681
|
# # `-- src3.txt
|
|
677
682
|
#
|
|
678
|
-
# If `src` and `dest` are both paths to directories, creates links
|
|
679
|
-
# and descendents pointing to `src` and its descendents:
|
|
683
|
+
# If `src` and `dest` are both paths to directories, creates links
|
|
684
|
+
# <code>dest/src</code> and descendents pointing to `src` and its descendents:
|
|
680
685
|
#
|
|
681
686
|
# tree('src1')
|
|
682
687
|
# # => src1
|
|
@@ -700,7 +705,7 @@ module FileUtils
|
|
|
700
705
|
#
|
|
701
706
|
# If `src` is an array of paths to entries and `dest` is the path to a
|
|
702
707
|
# directory, for each path `filepath` in `src`, creates a link at
|
|
703
|
-
#
|
|
708
|
+
# <code>dest/filepath</code> pointing to that path:
|
|
704
709
|
#
|
|
705
710
|
# tree('src2')
|
|
706
711
|
# # => src2
|
|
@@ -723,11 +728,12 @@ module FileUtils
|
|
|
723
728
|
#
|
|
724
729
|
# Keyword arguments:
|
|
725
730
|
#
|
|
726
|
-
# *
|
|
727
|
-
# dereference it.
|
|
728
|
-
# *
|
|
729
|
-
# *
|
|
730
|
-
#
|
|
731
|
+
# * <code>dereference_root: false</code> - if `src` is a symbolic link, does
|
|
732
|
+
# not dereference it.
|
|
733
|
+
# * <code>noop: true</code> - does not create links.
|
|
734
|
+
# * <code>remove_destination: true</code> - removes `dest` before creating
|
|
735
|
+
# links.
|
|
736
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
731
737
|
#
|
|
732
738
|
# FileUtils.cp_lr('src0', 'dest0', noop: true, verbose: true)
|
|
733
739
|
# FileUtils.cp_lr('src1', 'dest1', noop: true, verbose: true)
|
|
@@ -740,7 +746,7 @@ module FileUtils
|
|
|
740
746
|
# cp -lr src2/sub0 src2/sub1 dest2
|
|
741
747
|
#
|
|
742
748
|
# Raises an exception if `dest` is the path to an existing file or directory and
|
|
743
|
-
# keyword argument
|
|
749
|
+
# keyword argument <code>remove_destination: true</code> is not given.
|
|
744
750
|
#
|
|
745
751
|
# Related: [methods for copying](rdoc-ref:FileUtils@Copying).
|
|
746
752
|
#
|
|
@@ -767,7 +773,7 @@ module FileUtils
|
|
|
767
773
|
# File.file?('dest0.txt') # => true
|
|
768
774
|
#
|
|
769
775
|
# If `src` is the path to a file and `dest` is the path to a directory, copies
|
|
770
|
-
# `src` to
|
|
776
|
+
# `src` to <code>dest/src</code>:
|
|
771
777
|
#
|
|
772
778
|
# FileUtils.touch('src1.txt')
|
|
773
779
|
# FileUtils.mkdir('dest1')
|
|
@@ -797,7 +803,7 @@ module FileUtils
|
|
|
797
803
|
# # `-- src3.txt
|
|
798
804
|
#
|
|
799
805
|
# If `src` and `dest` are paths to directories, recursively copies `src` to
|
|
800
|
-
#
|
|
806
|
+
# <code>dest/src</code>:
|
|
801
807
|
#
|
|
802
808
|
# tree('src3')
|
|
803
809
|
# # => src3
|
|
@@ -825,12 +831,13 @@ module FileUtils
|
|
|
825
831
|
#
|
|
826
832
|
# Keyword arguments:
|
|
827
833
|
#
|
|
828
|
-
# *
|
|
829
|
-
# dereference it.
|
|
830
|
-
# *
|
|
831
|
-
# *
|
|
832
|
-
# *
|
|
833
|
-
#
|
|
834
|
+
# * <code>dereference_root: false</code> - if `src` is a symbolic link, does
|
|
835
|
+
# not dereference it.
|
|
836
|
+
# * <code>noop: true</code> - does not copy files.
|
|
837
|
+
# * <code>preserve: true</code> - preserves file times.
|
|
838
|
+
# * <code>remove_destination: true</code> - removes `dest` before copying
|
|
839
|
+
# files.
|
|
840
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
834
841
|
#
|
|
835
842
|
# FileUtils.cp_r('src0.txt', 'dest0.txt', noop: true, verbose: true)
|
|
836
843
|
# FileUtils.cp_r('src1.txt', 'dest1', noop: true, verbose: true)
|
|
@@ -887,8 +894,8 @@ module FileUtils
|
|
|
887
894
|
# FileUtils.install('src1.txt', 'dest1.txt')
|
|
888
895
|
# File.read('dest1.txt') # => "aaa\n"
|
|
889
896
|
#
|
|
890
|
-
# If `dest` is a directory entry, copies from `src` to
|
|
891
|
-
# if necessary:
|
|
897
|
+
# If `dest` is a directory entry, copies from `src` to <code>dest/src</code>,
|
|
898
|
+
# overwriting if necessary:
|
|
892
899
|
#
|
|
893
900
|
# File.read('src2.txt') # => "aaa\n"
|
|
894
901
|
# File.read('dest2/src2.txt') # => "bbb\n"
|
|
@@ -896,7 +903,7 @@ module FileUtils
|
|
|
896
903
|
# File.read('dest2/src2.txt') # => "aaa\n"
|
|
897
904
|
#
|
|
898
905
|
# If `src` is an array of paths and `dest` points to a directory, copies each
|
|
899
|
-
# path `path` in `src` to
|
|
906
|
+
# path `path` in `src` to <code>dest/path</code>:
|
|
900
907
|
#
|
|
901
908
|
# File.file?('src3.txt') # => true
|
|
902
909
|
# File.file?('src3.dat') # => true
|
|
@@ -907,16 +914,16 @@ module FileUtils
|
|
|
907
914
|
#
|
|
908
915
|
# Keyword arguments:
|
|
909
916
|
#
|
|
910
|
-
# *
|
|
917
|
+
# * <code>group: <i>group</i></code> - changes the group if not `nil`, using
|
|
911
918
|
# [File.chown](rdoc-ref:File.chown).
|
|
912
|
-
# *
|
|
919
|
+
# * <code>mode: <i>permissions</i></code> - changes the permissions. using
|
|
913
920
|
# [File.chmod](rdoc-ref:File.chmod).
|
|
914
|
-
# *
|
|
915
|
-
# *
|
|
921
|
+
# * <code>noop: true</code> - does not copy entries; returns `nil`.
|
|
922
|
+
# * <code>owner: <i>owner</i></code> - changes the owner if not `nil`, using
|
|
916
923
|
# [File.chown](rdoc-ref:File.chown).
|
|
917
|
-
# *
|
|
924
|
+
# * <code>preserve: true</code> - preserve timestamps using
|
|
918
925
|
# [File.utime](rdoc-ref:File.utime).
|
|
919
|
-
# *
|
|
926
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
920
927
|
#
|
|
921
928
|
# FileUtils.install('src0.txt', 'dest0.txt', noop: true, verbose: true)
|
|
922
929
|
# FileUtils.install('src1.txt', 'dest1.txt', noop: true, verbose: true)
|
|
@@ -1000,8 +1007,8 @@ module FileUtils
|
|
|
1000
1007
|
# Dir.children('tmp1/') # => ["t.lnk"]
|
|
1001
1008
|
#
|
|
1002
1009
|
# When `src` is the path to an existing file and `dest` is the path to an
|
|
1003
|
-
# existing directory, creates a hard link at
|
|
1004
|
-
# returns zero:
|
|
1010
|
+
# existing directory, creates a hard link at <code>dest/src</code> pointing to
|
|
1011
|
+
# `src`; returns zero:
|
|
1005
1012
|
#
|
|
1006
1013
|
# Dir.children('tmp2') # => ["t.dat"]
|
|
1007
1014
|
# Dir.children('tmp3') # => []
|
|
@@ -1010,7 +1017,7 @@ module FileUtils
|
|
|
1010
1017
|
#
|
|
1011
1018
|
# When `src` is an array of paths to existing files and `dest` is the path to an
|
|
1012
1019
|
# existing directory, then for each path `target` in `src`, creates a hard link
|
|
1013
|
-
# at
|
|
1020
|
+
# at <code>dest/target</code> pointing to `target`; returns `src`:
|
|
1014
1021
|
#
|
|
1015
1022
|
# Dir.children('tmp4/') # => []
|
|
1016
1023
|
# FileUtils.ln(['tmp0/t.txt', 'tmp2/t.dat'], 'tmp4/') # => ["tmp0/t.txt", "tmp2/t.dat"]
|
|
@@ -1018,9 +1025,9 @@ module FileUtils
|
|
|
1018
1025
|
#
|
|
1019
1026
|
# Keyword arguments:
|
|
1020
1027
|
#
|
|
1021
|
-
# *
|
|
1022
|
-
# *
|
|
1023
|
-
# *
|
|
1028
|
+
# * <code>force: true</code> - overwrites `dest` if it exists.
|
|
1029
|
+
# * <code>noop: true</code> - does not create links.
|
|
1030
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1024
1031
|
#
|
|
1025
1032
|
# FileUtils.ln('tmp0/t.txt', 'tmp1/t.lnk', verbose: true)
|
|
1026
1033
|
# FileUtils.ln('tmp2/t.dat', 'tmp3', verbose: true)
|
|
@@ -1073,8 +1080,8 @@ module FileUtils
|
|
|
1073
1080
|
# File.symlink?('dest0.txt') # => true
|
|
1074
1081
|
#
|
|
1075
1082
|
# * When `dest` is the path to an existing file, creates a symbolic link at
|
|
1076
|
-
# `dest` pointing to `src` if and only if keyword argument
|
|
1077
|
-
# given (raises an exception otherwise):
|
|
1083
|
+
# `dest` pointing to `src` if and only if keyword argument <code>force:
|
|
1084
|
+
# true</code> is given (raises an exception otherwise):
|
|
1078
1085
|
#
|
|
1079
1086
|
# FileUtils.touch('src1.txt')
|
|
1080
1087
|
# FileUtils.touch('dest1.txt')
|
|
@@ -1083,8 +1090,8 @@ module FileUtils
|
|
|
1083
1090
|
#
|
|
1084
1091
|
# FileUtils.ln_s('src1.txt', 'dest1.txt') # Raises Errno::EEXIST.
|
|
1085
1092
|
#
|
|
1086
|
-
# If `dest` is the path to a directory, creates a symbolic link at
|
|
1087
|
-
# pointing to `src`:
|
|
1093
|
+
# If `dest` is the path to a directory, creates a symbolic link at
|
|
1094
|
+
# <code>dest/src</code> pointing to `src`:
|
|
1088
1095
|
#
|
|
1089
1096
|
# FileUtils.touch('src2.txt')
|
|
1090
1097
|
# FileUtils.mkdir('destdir2')
|
|
@@ -1092,8 +1099,8 @@ module FileUtils
|
|
|
1092
1099
|
# File.symlink?('destdir2/src2.txt') # => true
|
|
1093
1100
|
#
|
|
1094
1101
|
# If `src` is an array of paths to existing files and `dest` is a directory, for
|
|
1095
|
-
# each child `child` in `src` creates a symbolic link
|
|
1096
|
-
# `child`:
|
|
1102
|
+
# each child `child` in `src` creates a symbolic link <code>dest/child</code>
|
|
1103
|
+
# pointing to `child`:
|
|
1097
1104
|
#
|
|
1098
1105
|
# FileUtils.mkdir('srcdir3')
|
|
1099
1106
|
# FileUtils.touch('srcdir3/src0.txt')
|
|
@@ -1105,10 +1112,10 @@ module FileUtils
|
|
|
1105
1112
|
#
|
|
1106
1113
|
# Keyword arguments:
|
|
1107
1114
|
#
|
|
1108
|
-
# *
|
|
1109
|
-
# *
|
|
1110
|
-
# *
|
|
1111
|
-
# *
|
|
1115
|
+
# * <code>force: true</code> - overwrites `dest` if it exists.
|
|
1116
|
+
# * <code>relative: false</code> - create links relative to `dest`.
|
|
1117
|
+
# * <code>noop: true</code> - does not create links.
|
|
1118
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1112
1119
|
#
|
|
1113
1120
|
# FileUtils.ln_s('src0.txt', 'dest0.txt', noop: true, verbose: true)
|
|
1114
1121
|
# FileUtils.ln_s('src1.txt', 'destdir1', noop: true, verbose: true)
|
|
@@ -1144,7 +1151,8 @@ module FileUtils
|
|
|
1144
1151
|
# rdoc-file=lib/fileutils.rb
|
|
1145
1152
|
# - ln_sf(src, dest, noop: nil, verbose: nil)
|
|
1146
1153
|
# -->
|
|
1147
|
-
# Like FileUtils.ln_s, but always with keyword argument
|
|
1154
|
+
# Like FileUtils.ln_s, but always with keyword argument <code>force: true</code>
|
|
1155
|
+
# given.
|
|
1148
1156
|
#
|
|
1149
1157
|
def self?.ln_sf: (pathlist src, path dest, ?noop: boolish, ?verbose: boolish) -> void
|
|
1150
1158
|
|
|
@@ -1161,23 +1169,25 @@ module FileUtils
|
|
|
1161
1169
|
# - mkdir(list, mode: nil, noop: nil, verbose: nil)
|
|
1162
1170
|
# -->
|
|
1163
1171
|
# Creates directories at the paths in the given `list` (a single path or an
|
|
1164
|
-
# array of paths); returns `list` if it is an array,
|
|
1172
|
+
# array of paths); returns `list` if it is an array, <code>[list]</code>
|
|
1173
|
+
# otherwise.
|
|
1165
1174
|
#
|
|
1166
1175
|
# Argument `list` or its elements should be [interpretable as
|
|
1167
1176
|
# paths](rdoc-ref:FileUtils@Path+Arguments).
|
|
1168
1177
|
#
|
|
1169
1178
|
# With no keyword arguments, creates a directory at each `path` in `list` by
|
|
1170
|
-
# calling:
|
|
1179
|
+
# calling: <code>Dir.mkdir(path, mode)</code>; see
|
|
1180
|
+
# [Dir.mkdir](rdoc-ref:Dir.mkdir):
|
|
1171
1181
|
#
|
|
1172
1182
|
# FileUtils.mkdir(%w[tmp0 tmp1]) # => ["tmp0", "tmp1"]
|
|
1173
1183
|
# FileUtils.mkdir('tmp4') # => ["tmp4"]
|
|
1174
1184
|
#
|
|
1175
1185
|
# Keyword arguments:
|
|
1176
1186
|
#
|
|
1177
|
-
# *
|
|
1178
|
-
# [File.chmod](rdoc-ref:File.chmod).
|
|
1179
|
-
# *
|
|
1180
|
-
# *
|
|
1187
|
+
# * <code>mode: <i>mode</i></code> - also calls <code>File.chmod(mode,
|
|
1188
|
+
# path)</code>; see [File.chmod](rdoc-ref:File.chmod).
|
|
1189
|
+
# * <code>noop: true</code> - does not create directories.
|
|
1190
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1181
1191
|
#
|
|
1182
1192
|
# FileUtils.mkdir(%w[tmp0 tmp1], verbose: true)
|
|
1183
1193
|
# FileUtils.mkdir(%w[tmp2 tmp3], mode: 0700, verbose: true)
|
|
@@ -1200,24 +1210,24 @@ module FileUtils
|
|
|
1200
1210
|
# -->
|
|
1201
1211
|
# Creates directories at the paths in the given `list` (a single path or an
|
|
1202
1212
|
# array of paths), also creating ancestor directories as needed; returns `list`
|
|
1203
|
-
# if it is an array,
|
|
1213
|
+
# if it is an array, <code>[list]</code> otherwise.
|
|
1204
1214
|
#
|
|
1205
1215
|
# Argument `list` or its elements should be [interpretable as
|
|
1206
1216
|
# paths](rdoc-ref:FileUtils@Path+Arguments).
|
|
1207
1217
|
#
|
|
1208
1218
|
# With no keyword arguments, creates a directory at each `path` in `list`, along
|
|
1209
|
-
# with any needed ancestor directories, by calling:
|
|
1210
|
-
# [Dir.mkdir](rdoc-ref:Dir.mkdir):
|
|
1219
|
+
# with any needed ancestor directories, by calling: <code>Dir.mkdir(path,
|
|
1220
|
+
# mode)</code>; see [Dir.mkdir](rdoc-ref:Dir.mkdir):
|
|
1211
1221
|
#
|
|
1212
1222
|
# FileUtils.mkdir_p(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"]
|
|
1213
1223
|
# FileUtils.mkdir_p('tmp4/tmp5') # => ["tmp4/tmp5"]
|
|
1214
1224
|
#
|
|
1215
1225
|
# Keyword arguments:
|
|
1216
1226
|
#
|
|
1217
|
-
# *
|
|
1218
|
-
# [File.chmod](rdoc-ref:File.chmod).
|
|
1219
|
-
# *
|
|
1220
|
-
# *
|
|
1227
|
+
# * <code>mode: <i>mode</i></code> - also calls <code>File.chmod(mode,
|
|
1228
|
+
# path)</code>; see [File.chmod](rdoc-ref:File.chmod).
|
|
1229
|
+
# * <code>noop: true</code> - does not create directories.
|
|
1230
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1221
1231
|
#
|
|
1222
1232
|
# FileUtils.mkdir_p(%w[tmp0 tmp1], verbose: true)
|
|
1223
1233
|
# FileUtils.mkdir_p(%w[tmp2 tmp3], mode: 0700, verbose: true)
|
|
@@ -1275,8 +1285,8 @@ module FileUtils
|
|
|
1275
1285
|
# If `src` and `dest` are on different file systems, first copies, then removes
|
|
1276
1286
|
# `src`.
|
|
1277
1287
|
#
|
|
1278
|
-
# May cause a local vulnerability if not called with keyword argument
|
|
1279
|
-
# true
|
|
1288
|
+
# May cause a local vulnerability if not called with keyword argument
|
|
1289
|
+
# <code>secure: true</code>; see [Avoiding the TOCTTOU
|
|
1280
1290
|
# Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
|
|
1281
1291
|
#
|
|
1282
1292
|
# If `src` is the path to a single file or directory and `dest` does not exist,
|
|
@@ -1313,13 +1323,13 @@ module FileUtils
|
|
|
1313
1323
|
#
|
|
1314
1324
|
# Keyword arguments:
|
|
1315
1325
|
#
|
|
1316
|
-
# *
|
|
1317
|
-
# `dest` are on different file systems), ignores raised
|
|
1318
|
-
# StandardError and its descendants.
|
|
1319
|
-
# *
|
|
1320
|
-
# *
|
|
1326
|
+
# * <code>force: true</code> - if the move includes removing `src` (that is,
|
|
1327
|
+
# if `src` and `dest` are on different file systems), ignores raised
|
|
1328
|
+
# exceptions of StandardError and its descendants.
|
|
1329
|
+
# * <code>noop: true</code> - does not move files.
|
|
1330
|
+
# * <code>secure: true</code> - removes `src` securely; see details at
|
|
1321
1331
|
# FileUtils.remove_entry_secure.
|
|
1322
|
-
# *
|
|
1332
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1323
1333
|
#
|
|
1324
1334
|
# FileUtils.mv('src0', 'dest0', noop: true, verbose: true)
|
|
1325
1335
|
# FileUtils.mv(['src1.txt', 'src1'], 'dest1', noop: true, verbose: true)
|
|
@@ -1470,7 +1480,7 @@ module FileUtils
|
|
|
1470
1480
|
# - rm(list, force: nil, noop: nil, verbose: nil)
|
|
1471
1481
|
# -->
|
|
1472
1482
|
# Removes entries at the paths in the given `list` (a single path or an array of
|
|
1473
|
-
# paths) returns `list`, if it is an array,
|
|
1483
|
+
# paths) returns `list`, if it is an array, <code>[list]</code> otherwise.
|
|
1474
1484
|
#
|
|
1475
1485
|
# Argument `list` or its elements should be [interpretable as
|
|
1476
1486
|
# paths](rdoc-ref:FileUtils@Path+Arguments).
|
|
@@ -1482,10 +1492,10 @@ module FileUtils
|
|
|
1482
1492
|
#
|
|
1483
1493
|
# Keyword arguments:
|
|
1484
1494
|
#
|
|
1485
|
-
# *
|
|
1486
|
-
# descendants.
|
|
1487
|
-
# *
|
|
1488
|
-
# *
|
|
1495
|
+
# * <code>force: true</code> - ignores raised exceptions of StandardError and
|
|
1496
|
+
# its descendants.
|
|
1497
|
+
# * <code>noop: true</code> - does not remove files; returns `nil`.
|
|
1498
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1489
1499
|
#
|
|
1490
1500
|
# FileUtils.rm(['src0.dat', 'src0.txt'], noop: true, verbose: true)
|
|
1491
1501
|
#
|
|
@@ -1547,13 +1557,13 @@ module FileUtils
|
|
|
1547
1557
|
# - rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
|
|
1548
1558
|
# -->
|
|
1549
1559
|
# Removes entries at the paths in the given `list` (a single path or an array of
|
|
1550
|
-
# paths); returns `list`, if it is an array,
|
|
1560
|
+
# paths); returns `list`, if it is an array, <code>[list]</code> otherwise.
|
|
1551
1561
|
#
|
|
1552
1562
|
# Argument `list` or its elements should be [interpretable as
|
|
1553
1563
|
# paths](rdoc-ref:FileUtils@Path+Arguments).
|
|
1554
1564
|
#
|
|
1555
|
-
# May cause a local vulnerability if not called with keyword argument
|
|
1556
|
-
# true
|
|
1565
|
+
# May cause a local vulnerability if not called with keyword argument
|
|
1566
|
+
# <code>secure: true</code>; see [Avoiding the TOCTTOU
|
|
1557
1567
|
# Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
|
|
1558
1568
|
#
|
|
1559
1569
|
# For each file path, removes the file at that path:
|
|
@@ -1578,12 +1588,12 @@ module FileUtils
|
|
|
1578
1588
|
#
|
|
1579
1589
|
# Keyword arguments:
|
|
1580
1590
|
#
|
|
1581
|
-
# *
|
|
1582
|
-
# descendants.
|
|
1583
|
-
# *
|
|
1584
|
-
# *
|
|
1591
|
+
# * <code>force: true</code> - ignores raised exceptions of StandardError and
|
|
1592
|
+
# its descendants.
|
|
1593
|
+
# * <code>noop: true</code> - does not remove entries; returns `nil`.
|
|
1594
|
+
# * <code>secure: true</code> - removes `src` securely; see details at
|
|
1585
1595
|
# FileUtils.remove_entry_secure.
|
|
1586
|
-
# *
|
|
1596
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1587
1597
|
#
|
|
1588
1598
|
# FileUtils.rm_r(['src0.dat', 'src0.txt'], noop: true, verbose: true)
|
|
1589
1599
|
# FileUtils.rm_r('src1', noop: true, verbose: true)
|
|
@@ -1608,8 +1618,8 @@ module FileUtils
|
|
|
1608
1618
|
# Argument `list` or its elements should be [interpretable as
|
|
1609
1619
|
# paths](rdoc-ref:FileUtils@Path+Arguments).
|
|
1610
1620
|
#
|
|
1611
|
-
# May cause a local vulnerability if not called with keyword argument
|
|
1612
|
-
# true
|
|
1621
|
+
# May cause a local vulnerability if not called with keyword argument
|
|
1622
|
+
# <code>secure: true</code>; see [Avoiding the TOCTTOU
|
|
1613
1623
|
# Vulnerability](rdoc-ref:FileUtils@Avoiding+the+TOCTTOU+Vulnerability).
|
|
1614
1624
|
#
|
|
1615
1625
|
# See FileUtils.rm_r for keyword arguments.
|
|
@@ -1637,22 +1647,24 @@ module FileUtils
|
|
|
1637
1647
|
# - rmdir(list, parents: nil, noop: nil, verbose: nil)
|
|
1638
1648
|
# -->
|
|
1639
1649
|
# Removes directories at the paths in the given `list` (a single path or an
|
|
1640
|
-
# array of paths); returns `list`, if it is an array,
|
|
1650
|
+
# array of paths); returns `list`, if it is an array, <code>[list]</code>
|
|
1651
|
+
# otherwise.
|
|
1641
1652
|
#
|
|
1642
1653
|
# Argument `list` or its elements should be [interpretable as
|
|
1643
1654
|
# paths](rdoc-ref:FileUtils@Path+Arguments).
|
|
1644
1655
|
#
|
|
1645
1656
|
# With no keyword arguments, removes the directory at each `path` in `list`, by
|
|
1646
|
-
# calling:
|
|
1657
|
+
# calling: <code>Dir.rmdir(path)</code>; see [Dir.rmdir](rdoc-ref:Dir.rmdir):
|
|
1647
1658
|
#
|
|
1648
1659
|
# FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3]) # => ["tmp0/tmp1", "tmp2/tmp3"]
|
|
1649
1660
|
# FileUtils.rmdir('tmp4/tmp5') # => ["tmp4/tmp5"]
|
|
1650
1661
|
#
|
|
1651
1662
|
# Keyword arguments:
|
|
1652
1663
|
#
|
|
1653
|
-
# *
|
|
1654
|
-
#
|
|
1655
|
-
# *
|
|
1664
|
+
# * <code>parents: true</code> - removes successive ancestor directories if
|
|
1665
|
+
# empty.
|
|
1666
|
+
# * <code>noop: true</code> - does not remove directories.
|
|
1667
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1656
1668
|
#
|
|
1657
1669
|
# FileUtils.rmdir(%w[tmp0/tmp1 tmp2/tmp3], parents: true, verbose: true)
|
|
1658
1670
|
# FileUtils.rmdir('tmp4/tmp5', parents: true, verbose: true)
|
|
@@ -1675,7 +1687,7 @@ module FileUtils
|
|
|
1675
1687
|
# -->
|
|
1676
1688
|
# Updates modification times (mtime) and access times (atime) of the entries
|
|
1677
1689
|
# given by the paths in `list` (a single path or an array of paths); returns
|
|
1678
|
-
# `list` if it is an array,
|
|
1690
|
+
# `list` if it is an array, <code>[list]</code> otherwise.
|
|
1679
1691
|
#
|
|
1680
1692
|
# By default, creates an empty file for any path to a non-existent entry; use
|
|
1681
1693
|
# keyword argument `nocreate` to raise an exception instead.
|
|
@@ -1699,11 +1711,12 @@ module FileUtils
|
|
|
1699
1711
|
#
|
|
1700
1712
|
# Keyword arguments:
|
|
1701
1713
|
#
|
|
1702
|
-
# *
|
|
1703
|
-
# current time.
|
|
1704
|
-
# *
|
|
1705
|
-
#
|
|
1706
|
-
# *
|
|
1714
|
+
# * <code>mtime: <i>time</i></code> - sets the entry's mtime to the given
|
|
1715
|
+
# time, instead of the current time.
|
|
1716
|
+
# * <code>nocreate: true</code> - raises an exception if the entry does not
|
|
1717
|
+
# exist.
|
|
1718
|
+
# * <code>noop: true</code> - does not touch entries; returns `nil`.
|
|
1719
|
+
# * <code>verbose: true</code> - prints an equivalent command:
|
|
1707
1720
|
#
|
|
1708
1721
|
# FileUtils.touch('src0.txt', noop: true, verbose: true)
|
|
1709
1722
|
# FileUtils.touch(['src0.txt', 'src0.dat'], noop: true, verbose: true)
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
# designated object, using the methods #def_delegator and #def_delegators.
|
|
4
4
|
#
|
|
5
5
|
# For example, say you have a class RecordCollection which contains an array
|
|
6
|
-
#
|
|
7
|
-
# simply calls #[] on the
|
|
6
|
+
# <code>@records</code>. You could provide the lookup method #record_number(),
|
|
7
|
+
# which simply calls #[] on the <code>@records</code> array, like this:
|
|
8
8
|
#
|
|
9
9
|
# require 'forwardable'
|
|
10
10
|
#
|
|
@@ -90,13 +90,13 @@
|
|
|
90
90
|
#
|
|
91
91
|
# Be advised, RDoc will not detect delegated methods.
|
|
92
92
|
#
|
|
93
|
-
#
|
|
94
|
-
# def_delegators methods. For full-class delegation via
|
|
95
|
-
#
|
|
93
|
+
# <code>forwardable.rb</code> provides single-method delegation via the
|
|
94
|
+
# def_delegator and def_delegators methods. For full-class delegation via
|
|
95
|
+
# DelegateClass, see <code>delegate.rb</code>.
|
|
96
96
|
#
|
|
97
97
|
module Forwardable
|
|
98
98
|
# <!-- rdoc-file=lib/forwardable.rb -->
|
|
99
|
-
# Version of
|
|
99
|
+
# Version of <code>forwardable.rb</code>
|
|
100
100
|
#
|
|
101
101
|
VERSION: String
|
|
102
102
|
|
|
@@ -151,10 +151,10 @@ module Forwardable
|
|
|
151
151
|
# - def_instance_delegator(accessor, method, ali = method)
|
|
152
152
|
# -->
|
|
153
153
|
# Define `method` as delegator instance method with an optional alias name
|
|
154
|
-
# `ali`. Method calls to `ali` will be delegated to
|
|
155
|
-
# `accessor` should be a method name, instance
|
|
156
|
-
# Use the full path to the constant if
|
|
157
|
-
# name of the method defined.
|
|
154
|
+
# `ali`. Method calls to `ali` will be delegated to
|
|
155
|
+
# <code>accessor.method</code>. `accessor` should be a method name, instance
|
|
156
|
+
# variable name, or constant name. Use the full path to the constant if
|
|
157
|
+
# providing the constant name. Returns the name of the method defined.
|
|
158
158
|
#
|
|
159
159
|
# class MyQueue
|
|
160
160
|
# CONST = 1
|