diff options
Diffstat (limited to 'lib/tapicero')
-rw-r--r-- | lib/tapicero/config.rb | 14 | ||||
-rw-r--r-- | lib/tapicero/couch_database_creator.rb | 4 |
2 files changed, 11 insertions, 7 deletions
diff --git a/lib/tapicero/config.rb b/lib/tapicero/config.rb index f760cca..6e0fdfe 100644 --- a/lib/tapicero/config.rb +++ b/lib/tapicero/config.rb @@ -15,11 +15,15 @@ module Tapicero end end - # TODO: enable username and password - def couch_host - couch_connection[:protocol] + '://' + - couch_connection[:host] + ':' + - couch_connection[:port].to_s + '/' + def couch_host(conf = nil) + conf ||= couch_connection + userinfo = [conf[:username], conf[:password]].compact.join(':') + userinfo += '@' unless userinfo.empty? + "#{conf[:protocol]}://#{userinfo}#{conf[:host]}:#{conf[:port]}" + end + + def couch_host_without_password + couch_host couch_connection.merge({:password => nil}) end private diff --git a/lib/tapicero/couch_database_creator.rb b/lib/tapicero/couch_database_creator.rb index 5a2849b..4d39c1b 100644 --- a/lib/tapicero/couch_database_creator.rb +++ b/lib/tapicero/couch_database_creator.rb @@ -12,8 +12,8 @@ module Tapicero def create(name, security = {}) db = @couch.create_db(name) puts security.to_json - puts "-> #{@host}#{name}/_security" - CouchRest.put "#{@host}#{name}/_security", security + puts "-> #{@host}/#{name}/_security" + CouchRest.put "#{@host}/#{name}/_security", security end end end |