def parse_database_yml
return "" unless File.exists?(Dir.pwd + '/config/database.yml')
environment = ENV['RAILS_ENV'] || ENV['MERB_ENV'] || ENV['RACK_ENV']
environment = 'development' if environment.nil? or environment.empty?
conf = YAML.load(File.read(Dir.pwd + '/config/database.yml'))[environment]
case conf['adapter']
when 'sqlite3'
return "sqlite://#{conf['database']}"
when 'postgresql'
uri_hash = conf_to_uri_hash(conf)
uri_hash['scheme'] = 'postgres'
return uri_hash_to_url(uri_hash)
else
return uri_hash_to_url(conf_to_uri_hash(conf))
end
rescue Exception => ex
puts "Error parsing database.yml: #{ex.message}"
puts ex.backtrace
""
end