summaryrefslogtreecommitdiff
path: root/lib/fileutils.rb
diff options
context:
space:
mode:
authorBurdette Lamar <[email protected]>2022-06-13 07:11:32 -0500
committergit <[email protected]>2022-06-13 21:11:45 +0900
commit753da6deca34eb7d5d61a26cf66b014ad77ad51d ()
tree6cb6e2767f40740d5b2863b9676e9779b398d74c /lib/fileutils.rb
parentb1397e96dacfed3dec3fb962e3b3ee9032ac137f (diff)
[ruby/fileutils] [DOC] Enhanced Rdoc (https://.com/ruby/fileutils/pull/84)
Treats: ::chown_R ::touch ::commands ::options ::have_option? ::options_of ::collect_method https://.com/ruby/fileutils/commit/5df0324f52
-rw-r--r--lib/fileutils.rb85
1 files changed, 54 insertions, 31 deletions
@@ -1705,15 +1705,7 @@ module FileUtils
end
module_function :chown
- #
- # Changes owner and group on the named files (in +list+)
- # to the user +user+ and the group +group+ recursively.
- # +user+ and +group+ may be an ID (Integer/String) or
- # a name (String). If +user+ or +group+ is nil, this
- # method does not change the attribute.
- #
- # FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
- # FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
#
def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
list = fu_list(list)
@@ -1764,12 +1756,44 @@ module FileUtils
end
private_module_function :fu_get_gid
#
- # Updates modification time (mtime) and access time (atime) of file(s) in
- # +list+. Files are created if they don't exist.
#
- # FileUtils.touch 'timestamp'
- # FileUtils.touch Dir.glob('*.c'); system 'make'
#
def touch(list, noop: nil, verbose: nil, mtime: nil, nocreate: nil)
list = fu_list(list)
@@ -2272,50 +2296,49 @@ module FileUtils
public
#
- # Returns an Array of names of high-level methods that accept any keyword
- # arguments.
- #
- # p FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
#
def self.commands
OPT_TABLE.keys
end
#
- # Returns an Array of option names.
- #
- # p FileUtils.options #=> ["noop", "force", "verbose", "preserve", "mode"]
#
def self.options
OPT_TABLE.values.flatten.uniq.map {|sym| sym.to_s }
end
#
- # Returns true if the method +mid+ have an option +opt+.
- #
- # p FileUtils.have_option?(:cp, :noop) #=> true
- # p FileUtils.have_option?(:rm, :force) #=> true
- # p FileUtils.have_option?(:rm, :preserve) #=> false
#
def self.have_option?(mid, opt)
li = OPT_TABLE[mid.to_s] or raise ArgumentError, "no such method: #{mid}"
li.include?(opt)
end
#
- # Returns an Array of option names of the method +mid+.
- #
- # p FileUtils.options_of(:rm) #=> ["noop", "verbose", "force"]
#
def self.options_of(mid)
OPT_TABLE[mid.to_s].map {|sym| sym.to_s }
end
#
- # Returns an Array of methods names which have the option +opt+.
- #
- # p FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
#
def self.collect_method(opt)
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }