lib/yogi_berra/catcher.rb in yogi_berra-0.0.2 vs lib/yogi_berra/catcher.rb in yogi_berra-0.0.3
- old
+ new
@@ -17,17 +17,17 @@
end
if database_config
begin
File.open(database_config, 'r') do |f|
yaml_file = YAML.load(f)
- environment = ENV["RAILS_ENV"] ? ENV["RAILS_ENV"] : ENV["YOGI_ENV"]
- YogiBerra::Logger.log("I get here! #{environment.inspect}", :info)
+ environment = (ENV["YOGI_ENV"] || ENV["RAILS_ENV"] || "test")
@@settings = yaml_file["#{environment}"] if yaml_file
end
rescue
YogiBerra::Logger.log("No such file: #{database_config}", :error)
end
+ @@settings
end
end
def db_client(host, port)
# :w => 0 set the default write concern to 0, this allows writes to be non-blocking
@@ -37,24 +37,24 @@
YogiBerra::Logger.log("Couldn't connect to the mongo database on host: #{host} port: #{port}.", :error)
nil
end
def quick_connection
- YogiBerra::Logger.log("settings::::::::::: #{settings.inspect}", :info)
- settings = @@settings || load_db_settings
+ load_db_settings
- if settings
- host = settings["host"]
- port = settings["port"]
+ if @@settings
+ host = @@settings["host"]
+ port = @@settings["port"]
client = db_client(host, port)
if client
- @@connection = client[settings["database"]]
+ @@connection = client[@@settings["database"]]
else
YogiBerra::Logger.log("Couldn't connect to the mongo database on host: #{host} port: #{port}.", :error)
end
else
YogiBerra::Logger.log("Couldn't load the yogi.yml file.", :error)
end
+ @@connection
end
end
end
end
\ No newline at end of file