Sha256: e51deac133bc6870ea2ec9828a14f81f1a8feb53555e962f716b12f280d27cf0
Contents?: true
Size: 1.09 KB
Versions: 34
Compression:
Stored size: 1.09 KB
Contents
# This is borrowed (slightly modified) from Scott Taylor's # project_path project: # http://github.com/smtlaissezfaire/project_path require 'pathname' module RSpec module Core # @private module RubyProject def add_to_load_path(*dirs) dirs.map { |dir| add_dir_to_load_path(File.join(root, dir)) } end def add_dir_to_load_path(dir) $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir) end def root @project_root ||= determine_root end def determine_root find_first_parent_containing('spec') || '.' end def find_first_parent_containing(dir) ascend_until { |path| File.exist?(File.join(path, dir)) } end def ascend_until Pathname(File.expand_path('.')).ascend do |path| return path if yield(path) end end module_function :add_to_load_path module_function :add_dir_to_load_path module_function :root module_function :determine_root module_function :find_first_parent_containing module_function :ascend_until end end end
Version data entries
34 entries across 31 versions & 8 rubygems