########################################################################### This a FileUtils extension that defines several additional commands to be added to the FileUtils utility functions.

Methods
Constants
RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']). sub(/.*\s.*/m, '"\&"')
LN_SUPPORTED = [true]
Public Instance methods
ruby(*args,&block)

Run a Ruby interpreter with the given arguments.

Example:

  ruby %{-pe '$_.upcase!' <README}
      # File lib/rake.rb, line 1002
1002:   def ruby(*args,&block)
1003:     options = (Hash === args.last) ? args.pop : {}
1004:     if args.length > 1 then
1005:       sh(*([RUBY] + args + [options]), &block)
1006:     else
1007:       sh("#{RUBY} #{args.first}", options, &block)
1008:     end
1009:   end
safe_ln(*args)

Attempt to do a normal file link, but fall back to a copy if the link fails.

      # File lib/rake.rb, line 1015
1015:   def safe_ln(*args)
1016:     unless LN_SUPPORTED[0]
1017:       cp(*args)
1018:     else
1019:       begin
1020:         ln(*args)
1021:       rescue StandardError, NotImplementedError => ex
1022:         LN_SUPPORTED[0] = false
1023:         cp(*args)
1024:       end
1025:     end
1026:   end
sh(*cmd, &block)

Run the system command cmd. If multiple arguments are given the command is not run with the shell (same semantics as Kernel::exec and Kernel::system).

Example:

  sh %{ls -ltr}

  sh 'ls', 'file with spaces'

  # check exit status after command runs
  sh %{grep pattern file} do |ok, res|
    if ! ok
      puts "pattern not found (status = #{res.exitstatus})"
    end
  end
     # File lib/rake.rb, line 964
964:   def sh(*cmd, &block)
965:     options = (Hash === cmd.last) ? cmd.pop : {}
966:     unless block_given?
967:       show_command = cmd.join(" ")
968:       show_command = show_command[0,42] + "..."
969:       # TODO code application logic heref show_command.length > 45
970:       block = lambda { |ok, status|
971:         ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]"
972:       }
973:     end
974:     if RakeFileUtils.verbose_flag == :default
975:       options[:verbose] = false
976:     else
977:       options[:verbose] ||= RakeFileUtils.verbose_flag
978:     end
979:     options[:noop]    ||= RakeFileUtils.nowrite_flag
980:     rake_check_options options, :noop, :verbose
981:     rake_output_message cmd.join(" ") if options[:verbose]
982:     unless options[:noop]
983:       res = rake_system(*cmd)
984:       block.call(res, $?)
985:     end
986:   end
split_all(path)

Split a file path into individual directory names.

Example:

  split_all("a/b/c") =>  ['a', 'b', 'c']
      # File lib/rake.rb, line 1033
1033:   def split_all(path)
1034:     head, tail = File.split(path)
1035:     return [tail] if head == '.' || tail == '/'
1036:     return [head, tail] if head == '/'
1037:     return split_all(head) + [tail]
1038:   end