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 suggested_thread_count # :nodoc:

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

def with_application(block_application = Rake::Application.new)

def with_application(block_application = Rake::Application.new)
  orig_application = Rake.application
  Rake.application = block_application
  yield block_application
  block_application
ensure
  Rake.application = orig_application
end