Module: Herbert::Configurator

Defined in:
lib/herbert/Configurator.rb

Defined Under Namespace

Modules: Helpers, Prepatch

Class Method Summary collapse

Class Method Details

.registered(app) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/herbert/Configurator.rb', line 36

def self.registered(app)
  app.enable :logging if app.development?
  #Assume loading by rackup...
  puts app.settings.root
  app.settings.root ||= File.join(Dir.getwd, 'lib')
  path = File.join(app.settings.root, 'config')
  # Load and evaluate common.rb and appropriate settings
  ['common.rb', app.environment.to_s + '.rb'].each do |file|
    cpath = File.join(path, file)
    if File.exists?(cpath) then
      # Ummm, I'm sorry?
      app.instance_eval(IO.read(cpath))
      log.h_debug("Applying #{cpath} onto the application")
    else
      log.h_warn("Configuration file #{cpath} not found")
    end
  end
  # So, we have all our settings... Please note that configure
  # block inside an App can overwrite our settings, but Herbert's
  # services are being created right now, so they only take in account
  # previous declarations
end