module App::Root

– app root —————————————————————

Public Class Methods

find() click to toggle source
# File lib/radiospieler/radiospieler/root.rb, line 22
def self.find
  find_starting_in(Dir.getwd) || raise("Could not find application root for #{dir}")
end
find_starting_in(dir) click to toggle source
# File lib/radiospieler/radiospieler/root.rb, line 6
def self.find_starting_in(dir)
  if is_root?(dir)
    dir 
  elsif !dir.sub!(/\/[^\/]+$/, "")
    nil
  else
    find_starting_in(dir)
  end
end
is_root?(dir) click to toggle source
# File lib/radiospieler/radiospieler/root.rb, line 16
def self.is_root?(dir)
  File.exists?("#{dir}/config.ru") || 
  File.exists?("#{dir}/Gemfile") ||
  File.exists?("#{dir}/Procfile")
end

Public Instance Methods

root() click to toggle source
# File lib/radiospieler/radiospieler/root.rb, line 30
def root
  @root ||= Root.find.tap { |root| App.logger.warn "Application root is #{root}" }
end
root=(root) click to toggle source
# File lib/radiospieler/radiospieler/root.rb, line 26
def root=(root)
  @root = root
end