Method: Nginxtra::Config.path

Defined in:
lib/nginxtra/config.rb

.pathObject

Obtain the config file path based on the current directory. This will be the path to the first nginxtra.conf.rb found starting at the current directory and working up until it is found or the filesystem boundary is hit (so /nginxtra.conf.rb is the last possible tested file). If none is found, nil is returned.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/nginxtra/config.rb', line 163

def path
  path = File.absolute_path "."
  config = File.join path, FILENAME
  return config if File.exist? config
  config = File.join path, "config", FILENAME
  return config if File.exist? config
  path = File.dirname path

  loop do
    config = File.join path, FILENAME
    return config if File.exist? config
    path = File.dirname path
    break if path == "/"
  end

  config = File.join path, FILENAME
  config if File.exist? config
end