Module: RSpec::Core::RubyProject

Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb

Class Method Summary collapse

Class Method Details

.add_dir_to_load_path(dir) ⇒ Object



12
13
14
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb', line 12

def add_dir_to_load_path(dir)
  $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include?(dir)
end

.add_to_load_path(*dirs) ⇒ Object



8
9
10
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb', line 8

def add_to_load_path(*dirs)
  dirs.each { |dir| add_dir_to_load_path(File.join(root, dir)) }
end

.ascend_untilObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb', line 28

def ascend_until
  fs = File::SEPARATOR
  escaped_slash = "\\#{fs}"
  special = "_RSPEC_ESCAPED_SLASH_"
  project_path = File.expand_path(".")
  parts = project_path.gsub(escaped_slash, special).squeeze(fs).split(fs).map do |x|
    x.gsub(special, escaped_slash)
  end

  until parts.empty?
    path = parts.join(fs)
    path = fs if path == ""
    return path if yield(path)
    parts.pop
  end
end

.determine_rootObject



20
21
22
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb', line 20

def determine_root
  find_first_parent_containing('spec') || '.'
end

.find_first_parent_containing(dir) ⇒ Object



24
25
26
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb', line 24

def find_first_parent_containing(dir)
  ascend_until { |path| File.exist?(File.join(path, dir)) }
end

.rootObject



16
17
18
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.12.0/lib/rspec/core/ruby_project.rb', line 16

def root
  @project_root ||= determine_root
end