From a89e2ba55399e6bddd9e052cf2064ed0056c958a Mon Sep 17 00:00:00 2001 From: Azul Date: Wed, 8 Jun 2016 12:44:38 +0200 Subject: refactor: use new couch_db classes from fetch_key This moves all the em_http related stuff into a single adapter. We're also not using callback and errback inside fetch_key or server for couch requests anymore. Changing the interface for hkp to do the same will follow. --- lib/nickserver/couch_db/source.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/nickserver/couch_db') diff --git a/lib/nickserver/couch_db/source.rb b/lib/nickserver/couch_db/source.rb index fffa76e..874fe4f 100644 --- a/lib/nickserver/couch_db/source.rb +++ b/lib/nickserver/couch_db/source.rb @@ -2,6 +2,7 @@ # This class allows querying couch for public keys. # require 'nickserver/couch_db/response' +require 'nickserver/config' module Nickserver::CouchDB class Source @@ -13,13 +14,17 @@ module Nickserver::CouchDB end def query(nick) - adapter.get VIEW, query: query_for(nick) do |status, body| - yield Response.new nick, status: status, body: body + adapter.get url, query: query_for(nick) do |status, body| + yield Response.new(nick, status: status, body: body) end end protected + def url + Nickserver::Config.couch_url + VIEW + end + def query_for(nick) { reduce: "false", key: "\"#{nick}\"" } end -- cgit v1.2.3