summaryrefslogtreecommitdiff
path: root/lib/leap_ca/couch_changes.rb
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2012-09-20 13:15:33 +0200
committerAzul <azul@riseup.net>2012-09-20 13:17:17 +0200
commit1bac88549fc3bfda81e04b2811443a301aa9e781 (patch)
tree1d646219965216479e5c770d82eec543a80044aa /lib/leap_ca/couch_changes.rb
parent15354c284879c734ca9bd87450d715dcdbe8aec2 (diff)
moved files into own dir and added main leap_ca.rb
Also updated the couchdb.yml.example with more meaningful content
Diffstat (limited to 'lib/leap_ca/couch_changes.rb')
-rw-r--r--lib/leap_ca/couch_changes.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/leap_ca/couch_changes.rb b/lib/leap_ca/couch_changes.rb
new file mode 100644
index 0000000..59209a4
--- /dev/null
+++ b/lib/leap_ca/couch_changes.rb
@@ -0,0 +1,17 @@
+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