Module: Evilution::RailsDetector

Defined in:
lib/evilution/rails_detector.rb

Constant Summary collapse

MARKER =
File.join("config", "application.rb").freeze

Class Method Summary collapse

Class Method Details

.rails_root_for(path) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/evilution/rails_detector.rb', line 10

def rails_root_for(path)
  return nil if path.nil?

  dir = starting_dir(path)
  return nil if dir.nil?

  @mutex.synchronize do
    return @cache[dir] if @cache.key?(dir)

    @cache[dir] = walk_up(dir)
  end
end

.rails_root_for_any(paths) ⇒ Object



23
24
25
26
27
28
29
# File 'lib/evilution/rails_detector.rb', line 23

def rails_root_for_any(paths)
  Array(paths).each do |path|
    root = rails_root_for(path)
    return root if root
  end
  nil
end

.reset_cache!Object



31
32
33
# File 'lib/evilution/rails_detector.rb', line 31

def reset_cache!
  @mutex.synchronize { @cache.clear }
end