235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
# File 'lib/omf-web/thin/server.rb', line 235
def get_database(config)
require 'omf_oml/table'
require 'omf_oml/sql_source'
if config.is_a? String
if db = @databases[config]
return db
end
fatal "Database '#{config}' not defined - (#{@databases.keys})"
abort
end
if id = config.delete(:id)
if db = @databases[id.to_s] return db
end
end
unless url = config.delete(:url)
fatal "Missing URL for database '#{id}'"
abort
end
if url.start_with?('sqlite:') && ! url.start_with?('sqlite:/')
url.insert('sqlite:'.length, '//' + @cfg_dir + '/')
end
begin
db = OMF::OML::OmlSqlSource.new(url, config)
@databases[id] = db if id
return db
rescue Exception => ex
fatal "Can't connect to database '#{id}' - #{ex}"
abort
end
end
|