Module: RareMap::RailsLocator
- Included in:
- Mapper
- Defined in:
- lib/rare_map/rails_locator.rb
Overview
RareMap::RailsLocator locates the root of a rails application from any where inside it.
Instance Method Summary collapse
-
#locate_rails_root(path = '.', depth = 5) ⇒ String?
Finds the root of a rails application.
Instance Method Details
#locate_rails_root(path = '.', depth = 5) ⇒ String?
Finds the root of a rails application.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rare_map/rails_locator.rb', line 11 def locate_rails_root(path = '.', depth = 5) rails_dirs = %w(app config db lib log public) depth.times do |level| found = true paths = [path] level.times { paths << '..' } rails_dirs.each do |dir| found = false unless Dir.exist? File.join(*(paths + [dir])) end return File.absolute_path(File.join(*paths)) if found end nil end |