This a FileUtils extension that defines several additional commands to be added to the FileUtils utility functions.
Run a Ruby interpreter with the given arguments.
Example:
ruby %{-pe '$_.upcase!' <README}
# File lib/rake.rb, line 1024 1024: def ruby(*args,&block) 1025: options = (Hash === args.last) ? args.pop : {} 1026: if args.length > 1 then 1027: sh(*([RUBY] + args + [options]), &block) 1028: else 1029: sh("#{RUBY} #{args.first}", options, &block) 1030: end 1031: end
Attempt to do a normal file link, but fall back to a copy if the link fails.
# File lib/rake.rb, line 1037 1037: def safe_ln(*args) 1038: unless LN_SUPPORTED[0] 1039: cp(*args) 1040: else 1041: begin 1042: ln(*args) 1043: rescue StandardError, NotImplementedError => ex 1044: LN_SUPPORTED[0] = false 1045: cp(*args) 1046: end 1047: end 1048: end
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 988 988: def sh(*cmd, &block) 989: options = (Hash === cmd.last) ? cmd.pop : {} 990: unless block_given? 991: show_command = cmd.join(" ") 992: show_command = show_command[0,42] + "..." unless $trace 993: # TODO code application logic heref show_command.length > 45 994: block = lambda { |ok, status| 995: ok or fail "Command failed with status (#{status.exitstatus}): [#{show_command}]" 996: } 997: end 998: if RakeFileUtils.verbose_flag == :default 999: options[:verbose] = true 1000: else 1001: options[:verbose] ||= RakeFileUtils.verbose_flag 1002: end 1003: options[:noop] ||= RakeFileUtils.nowrite_flag 1004: rake_check_options options, :noop, :verbose 1005: rake_output_message cmd.join(" ") if options[:verbose] 1006: unless options[:noop] 1007: res = rake_system(*cmd) 1008: status = $? 1009: status = PseudoStatus.new(1) if !res && status.nil? 1010: block.call(res, status) 1011: end 1012: end
Split a file path into individual directory names.
Example:
split_all("a/b/c") => ['a', 'b', 'c']
# File lib/rake.rb, line 1055 1055: def split_all(path) 1056: head, tail = File.split(path) 1057: return [tail] if head == '.' || tail == '/' 1058: return [head, tail] if head == '/' 1059: return split_all(head) + [tail] 1060: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.