summaryrefslogtreecommitdiff
path: root/lib/nickserver/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nickserver/adapters')
-rw-r--r--lib/nickserver/adapters/couch_db.rb12
-rw-r--r--lib/nickserver/adapters/em_http.rb24
2 files changed, 24 insertions, 12 deletions
diff --git a/lib/nickserver/adapters/couch_db.rb b/lib/nickserver/adapters/couch_db.rb
deleted file mode 100644
index e8a23ad..0000000
--- a/lib/nickserver/adapters/couch_db.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-require 'nickserver/adapters'
-
-class Nickserver::Adapters::CouchDB
-
-
- protected
-
- def query_couch(nick)
- yield 404, "{}"
- end
-
-end
diff --git a/lib/nickserver/adapters/em_http.rb b/lib/nickserver/adapters/em_http.rb
new file mode 100644
index 0000000..16db5ae
--- /dev/null
+++ b/lib/nickserver/adapters/em_http.rb
@@ -0,0 +1,24 @@
+require 'nickserver/adapters'
+require 'em-http'
+
+module Nickserver::Adapters
+ class EmHttp
+
+ def initialize
+ @timeout = 5
+ end
+
+ def get(url, options = {})
+ get_request(url, options).callback {|http|
+ yield http.response_header.status, http.response
+ }.errback {|http|
+ yield 0, http.error
+ }
+ end
+
+ def get_request(url, options = {})
+ @request = EventMachine::HttpRequest.new(url)
+ @request.get timeout: @timeout, query: options[:query]
+ end
+ end
+end