diff options
author | azul <azul@leap.se> | 2014-07-02 11:17:53 +0200 |
---|---|---|
committer | azul <azul@leap.se> | 2014-07-02 11:17:53 +0200 |
commit | c4f89692beeb98afaf61f5da8027236a10f1e440 (patch) | |
tree | fce73661f1a92f724d95d886d5f57a2b4c87c911 | |
parent | 22b785484d6df25348854ecd88f9193c0a825c44 (diff) | |
parent | acf155a879ad80336f279da6939ac08b787dac28 (diff) |
Merge pull request #17 from azul/feature/catch-first-change
Work around a bug in couchrest to catch the first change
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | lib/extends/couchrest.rb | 29 | ||||
-rw-r--r-- | lib/tapicero_daemon.rb | 1 |
3 files changed, 31 insertions, 0 deletions
diff --git a/.travis.yml b/.travis.yml index 3fd27a7..7e980b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,5 +11,6 @@ before_script: - "bundle exec bin/tapicero status" - "cat /tmp/tapicero_test.log" after_script: + - "bundle exec bin/tapicero stop" - "cat /tmp/tapicero_test.log" - "cat /tmp/tapicero_test.seq" 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 |