def locate_ruby_tool(name, extensions = ['', CONFIG['EXEEXT']].compact.uniq)
      # Deduce Ruby's --program-prefix and --program-suffix from its install name
      # and transform the given input name accordingly.
      #
      #   "rake" => "jrake", "rake1.8", etc.
      [name, CONFIG['RUBY_INSTALL_NAME'].sub('ruby', name)].uniq.each { |basename|
        extensions.each { |ext|
          result = locate_ruby_tool_by_basename(basename + ext) and return result
        }
      }

      nil
    end
def locate_ruby_tool(name, extensions = ['', CONFIG['EXEEXT']].compact.uniq)
      # Deduce Ruby's --program-prefix and --program-suffix from its install name
      # and transform the given input name accordingly.
      #
      #   "rake" => "jrake", "rake1.8", etc.
      [name, CONFIG['RUBY_INSTALL_NAME'].sub('ruby', name)].uniq.each { |basename|
        extensions.each { |ext|
          result = locate_ruby_tool_by_basename(basename + ext) and return result
        }
      }

      nil
    end
Locates a Ruby tool command +name+, e.g. 'gem', 'rake', 'bundle', etc. Instead
 of naively looking in $PATH, this function uses a variety of search heuristics
 to find the command that's really associated with the current Ruby interpreter.
 It should never locate a command that's actually associated with a different
 Ruby interpreter.

 NOTE: The return value may not be the actual correct invocation for the tool.
 Use command_for_ruby_tool for that.

 Returns +nil+ when nothing's found.