Module: JasonDB

Defined in:
lib/medea/jasondb.rb

Class Method Summary collapse

Class Method Details

.db_auth_url(mode = :secure) ⇒ Object

jason_url here doesn’t include the http:// part, but does include the domain and a trailing ‘/’ ( so it’s “rest.jasondb.com/<domain>/” )



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/medea/jasondb.rb', line 4

def JasonDB::db_auth_url mode=:secure
  if ENV.include? "jason_user"
    config = ENV
  elsif defined? Rails
    config = Rails.configuration.database_configuration[Rails.env]
  else
    raise "No configuration for JasonDB found!"
  end
  
  user = config["jason_user"]
  topic = config["jason_topic"]
  password = config["jason_password"]
  if config["jason_host"]
    host = config["jason_host"]
  else
    host = "rest.jasondb.com"
  end
  protocol = "http"
  if mode == :secure
    protocol << "s"
    "#{protocol}://#{user}:#{password}@#{host}/#{topic}/"
  else #mode == :public
    #TODO Remove the dummy "a:a" here...
    "#{protocol}://a:a@#{host}/#{topic}/"
  end
end