Sha256: ab3ea54ca44b1b4e8b7d1f6fdd644e132ac418242f97544144b402d297121157

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

begin

  env = ENV['RAILS_ENV'] || 'development'

  couchdb_config = YAML::load(ERB.new(IO.read(RAILS_ROOT + "/config/couchdb.yml")).result)[env]

  host      = couchdb_config["host"]      || 'localhost'
  port      = couchdb_config["port"]      || '5984'
  database  = couchdb_config["database"]
  username  = couchdb_config["username"]
  password  = couchdb_config["password"]
  ssl       = couchdb_config["ssl"]       || false
  db_prefix = couchdb_config["database_prefix"] || ""
  db_suffix = couchdb_config["database_suffix"] || ""
  host     = "localhost"  if host == nil
  port     = "5984"       if port == nil
  ssl      = false        if ssl == nil

  protocol = ssl ? 'https' : 'http'
  authorized_host = (username.blank? && password.blank?) ? host :
    "#{CGI.escape(username)}:#{CGI.escape(password)}@#{host}"

rescue

  raise "There was a problem with your config/couchdb.yml file. Check and make sure it's present and the syntax is correct."

else

  COUCHDB_CONFIG = {
    :host_path => "#{protocol}://#{authorized_host}:#{port}",
    :db_prefix => "#{db_prefix}",
    :db_suffix => "#{db_suffix}"
  }

  COUCHDB_SERVER = CouchRest.new COUCHDB_CONFIG[:host_path]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
therealadam-couchrest-rails-0.1.1 generators/couch_rest_rails/templates/couchdb_initializer.rb