diff options
Diffstat (limited to 'lib/extends/couchrest.rb')
-rw-r--r-- | lib/extends/couchrest.rb | 29 |
1 files changed, 29 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 |