Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support deeper nesting of multi bulks

  • Loading branch information...
commit 1ef107c01ad91dba003b4c4262109d87b40c19a5 1 parent b0a52ba
@pietern pietern authored
View
11 lib/hiredis/ruby/reader.rb
@@ -32,14 +32,17 @@ class Task
method_index[?*] = :process_multi_bulk_reply
METHOD_INDEX = method_index.freeze
- attr_accessor :parent, :child
+ attr_reader :parent
+ attr_reader :depth
attr_accessor :multi_bulk
def initialize(buffer, parent = nil, depth = 0)
- @buffer, @parent = buffer, parent
+ @buffer, @parent, @depth = buffer, parent, depth
+ end
- # Require 3 nested tasks
- @child = Task.new(@buffer, self, depth + 1) if depth < 2
+ # Note: task depth is not checked.
+ def child
+ @child ||= Task.new(@buffer, self, depth + 1)
end
def root
View
5 test/reader_test.rb
@@ -70,6 +70,11 @@ def test_nested_multi_bulk
@reader.feed("*2\r\n*2\r\n$5\r\nhello\r\n$5\r\nworld\r\n$1\r\n!\r\n")
assert_equal [["hello", "world"], "!"], @reader.gets
end
+
+ def test_nested_multi_bulk_redux
+ @reader.feed("*2\r\n*2\r\n*1\r\n$5\r\nhello\r\n$5\r\nworld\r\n$1\r\n!\r\n")
+ assert_equal [[["hello"], "world"], "!"], @reader.gets
+ end
end
if defined?(Hiredis::Ruby::Reader)
2  vendor/hiredis
@@ -1 +1 @@
-Subproject commit 6d026b70d0795181ae2fe3c4c96c84461b4be0b5
+Subproject commit 95e83386f7d592d021bed87f4df1530eda454c6a
Please sign in to comment.
Something went wrong with that request. Please try again.