diff options
author | Azul <azul@riseup.net> | 2013-09-10 09:44:38 +0200 |
---|---|---|
committer | Azul <azul@riseup.net> | 2013-09-10 09:44:38 +0200 |
commit | 57140b80f00aab43918a3ec3276062823971dec7 (patch) | |
tree | 759de1356d0cee24e44a4229629ddaf2fc662ad0 /lib/tapicero/couch_stream.rb | |
parent | c221405796270f46d8d4881183fd55fd4d977da9 (diff) |
bringing over couch_changes from leap_ca including tests
Diffstat (limited to 'lib/tapicero/couch_stream.rb')
-rw-r--r-- | lib/tapicero/couch_stream.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/tapicero/couch_stream.rb b/lib/tapicero/couch_stream.rb new file mode 100644 index 0000000..96c752a --- /dev/null +++ b/lib/tapicero/couch_stream.rb @@ -0,0 +1,25 @@ +require 'yajl/http_stream' + +module Tapicero + class CouchStream + def initialize(database_url) + @database_url = database_url + end + + def get(path, options) + url = url_for(path, options) + # puts url + Yajl::HttpStream.get(url, :symbolize_keys => true) do |hash| + yield(hash) + end + end + + protected + + def url_for(path, options = {}) + url = [@database_url, path].join('/') + url += '?' if options.any? + url += options.map {|k,v| "#{k}=#{v}"}.join('&') + end + end +end |