Skip to content

Commit

Permalink
Make config loading more unsurprising
Browse files Browse the repository at this point in the history
  • Loading branch information
slaxor committed Apr 22, 2013
1 parent a518afc commit d893dd1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
6 changes: 3 additions & 3 deletions Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
nezu (0.5.21)
nezu (0.5.22)
activerecord (~> 3.2.11)
activesupport (~> 3.2.11)
amqp
Expand Down Expand Up @@ -34,7 +34,7 @@ GEM
eventmachine
arel (3.0.2)
builder (3.0.4)
bunny (0.9.0.pre8)
bunny (0.9.0.pre9)
amq-protocol (>= 1.2.0)
columnize (0.3.6)
configatron (2.10.0)
Expand Down Expand Up @@ -66,7 +66,7 @@ GEM
sdoc (0.3.20)
json (>= 1.1.3)
rdoc (~> 3.10)
term-ansicolor (1.1.4)
term-ansicolor (1.1.5)
tzinfo (0.3.37)
yamler (0.1.0)

Expand Down
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
0.5.21
0.5.22
20 changes: 16 additions & 4 deletions lib/nezu/runtime.rb
Expand Up @@ -6,7 +6,7 @@ module Nezu
module Runtime
# load everything needed to run the app
def self.load_config
Nezu.try(true) { configure_from_yaml('database.yml') }
configure_from_yaml('database.yml')

begin
configure_from_yaml('amqp.yml')
Expand All @@ -29,7 +29,14 @@ def self.load_config
req_files.each do |file_name|
require file_name #Autoload is not thread-safe :(
end
Nezu.try {require Nezu.root.join('config', 'nezu')}

app_config=Nezu.root.join('config', 'nezu.rb')
if File.exist?(app_config)
require app_config
else
Nezu.logger.info("#{app_config} doesn`t exist. I`m skipping it")
end

Nezu.logger.debug("[Nezu Runner] config loaded")
Nezu.logger.debug(configatron.amqp)
end
Expand Down Expand Up @@ -67,8 +74,13 @@ def descendants
private

def self.configure_from_yaml(yaml_file) #:nodoc:
yaml = YAML.load_file(Nezu.root.join('config', yaml_file))
configatron.configure_from_hash(File.basename(yaml_file.sub(/.yml/, '')) => yaml)
config_file = Nezu.root.join('config', yaml_file)
if File.exist?(config_file)
yaml = YAML.load_file(config_file)
configatron.configure_from_hash(File.basename(yaml_file.sub(/.yml/, '')) => yaml)
else
Nezu.logger.info("#{config_file} doesn`t exist. I`m skipping it")
end
end
end
end
Expand Down

0 comments on commit d893dd1

Please sign in to comment.