summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAzul <azul@riseup.net>2014-07-02 11:08:56 +0200
committerAzul <azul@riseup.net>2014-07-02 11:10:46 +0200
commitacf155a879ad80336f279da6939ac08b787dac28 (patch)
tree9fd4cd65b4ad0ef5bc2691553aa6e088b69ba054 /lib
parentaac4577031728dab84f077b54e461fcb813ac0c3 (diff)
Fix couchrest missing the first change (#5452)
CouchRest::Streamer will ignore the first line from a stream. Normally that's the line opening the results array. But for continuous feeds couch will start streaming the array elements right away. So we miss the first one. There's a pull request pending for couchrest here: https://github.com/couchrest/couchrest/pull/104 Until it's merged we'll monkeypatch. Also stopping tapicero again after travis run.
Diffstat (limited to 'lib')
-rw-r--r--lib/extends/couchrest.rb29
-rw-r--r--lib/tapicero_daemon.rb1
2 files changed, 30 insertions, 0 deletions
diff --git a/lib/extends/couchrest.rb b/lib/extends/couchrest.rb
new file mode 100644
index 0000000..54db9d8
--- /dev/null
+++ b/lib/extends/couchrest.rb
@@ -0,0 +1,29 @@
+#
+# monkeypatch CouchRest::Streamer to fix
+# https://github.com/couchrest/couchrest/pull/104
+#
+module CouchRest
+ class Streamer
+
+ def open_pipe(cmd, &block)
+ first = nil
+ prev = nil
+ IO.popen(cmd) do |f|
+ while line = f.gets
+ row = parse_line(line)
+ if row.nil?
+ first ||= line # save the header for later if we can't parse it.
+ else
+ block.call row
+ end
+ prev = line
+ end
+ end
+
+ raise RestClient::ServerBrokeConnection if $? && $?.exitstatus != 0
+
+ parse_first(first, prev)
+ end
+
+ end
+end
diff --git a/lib/tapicero_daemon.rb b/lib/tapicero_daemon.rb
index 89566de..b46158a 100644
--- a/lib/tapicero_daemon.rb
+++ b/lib/tapicero_daemon.rb
@@ -5,6 +5,7 @@
# Daemons.run('tapicero_daemon.rb')
#
require 'tapicero'
+require 'extends/couchrest'
module Tapicero
module Daemon