module Rake

def add_rakelib(*files)

Add files to the rakelib list
def add_rakelib(*files)
  application.options.rakelib ||= []
  application.options.rakelib.concat(files)
end

def application

Current Rake Application
def application
  @application ||= Rake::Application.new
end

def application=(app)

Set the current Rake application object.
def application=(app)
  @application = app
end

def each_dir_parent(dir) # :nodoc:

:nodoc:
Yield each file or directory component.
def each_dir_parent(dir)    # :nodoc:
  old_length = nil
  while dir != '.' && dir.length != old_length
    yield(dir)
    old_length = dir.length
    dir = File.dirname(dir)
  end
end

def from_pathname(path) # :nodoc:

:nodoc:
leave everything else alone
Convert Pathname and Pathname-like objects to strings;
def from_pathname(path)    # :nodoc:
  path = path.to_path if path.respond_to?(:to_path)
  path = path.to_str if path.respond_to?(:to_str)
  path
end

def load_rakefile(path)

Load a rakefile.
def load_rakefile(path)
  load(path)
end

def original_dir

Return the original directory where the Rake application was started.
def original_dir
  application.original_dir
end

def run_tests(pattern='test/test*.rb', log_enabled=false) # :nodoc:

:nodoc:
def run_tests(pattern='test/test*.rb', log_enabled=false) # :nodoc:
  FileList.glob(pattern).each do |fn|
    $stderr.puts fn if log_enabled
    begin
      require fn
    rescue Exception => ex
      $stderr.puts "Error in #{fn}: #{ex.message}"
      $stderr.puts ex.backtrace
      assert false
    end
  end
end

def suggested_thread_count # :nodoc:

:nodoc:
def suggested_thread_count # :nodoc:
  @cpu_count ||= Rake::CpuCounter.count
  @cpu_count + 4
end