Sha256: 52d0a9ce0286d0556690378bc53cf217cb34cadb7abaf959fa0c351c35c72e10

Contents?: true

Size: 841 Bytes

Versions: 21

Compression:

Stored size: 841 Bytes

Contents

require 'riak/util/escape'
require 'riak/json'

module Riak
   class Client
     class HTTPBackend
       # @private
       class KeyStreamer
         include Util::Escape

         def initialize(block)
           @buffer = ""
           @block = block
         end

         def accept(chunk)
           @buffer << chunk
           consume
         end

         def to_proc
           method(:accept).to_proc
         end

         private
         def consume
           while @buffer =~ /\}\{/
             stream($~.pre_match + '}')
             @buffer = '{' + $~.post_match
           end
         end

         def stream(str)
           obj = JSON.parse(str) rescue nil
           if obj && obj['keys']
             @block.call obj['keys'].map(&method(:maybe_unescape))
           end
         end
       end
     end
   end
 end

Version data entries

21 entries across 11 versions & 2 rubygems

Version Path
riak-client-1.2.0 lib/riak/client/http_backend/key_streamer.rb
riak-client-1.1.1 lib/riak/client/http_backend/key_streamer.rb
riak-client-1.1.0 lib/riak/client/http_backend/key_streamer.rb
better-riak-client-1.0.7 lib/riak/client/http_backend/key_streamer.rb
better-riak-client-1.0.6 lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.5 lib/riak/client/http_backend/key_streamer.rb
better-riak-client-1.0.5 lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.0/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.1/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.0/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.3 pkg/riak-client-1.0.2/pkg/riak-client-1.0.1/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.2 pkg/riak-client-1.0.1/pkg/riak-client-1.0.0/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.2 pkg/riak-client-1.0.1/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.2 pkg/riak-client-1.0.0/lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.2 lib/riak/client/http_backend/key_streamer.rb
riak-client-1.0.0 lib/riak/client/http_backend/key_streamer.rb