Method: Shell::CommandProcessor.def_builtin_commands
- Defined in:
- lib/shell/command-processor.rb
.def_builtin_commands(delegation_class, command_specs) ⇒ Object
:nodoc:
Delegates File and FileTest methods into Shell, including the following commands:
-
Shell#blockdev?(file)
-
Shell#chardev?(file)
-
Shell#directory?(file)
-
Shell#executable?(file)
-
Shell#executable_real?(file)
-
Shell#exist?(file)/Shell#exists?(file)
-
Shell#file?(file)
-
Shell#grpowned?(file)
-
Shell#owned?(file)
-
Shell#pipe?(file)
-
Shell#readable?(file)
-
Shell#readable_real?(file)
-
Shell#setgid?(file)
-
Shell#setuid?(file)
-
Shell#size(file)/Shell#size?(file)
-
Shell#socket?(file)
-
Shell#sticky?(file)
-
Shell#symlink?(file)
-
Shell#writable?(file)
-
Shell#writable_real?(file)
-
Shell#zero?(file)
-
Shell#syscopy(filename_from, filename_to)
-
Shell#copy(filename_from, filename_to)
-
Shell#move(filename_from, filename_to)
-
Shell#compare(filename_from, filename_to)
-
Shell#safe_unlink(*filenames)
-
Shell#makedirs(*filenames)
-
Shell#install(filename_from, filename_to, mode)
And also, there are some aliases for convenience:
-
Shell#cmp <- Shell#compare
-
Shell#mv <- Shell#move
-
Shell#cp <- Shell#copy
-
Shell#rm_f <- Shell#safe_unlink
-
Shell#mkpath <- Shell#makedirs
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 |
# File 'lib/shell/command-processor.rb', line 517 def self.def_builtin_commands(delegation_class, command_specs) for meth, args in command_specs arg_str = args.collect{|arg| arg.downcase}.join(", ") call_arg_str = args.collect{ |arg| case arg when /^(FILENAME.*)$/ format("expand_path(%s)", $1.downcase) when /^(\*FILENAME.*)$/ # \*FILENAME* -> filenames.collect{|fn| expand_path(fn)}.join(", ") $1.downcase + '.collect{|fn| expand_path(fn)}' else arg end }.join(", ") d = %Q[def #{meth}(#{arg_str}) #{delegation_class}.#{meth}(#{call_arg_str}) end] Shell.notify "Define #{meth}(#{arg_str})", Shell.debug? Shell.notify("Definition of #{meth}: ", d, Shell.debug.kind_of?(Integer) && Shell.debug > 1) eval d end end |