From 57140b80f00aab43918a3ec3276062823971dec7 Mon Sep 17 00:00:00 2001 From: Azul Date: Tue, 10 Sep 2013 09:44:38 +0200 Subject: bringing over couch_changes from leap_ca including tests --- lib/tapicero/couch_changes.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 lib/tapicero/couch_changes.rb (limited to 'lib/tapicero/couch_changes.rb') diff --git a/lib/tapicero/couch_changes.rb b/lib/tapicero/couch_changes.rb new file mode 100644 index 0000000..2e668dc --- /dev/null +++ b/lib/tapicero/couch_changes.rb @@ -0,0 +1,19 @@ +module Tapicero + class CouchChanges + def initialize(stream) + @stream = stream + end + + def last_seq + @stream.get "_changes", :limit => 1, :descending => true do |hash| + return hash[:last_seq] + end + end + + def follow + @stream.get "_changes", :feed => :continuous, :since => last_seq do |hash| + yield(hash) + end + end + end +end -- cgit v1.2.3