Instead, the number of bytes consumed is now returned, too.
--
-$Id: ChangeLog 43 2005-05-25 19:44:06Z tilman $
+$Id: ChangeLog 44 2005-05-25 19:51:25Z tilman $
++
2005-05-25 Tilman Sauerbeck (tilman at code-monkey de)
* test/test_array_sub.rb: Added a test for the :sub format
specifier
+ * lib/eet.rb, test/test_chunk.rb: Chunk.deserialize doesn't
+ modify its argument any more, instead, the number of bytes
+ consumed is now returned, too.
2005-05-19 Tilman Sauerbeck (tilman at code-monkey de)
* Rakefile: Code cleanup
#--
-# $Id: eet.rb 40 2005-05-18 19:04:52Z tilman $
+# $Id: eet.rb 44 2005-05-25 19:51:25Z tilman $
#
# Copyright (c) 2005 Tilman Sauerbeck (tilman at code-monkey de)
#
def Stream.deserialize(data)
data = data.to_str.dup
s = Stream.new
+ offset = 0
- while data.length > 0
- s << Chunk.deserialize(data)
+ while offset < data.length
+ c, bytes = Chunk.deserialize(data[offset..-1])
+
+ s << c
+ offset += bytes
end
s
c = Chunk.new(*data[8, size].split("\0", 2))
- data.replace(data[8 + size..-1] || "")
-
- c
+ [c, 8 + size]
end
end
end
-# $Id: test_chunk.rb 1 2005-03-26 01:45:38Z tilman $
+# $Id: test_chunk.rb 44 2005-05-25 19:51:25Z tilman $
require "eet"
require "test/unit"
chunk = nil
assert_nothing_raised do
- chunk = Eet::Chunk.deserialize(@data)
+ chunk, = Eet::Chunk.deserialize(@data)
end
assert_equal("tag", chunk.tag)