diff options
author | Azul <azul@riseup.net> | 2016-05-25 13:13:30 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2016-05-25 14:13:30 +0200 |
commit | 8a81429f0eb8aa5041d47557d0c5b5359bb959e6 (patch) | |
tree | 10f5d3db69883c685408edc3365d1e762f13e322 /lib/nickserver/lookup.rb | |
parent | 5c0fa0fb7b10820f2956807cb457421bf1e00708 (diff) |
copy over all files from rewritten attempt
I started a nickserver from scratch to implement the things that are independent of our choice of stack (eventmachine or other).
This commit copies them over and tests both things in parallel.
Diffstat (limited to 'lib/nickserver/lookup.rb')
-rw-r--r-- | lib/nickserver/lookup.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/nickserver/lookup.rb b/lib/nickserver/lookup.rb new file mode 100644 index 0000000..105e77e --- /dev/null +++ b/lib/nickserver/lookup.rb @@ -0,0 +1,31 @@ +require 'nickserver/invalid_source' + +module Nickserver + class Lookup + + attr_reader :nick + + def initialize(nick) + @nick = nick + end + + def respond_with(responder) + query do |status, content| + responder.send_response status: status, content: content + end + end + + protected + + def query(&block) + source.query nick, &block + end + + def source + if nick.invalid? then Nickserver::InvalidSource + elsif nick.local? then Nickserver::Config.local_source + else Nickserver::Config.remote_source + end + end + end +end |