diff options
author | Azul <azul@riseup.net> | 2016-06-20 10:58:25 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-06-20 10:58:25 +0200 |
commit | 6925fc2fe17d7e22e22af664171cd98956c62cf1 (patch) | |
tree | d5c3f8b0854d5185d38bb4d739517c4553bfae57 /lib | |
parent | 73226b22fdaf89be45643cf2810124a498bdef28 (diff) |
add Nickserver::Source as superclass
Diffstat (limited to 'lib')
-rw-r--r-- | lib/nickserver/couch_db/source.rb | 12 | ||||
-rw-r--r-- | lib/nickserver/hkp/source.rb | 8 | ||||
-rw-r--r-- | lib/nickserver/source.rb | 13 |
3 files changed, 16 insertions, 17 deletions
diff --git a/lib/nickserver/couch_db/source.rb b/lib/nickserver/couch_db/source.rb index 874fe4f..b30fdfc 100644 --- a/lib/nickserver/couch_db/source.rb +++ b/lib/nickserver/couch_db/source.rb @@ -1,18 +1,15 @@ # # This class allows querying couch for public keys. # +require 'nickserver/source' require 'nickserver/couch_db/response' require 'nickserver/config' module Nickserver::CouchDB - class Source + class Source < Nickserver::Source VIEW = '/_design/Identity/_view/pgp_key_by_email' - def initialize(adapter) - @adapter = adapter - end - def query(nick) adapter.get url, query: query_for(nick) do |status, body| yield Response.new(nick, status: status, body: body) @@ -29,11 +26,6 @@ module Nickserver::CouchDB { reduce: "false", key: "\"#{nick}\"" } end - def adapter - @adapter - # Nickserver::Adapters::Http.new(config) - end - attr_reader :config end end diff --git a/lib/nickserver/hkp/source.rb b/lib/nickserver/hkp/source.rb index cae3e01..8b2a62b 100644 --- a/lib/nickserver/hkp/source.rb +++ b/lib/nickserver/hkp/source.rb @@ -11,11 +11,7 @@ require "nickserver/hkp/key_info" # module Nickserver; module Hkp - class Source - - def initialize(adapter) - @adapter = adapter - end + class Source < Nickserver::Source def query(nick, &block) search(nick) do |status, response| @@ -37,8 +33,6 @@ module Nickserver; module Hkp protected - attr_reader :adapter - # # for now, just pick the newest key. # diff --git a/lib/nickserver/source.rb b/lib/nickserver/source.rb new file mode 100644 index 0000000..b8135da --- /dev/null +++ b/lib/nickserver/source.rb @@ -0,0 +1,13 @@ +module Nickserver + class Source + + def initialize(adapter) + @adapter = adapter + end + + protected + + attr_reader :adapter + + end +end |