module RSpec::Core::RubyProject

Public Class Methods

add_dir_to_load_path(dir) click to toggle source
# File lib/rspec/core/ruby_project.rb, line 14
def add_dir_to_load_path(dir)
  $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
end
add_to_load_path(*dirs) click to toggle source
# File lib/rspec/core/ruby_project.rb, line 10
def add_to_load_path(*dirs)
  dirs.map {|dir| add_dir_to_load_path(File.join(root, dir))}
end
ascend_until() { |path| ... } click to toggle source
# File lib/rspec/core/ruby_project.rb, line 30
def ascend_until
  Pathname(File.expand_path('.')).ascend do |path|
    return path if yield(path)
  end
end
determine_root() click to toggle source
# File lib/rspec/core/ruby_project.rb, line 22
def determine_root
  find_first_parent_containing('spec') || '.'
end
find_first_parent_containing(dir) click to toggle source
# File lib/rspec/core/ruby_project.rb, line 26
def find_first_parent_containing(dir)
  ascend_until {|path| File.exists?(File.join(path, dir))}
end
root() click to toggle source
# File lib/rspec/core/ruby_project.rb, line 18
def root
  @project_root ||= determine_root
end

Private Instance Methods

add_dir_to_load_path(dir) click to toggle source
# File lib/rspec/core/ruby_project.rb, line 14
def add_dir_to_load_path(dir)
  $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
end
add_to_load_path(*dirs) click to toggle source
# File lib/rspec/core/ruby_project.rb, line 10
def add_to_load_path(*dirs)
  dirs.map {|dir| add_dir_to_load_path(File.join(root, dir))}
end
ascend_until() { |path| ... } click to toggle source
# File lib/rspec/core/ruby_project.rb, line 30
def ascend_until
  Pathname(File.expand_path('.')).ascend do |path|
    return path if yield(path)
  end
end
determine_root() click to toggle source
# File lib/rspec/core/ruby_project.rb, line 22
def determine_root
  find_first_parent_containing('spec') || '.'
end
find_first_parent_containing(dir) click to toggle source
# File lib/rspec/core/ruby_project.rb, line 26
def find_first_parent_containing(dir)
  ascend_until {|path| File.exists?(File.join(path, dir))}
end
root() click to toggle source
# File lib/rspec/core/ruby_project.rb, line 18
def root
  @project_root ||= determine_root
end