summaryrefslogtreecommitdiff
path: root/lib/nickserver/hkp/source.rb
diff options
context:
space:
mode:
authorazul <azul@riseup.net>2017-09-23 15:11:20 +0000
committerazul <azul@riseup.net>2017-09-23 15:11:20 +0000
commitfac140a8ff76e98c275194845125d4c97f4ba07b (patch)
tree08ffafb2c70935892e975704911080b9da84e391 /lib/nickserver/hkp/source.rb
parent787287318c54b019a12ef79525c9f5b10d93724d (diff)
parent8ac6bb8492c9a3b9ec5d7b5bf2b35907a1f8c332 (diff)
Merge branch 'rubocop' into 'master'
Style fixes based on Rubocop See merge request leap/nickserver!19
Diffstat (limited to 'lib/nickserver/hkp/source.rb')
-rw-r--r--lib/nickserver/hkp/source.rb29
1 files changed, 13 insertions, 16 deletions
diff --git a/lib/nickserver/hkp/source.rb b/lib/nickserver/hkp/source.rb
index 82c94a0..d7c86a3 100644
--- a/lib/nickserver/hkp/source.rb
+++ b/lib/nickserver/hkp/source.rb
@@ -2,24 +2,21 @@ require 'nickserver/source'
require 'nickserver/response'
require 'nickserver/hkp/response'
require 'nickserver/hkp/client'
-require "nickserver/hkp/parse_key_info"
-require "nickserver/hkp/key_info"
-
-
-#
-# Fetch keys via HKP
-# http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00
-#
-
-module Nickserver; module Hkp
+require 'nickserver/hkp/parse_key_info'
+require 'nickserver/hkp/key_info'
+
+module Nickserver::Hkp
+ #
+ # Fetch keys via HKP
+ # http://tools.ietf.org/html/draft-shaw-openpgp-hkp-00
+ #
class Source < Nickserver::Source
-
def query(nick)
status, response = search(nick)
if status == 200
best = pick_best_key(response)
get_key_by_fingerprint(best.keyid, nick)
- elsif status != 404 # 404 means no key found and we proceed
+ elsif status != 404 # 404 means no key found and we proceed
Nickserver::Response.new(status, response)
end
end
@@ -27,7 +24,7 @@ module Nickserver; module Hkp
def search(nick)
status, response = client.get_key_infos_by_email(nick)
parser = ParseKeyInfo.new status, response
- return parser.status_for(nick), parser.response_for(nick)
+ [parser.status_for(nick), parser.response_for(nick)]
end
def get_key_by_fingerprint(fingerprint, nick = nil)
@@ -35,7 +32,7 @@ module Nickserver; module Hkp
if status == 200
Response.new nick, response
else
- Nickserver::Response.new status, "HKP Request failed"
+ Nickserver::Response.new status, 'HKP Request failed'
end
end
@@ -48,11 +45,11 @@ module Nickserver; module Hkp
# that is signed by the oldest key.
#
def pick_best_key(key_info_list)
- key_info_list.sort {|a,b| a.creationdate <=> b.creationdate}.last
+ key_info_list.sort_by(&:creationdate).last
end
def client
@client ||= Client.new(adapter)
end
end
-end; end
+end