msgpack 0.7.4 → 1.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +3 -1
- data/.rubocop.yml +3 -0
- data/.travis.yml +27 -14
- data/ChangeLog +89 -1
- data/Gemfile +6 -1
- data/README.rdoc +55 -1
- data/Rakefile +5 -1
- data/bench/pack_symbols.rb +28 -0
- data/bench/run_symbols.sh +26 -0
- data/doclib/msgpack.rb +2 -2
- data/doclib/msgpack/core_ext.rb +20 -20
- data/doclib/msgpack/factory.rb +33 -0
- data/doclib/msgpack/packer.rb +20 -0
- data/doclib/msgpack/time.rb +22 -0
- data/doclib/msgpack/timestamp.rb +44 -0
- data/ext/java/org/msgpack/jruby/Buffer.java +4 -0
- data/ext/java/org/msgpack/jruby/Encoder.java +48 -18
- data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +67 -38
- data/ext/java/org/msgpack/jruby/Factory.java +20 -8
- data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +0 -92
- data/ext/java/org/msgpack/jruby/Packer.java +114 -11
- data/ext/java/org/msgpack/jruby/Unpacker.java +15 -8
- data/ext/msgpack/buffer.h +14 -0
- data/ext/msgpack/buffer_class.c +1 -1
- data/ext/msgpack/compat.h +10 -0
- data/ext/msgpack/factory_class.c +24 -17
- data/ext/msgpack/factory_class.h +0 -2
- data/ext/msgpack/packer.c +5 -4
- data/ext/msgpack/packer.h +13 -1
- data/ext/msgpack/packer_class.c +130 -43
- data/ext/msgpack/packer_class.h +0 -2
- data/ext/msgpack/packer_ext_registry.c +2 -2
- data/ext/msgpack/packer_ext_registry.h +64 -25
- data/ext/msgpack/rbinit.c +0 -2
- data/ext/msgpack/unpacker.c +3 -3
- data/ext/msgpack/unpacker_class.c +25 -56
- data/ext/msgpack/unpacker_class.h +0 -2
- data/ext/msgpack/unpacker_ext_registry.c +2 -2
- data/ext/msgpack/unpacker_ext_registry.h +3 -3
- data/lib/msgpack.rb +36 -0
- data/lib/msgpack/core_ext.rb +139 -0
- data/lib/msgpack/factory.rb +21 -0
- data/lib/msgpack/symbol.rb +9 -0
- data/lib/msgpack/time.rb +29 -0
- data/lib/msgpack/timestamp.rb +76 -0
- data/lib/msgpack/version.rb +8 -1
- data/msgpack.gemspec +6 -7
- data/spec/cruby/buffer_spec.rb +6 -1
- data/spec/factory_spec.rb +134 -0
- data/spec/msgpack_spec.rb +52 -0
- data/spec/packer_spec.rb +200 -0
- data/spec/timestamp_spec.rb +121 -0
- data/spec/unpacker_spec.rb +29 -0
- metadata +29 -23
- data/ext/msgpack/core_ext.c +0 -144
- data/ext/msgpack/core_ext.h +0 -26
data/spec/msgpack_spec.rb
CHANGED
@@ -159,4 +159,56 @@ describe MessagePack do
|
|
159
159
|
packed.should start_with("\xDA\x00\x20")
|
160
160
|
end
|
161
161
|
end
|
162
|
+
|
163
|
+
context 'when a Bignum has a small value' do
|
164
|
+
tests['numbers'].take(10).each do |desc, unpacked, packed|
|
165
|
+
it("encodes #{desc} to the smallest representation") do
|
166
|
+
bignum = (1 << 64).coerce(unpacked)[0]
|
167
|
+
MessagePack.pack(bignum).should eq(packed)
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
context 'when the source is na IO-like object' do
|
173
|
+
require 'tempfile'
|
174
|
+
require 'stringio'
|
175
|
+
|
176
|
+
it 'work with IO destination object as 2nd argument of MessagePack.pack' do
|
177
|
+
Tempfile.create("pack-test") do |io|
|
178
|
+
return_value = MessagePack.pack(utf8enc('hello world'), io)
|
179
|
+
return_value.should be_nil
|
180
|
+
|
181
|
+
io.rewind
|
182
|
+
io.read.force_encoding(Encoding::ASCII_8BIT).should eq("\xABhello world".force_encoding(Encoding::ASCII_8BIT))
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'work with IO-like StringIO destination object as 2nd argument of MessagePack.pack' do
|
187
|
+
io = StringIO.new
|
188
|
+
return_value = MessagePack.pack(utf8enc('hello world'), io)
|
189
|
+
return_value.should be_nil
|
190
|
+
|
191
|
+
io.rewind
|
192
|
+
io.read.force_encoding(Encoding::ASCII_8BIT).should eq("\xABhello world".force_encoding(Encoding::ASCII_8BIT))
|
193
|
+
end
|
194
|
+
|
195
|
+
it 'work with IO source object as source of MessagePack.unpack' do
|
196
|
+
Tempfile.create("unpack-test") do |io|
|
197
|
+
MessagePack.pack(utf8enc('hello world'), io)
|
198
|
+
io.rewind
|
199
|
+
|
200
|
+
return_value = MessagePack.unpack(io)
|
201
|
+
return_value.should eq(utf8enc('hello world'))
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
it 'work with IO-like StringIO object of MessagePack.unpack' do
|
206
|
+
io = StringIO.new
|
207
|
+
MessagePack.pack(utf8enc('hello world'), io)
|
208
|
+
io.rewind
|
209
|
+
|
210
|
+
return_value = MessagePack.unpack(io)
|
211
|
+
return_value.should eq(utf8enc('hello world'))
|
212
|
+
end
|
213
|
+
end
|
162
214
|
end
|
data/spec/packer_spec.rb
CHANGED
@@ -134,6 +134,41 @@ describe MessagePack::Packer do
|
|
134
134
|
packer.to_s.should == "\x81"
|
135
135
|
end
|
136
136
|
|
137
|
+
it 'write_bin_header 0' do
|
138
|
+
packer.write_bin_header(0)
|
139
|
+
packer.to_s.should == "\xC4\x00"
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'write_bin_header 255' do
|
143
|
+
packer.write_bin_header(255)
|
144
|
+
packer.to_s.should == "\xC4\xFF"
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'write_bin_header 256' do
|
148
|
+
packer.write_bin_header(256)
|
149
|
+
packer.to_s.should == "\xC5\x01\x00"
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'write_bin_header 65535' do
|
153
|
+
packer.write_bin_header(65535)
|
154
|
+
packer.to_s.should == "\xC5\xFF\xFF"
|
155
|
+
end
|
156
|
+
|
157
|
+
it 'write_bin_header 65536' do
|
158
|
+
packer.write_bin_header(65536)
|
159
|
+
packer.to_s.should == "\xC6\x00\x01\x00\x00"
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'write_bin_header 999999' do
|
163
|
+
packer.write_bin_header(999999)
|
164
|
+
packer.to_s.should == "\xC6\x00\x0F\x42\x3F"
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'write_bin' do
|
168
|
+
packer.write_bin("hello")
|
169
|
+
packer.to_s.should == "\xC4\x05hello"
|
170
|
+
end
|
171
|
+
|
137
172
|
describe '#write_float32' do
|
138
173
|
tests = [
|
139
174
|
['small floats', 3.14, "\xCA\x40\x48\xF5\xC3"],
|
@@ -178,6 +213,29 @@ describe MessagePack::Packer do
|
|
178
213
|
Array.new.to_msgpack.class.should == String
|
179
214
|
end
|
180
215
|
|
216
|
+
it 'to_msgpack with packer equals to_msgpack' do
|
217
|
+
nil.to_msgpack(MessagePack::Packer.new).to_str.should == nil.to_msgpack
|
218
|
+
true.to_msgpack(MessagePack::Packer.new).to_str.should == true.to_msgpack
|
219
|
+
false.to_msgpack(MessagePack::Packer.new).to_str.should == false.to_msgpack
|
220
|
+
1.to_msgpack(MessagePack::Packer.new).to_str.should == 1.to_msgpack
|
221
|
+
1.0.to_msgpack(MessagePack::Packer.new).to_str.should == 1.0.to_msgpack
|
222
|
+
"".to_msgpack(MessagePack::Packer.new).to_str.should == "".to_msgpack
|
223
|
+
Hash.new.to_msgpack(MessagePack::Packer.new).to_str.should == Hash.new.to_msgpack
|
224
|
+
Array.new.to_msgpack(MessagePack::Packer.new).to_str.should == Array.new.to_msgpack
|
225
|
+
end
|
226
|
+
|
227
|
+
it 'raises type error on wrong type' do
|
228
|
+
packer = MessagePack::Packer.new
|
229
|
+
expect { packer.write_float "hello" }.to raise_error(TypeError)
|
230
|
+
expect { packer.write_string 1 }.to raise_error(TypeError)
|
231
|
+
expect { packer.write_bin 1 }.to raise_error(TypeError)
|
232
|
+
expect { packer.write_array "hello" }.to raise_error(TypeError)
|
233
|
+
expect { packer.write_hash "hello" }.to raise_error(TypeError)
|
234
|
+
expect { packer.write_symbol "hello" }.to raise_error(TypeError)
|
235
|
+
expect { packer.write_int "hello" }.to raise_error(TypeError)
|
236
|
+
expect { packer.write_extension "hello" }.to raise_error(TypeError)
|
237
|
+
end
|
238
|
+
|
181
239
|
class CustomPack01
|
182
240
|
def to_msgpack(pk=nil)
|
183
241
|
return MessagePack.pack(self, pk) unless pk.class == MessagePack::Packer
|
@@ -323,6 +381,148 @@ describe MessagePack::Packer do
|
|
323
381
|
expect(two[:class]).to eq(ValueTwo)
|
324
382
|
expect(two[:packer]).to eq(:to_msgpack_ext)
|
325
383
|
end
|
384
|
+
|
385
|
+
context 'when it has no ext type but a super class has' do
|
386
|
+
before { stub_const('Value', Class.new) }
|
387
|
+
before do
|
388
|
+
Value.class_eval do
|
389
|
+
def to_msgpack_ext
|
390
|
+
'value_msgpacked'
|
391
|
+
end
|
392
|
+
end
|
393
|
+
end
|
394
|
+
before { packer.register_type(0x01, Value, :to_msgpack_ext) }
|
395
|
+
|
396
|
+
context "when it is a child class" do
|
397
|
+
before { stub_const('InheritedValue', Class.new(Value)) }
|
398
|
+
subject { packer.pack(InheritedValue.new).to_s }
|
399
|
+
|
400
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
401
|
+
|
402
|
+
context "when it is a grandchild class" do
|
403
|
+
before { stub_const('InheritedTwiceValue', Class.new(InheritedValue)) }
|
404
|
+
subject { packer.pack(InheritedTwiceValue.new).to_s }
|
405
|
+
|
406
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
407
|
+
end
|
408
|
+
end
|
409
|
+
end
|
410
|
+
|
411
|
+
context 'when it and its super class has an ext type' do
|
412
|
+
before { stub_const('Value', Class.new) }
|
413
|
+
before do
|
414
|
+
Value.class_eval do
|
415
|
+
def to_msgpack_ext
|
416
|
+
'value_msgpacked'
|
417
|
+
end
|
418
|
+
end
|
419
|
+
end
|
420
|
+
before { packer.register_type(0x01, Value, :to_msgpack_ext) }
|
421
|
+
|
422
|
+
context "when it is a child class" do
|
423
|
+
before { stub_const('InheritedValue', Class.new(Value)) }
|
424
|
+
before do
|
425
|
+
InheritedValue.class_eval do
|
426
|
+
def to_msgpack_ext
|
427
|
+
'inherited_value_msgpacked'
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
|
432
|
+
before { packer.register_type(0x02, InheritedValue, :to_msgpack_ext) }
|
433
|
+
subject { packer.pack(InheritedValue.new).to_s }
|
434
|
+
|
435
|
+
it { is_expected.to eq "\xC7\x19\x02inherited_value_msgpacked" }
|
436
|
+
end
|
437
|
+
|
438
|
+
context "even when it is a child class" do
|
439
|
+
before { stub_const('InheritedValue', Class.new(Value)) }
|
440
|
+
before do
|
441
|
+
InheritedValue.class_eval do
|
442
|
+
def to_msgpack_ext
|
443
|
+
'inherited_value_msgpacked'
|
444
|
+
end
|
445
|
+
end
|
446
|
+
end
|
447
|
+
|
448
|
+
before { packer.register_type(0x02, InheritedValue, :to_msgpack_ext) }
|
449
|
+
subject { packer.pack(Value.new).to_s }
|
450
|
+
|
451
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
452
|
+
end
|
453
|
+
end
|
454
|
+
|
455
|
+
context 'when it has no ext type but an included module has' do
|
456
|
+
subject { packer.pack(Value.new).to_s }
|
457
|
+
|
458
|
+
before do
|
459
|
+
mod = Module.new do
|
460
|
+
def to_msgpack_ext
|
461
|
+
'value_msgpacked'
|
462
|
+
end
|
463
|
+
end
|
464
|
+
stub_const('Mod', mod)
|
465
|
+
end
|
466
|
+
before { packer.register_type(0x01, Mod, :to_msgpack_ext) }
|
467
|
+
|
468
|
+
before { stub_const('Value', Class.new{ include Mod }) }
|
469
|
+
|
470
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
471
|
+
end
|
472
|
+
|
473
|
+
context 'when it has no ext type but it was extended by a module which has one' do
|
474
|
+
subject { packer.pack(object).to_s }
|
475
|
+
let(:object) { Object.new.extend Mod }
|
476
|
+
|
477
|
+
before do
|
478
|
+
mod = Module.new do
|
479
|
+
def to_msgpack_ext
|
480
|
+
'value_msgpacked'
|
481
|
+
end
|
482
|
+
end
|
483
|
+
stub_const('Mod', mod)
|
484
|
+
end
|
485
|
+
before { packer.register_type(0x01, Mod, :to_msgpack_ext) }
|
486
|
+
|
487
|
+
|
488
|
+
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
489
|
+
end
|
490
|
+
|
491
|
+
context 'when registering a type for symbols' do
|
492
|
+
before { packer.register_type(0x00, ::Symbol, :to_msgpack_ext) }
|
493
|
+
|
494
|
+
it 'packs symbols in an ext type' do
|
495
|
+
expect(packer.pack(:symbol).to_s).to eq "\xc7\x06\x00symbol"
|
496
|
+
end
|
497
|
+
end
|
498
|
+
end
|
499
|
+
|
500
|
+
describe "fixnum and bignum" do
|
501
|
+
it "fixnum.to_msgpack" do
|
502
|
+
23.to_msgpack.should == "\x17"
|
503
|
+
end
|
504
|
+
|
505
|
+
it "fixnum.to_msgpack(packer)" do
|
506
|
+
23.to_msgpack(packer)
|
507
|
+
packer.to_s.should == "\x17"
|
508
|
+
end
|
509
|
+
|
510
|
+
it "bignum.to_msgpack" do
|
511
|
+
-4294967296.to_msgpack.should == "\xD3\xFF\xFF\xFF\xFF\x00\x00\x00\x00"
|
512
|
+
end
|
513
|
+
|
514
|
+
it "bignum.to_msgpack(packer)" do
|
515
|
+
-4294967296.to_msgpack(packer)
|
516
|
+
packer.to_s.should == "\xD3\xFF\xFF\xFF\xFF\x00\x00\x00\x00"
|
517
|
+
end
|
518
|
+
|
519
|
+
it "unpack(fixnum)" do
|
520
|
+
MessagePack.unpack("\x17").should == 23
|
521
|
+
end
|
522
|
+
|
523
|
+
it "unpack(bignum)" do
|
524
|
+
MessagePack.unpack("\xD3\xFF\xFF\xFF\xFF\x00\x00\x00\x00").should == -4294967296
|
525
|
+
end
|
326
526
|
end
|
327
527
|
|
328
528
|
describe "ext formats" do
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe MessagePack::Timestamp do
|
6
|
+
describe 'malformed format' do
|
7
|
+
it do
|
8
|
+
expect do
|
9
|
+
MessagePack::Timestamp.from_msgpack_ext([0xd4, 0x00].pack("C*"))
|
10
|
+
end.to raise_error(MessagePack::MalformedFormatError)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe 'register_type with Time' do
|
15
|
+
let(:factory) do
|
16
|
+
factory = MessagePack::Factory.new
|
17
|
+
factory.register_type(
|
18
|
+
MessagePack::Timestamp::TYPE,
|
19
|
+
Time,
|
20
|
+
packer: MessagePack::Time::Packer,
|
21
|
+
unpacker: MessagePack::Time::Unpacker
|
22
|
+
)
|
23
|
+
factory
|
24
|
+
end
|
25
|
+
|
26
|
+
let(:time) { Time.local(2019, 6, 17, 1, 2, 3, 123_456_789 / 1000.0) }
|
27
|
+
it 'serializes and deserializes Time' do
|
28
|
+
prefix_fixext8_with_type_id = [0xd7, -1].pack("c*")
|
29
|
+
|
30
|
+
packed = factory.pack(time)
|
31
|
+
expect(packed).to start_with(prefix_fixext8_with_type_id)
|
32
|
+
expect(packed.size).to eq(10)
|
33
|
+
unpacked = factory.unpack(packed)
|
34
|
+
expect(unpacked.to_i).to eq(time.to_i)
|
35
|
+
expect(unpacked.to_f).to eq(time.to_f)
|
36
|
+
# expect(unpacked).to eq(time) # we can't do it because of nsec (rational vs float?)
|
37
|
+
end
|
38
|
+
|
39
|
+
let(:time_without_nsec) { Time.local(2019, 6, 17, 1, 2, 3, 0) }
|
40
|
+
it 'serializes time without nanosec as fixext4' do
|
41
|
+
prefix_fixext4_with_type_id = [0xd6, -1].pack("c*")
|
42
|
+
|
43
|
+
packed = factory.pack(time_without_nsec)
|
44
|
+
expect(packed).to start_with(prefix_fixext4_with_type_id)
|
45
|
+
expect(packed.size).to eq(6)
|
46
|
+
unpacked = factory.unpack(packed)
|
47
|
+
expect(unpacked).to eq(time_without_nsec)
|
48
|
+
end
|
49
|
+
|
50
|
+
let(:time_after_2514) { Time.at(1 << 34) } # the max num of 34bit int means 2514-05-30 01:53:04 UTC
|
51
|
+
it 'serializes time after 2038 as ext8' do
|
52
|
+
prefix_ext8_with_12bytes_payload_and_type_id = [0xc7, 12, -1].pack("c*")
|
53
|
+
|
54
|
+
expect(time_after_2514.to_i).to be > 0xffffffff
|
55
|
+
packed = factory.pack(time_after_2514)
|
56
|
+
expect(packed).to start_with(prefix_ext8_with_12bytes_payload_and_type_id)
|
57
|
+
expect(packed.size).to eq(15)
|
58
|
+
end
|
59
|
+
|
60
|
+
it 'runs correctly (regression)' do
|
61
|
+
expect(factory.unpack(factory.pack(Time.utc(2200)))).to eq(Time.utc(2200))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
describe 'register_type with MessagePack::Timestamp' do
|
66
|
+
let(:factory) do
|
67
|
+
factory = MessagePack::Factory.new
|
68
|
+
factory.register_type(MessagePack::Timestamp::TYPE, MessagePack::Timestamp)
|
69
|
+
factory
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:timestamp) { MessagePack::Timestamp.new(Time.now.tv_sec, 123_456_789) }
|
73
|
+
it 'serializes and deserializes MessagePack::Timestamp' do
|
74
|
+
packed = factory.pack(timestamp)
|
75
|
+
unpacked = factory.unpack(packed)
|
76
|
+
expect(unpacked).to eq(timestamp)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
describe 'timestamp32' do
|
81
|
+
it 'handles [1, 0]' do
|
82
|
+
t = MessagePack::Timestamp.new(1, 0)
|
83
|
+
|
84
|
+
payload = t.to_msgpack_ext
|
85
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
86
|
+
|
87
|
+
expect(unpacked).to eq(t)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe 'timestamp64' do
|
92
|
+
it 'handles [1, 1]' do
|
93
|
+
t = MessagePack::Timestamp.new(1, 1)
|
94
|
+
|
95
|
+
payload = t.to_msgpack_ext
|
96
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
97
|
+
|
98
|
+
expect(unpacked).to eq(t)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
describe 'timestamp96' do
|
103
|
+
it 'handles [-1, 0]' do
|
104
|
+
t = MessagePack::Timestamp.new(-1, 0)
|
105
|
+
|
106
|
+
payload = t.to_msgpack_ext
|
107
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
108
|
+
|
109
|
+
expect(unpacked).to eq(t)
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'handles [-1, 999_999_999]' do
|
113
|
+
t = MessagePack::Timestamp.new(-1, 999_999_999)
|
114
|
+
|
115
|
+
payload = t.to_msgpack_ext
|
116
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
117
|
+
|
118
|
+
expect(unpacked).to eq(t)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
data/spec/unpacker_spec.rb
CHANGED
@@ -477,6 +477,24 @@ describe MessagePack::Unpacker do
|
|
477
477
|
expect(two[:class]).to be_nil
|
478
478
|
expect(two[:unpacker]).to be_instance_of(Proc)
|
479
479
|
end
|
480
|
+
|
481
|
+
describe "registering an ext type for a module" do
|
482
|
+
subject { unpacker.feed("\xc7\x06\x00module").unpack }
|
483
|
+
|
484
|
+
let(:unpacker) { MessagePack::Unpacker.new }
|
485
|
+
|
486
|
+
before do
|
487
|
+
mod = Module.new do
|
488
|
+
def self.from_msgpack_ext(data)
|
489
|
+
"unpacked #{data}"
|
490
|
+
end
|
491
|
+
end
|
492
|
+
stub_const('Mod', mod)
|
493
|
+
end
|
494
|
+
|
495
|
+
before { unpacker.register_type(0x00, Mod, :from_msgpack_ext) }
|
496
|
+
it { is_expected.to eq "unpacked module" }
|
497
|
+
end
|
480
498
|
end
|
481
499
|
|
482
500
|
def flatten(struct, results = [])
|
@@ -564,6 +582,17 @@ describe MessagePack::Unpacker do
|
|
564
582
|
objects.should == [{'foo' => 'bar'}, {'hello' => {'world' => [1, 2, 3]}}, {'x' => 'y'}]
|
565
583
|
end
|
566
584
|
end
|
585
|
+
|
586
|
+
context 'with a stream and symbolize_keys passed to the constructor' do
|
587
|
+
it 'yields each object in the stream, with symbolized keys' do
|
588
|
+
objects = []
|
589
|
+
unpacker = described_class.new(StringIO.new(buffer1 + buffer2 + buffer3), symbolize_keys: true)
|
590
|
+
unpacker.each do |obj|
|
591
|
+
objects << obj
|
592
|
+
end
|
593
|
+
objects.should == [{:foo => 'bar'}, {:hello => {:world => [1, 2, 3]}}, {:x => 'y'}]
|
594
|
+
end
|
595
|
+
end
|
567
596
|
end
|
568
597
|
|
569
598
|
describe '#feed_each' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -10,64 +10,64 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2020-02-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - "
|
19
|
+
- - ">="
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '
|
21
|
+
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - "
|
26
|
+
- - ">="
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: '
|
28
|
+
version: '0'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- - "
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0
|
35
|
+
version: '0'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- - "
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0
|
42
|
+
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: rake-compiler
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0
|
49
|
+
version: '1.0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0
|
56
|
+
version: '1.0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: rake-compiler-dock
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
61
|
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
63
|
+
version: '1.0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
68
|
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
70
|
+
version: '1.0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: rspec
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,16 +86,16 @@ dependencies:
|
|
86
86
|
name: yard
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - "
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 0
|
91
|
+
version: '0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- - "
|
96
|
+
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
|
-
version: 0
|
98
|
+
version: '0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: json
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,8 +134,10 @@ files:
|
|
134
134
|
- bench/pack.rb
|
135
135
|
- bench/pack_log.rb
|
136
136
|
- bench/pack_log_long.rb
|
137
|
+
- bench/pack_symbols.rb
|
137
138
|
- bench/run.sh
|
138
139
|
- bench/run_long.sh
|
140
|
+
- bench/run_symbols.sh
|
139
141
|
- bench/unpack.rb
|
140
142
|
- bench/unpack_log.rb
|
141
143
|
- bench/unpack_log_long.rb
|
@@ -146,6 +148,8 @@ files:
|
|
146
148
|
- doclib/msgpack/extension_value.rb
|
147
149
|
- doclib/msgpack/factory.rb
|
148
150
|
- doclib/msgpack/packer.rb
|
151
|
+
- doclib/msgpack/time.rb
|
152
|
+
- doclib/msgpack/timestamp.rb
|
149
153
|
- doclib/msgpack/unpacker.rb
|
150
154
|
- ext/java/org/msgpack/jruby/Buffer.java
|
151
155
|
- ext/java/org/msgpack/jruby/Decoder.java
|
@@ -162,8 +166,6 @@ files:
|
|
162
166
|
- ext/msgpack/buffer_class.c
|
163
167
|
- ext/msgpack/buffer_class.h
|
164
168
|
- ext/msgpack/compat.h
|
165
|
-
- ext/msgpack/core_ext.c
|
166
|
-
- ext/msgpack/core_ext.h
|
167
169
|
- ext/msgpack/extconf.rb
|
168
170
|
- ext/msgpack/extension_value_class.c
|
169
171
|
- ext/msgpack/extension_value_class.h
|
@@ -188,8 +190,12 @@ files:
|
|
188
190
|
- ext/msgpack/unpacker_ext_registry.c
|
189
191
|
- ext/msgpack/unpacker_ext_registry.h
|
190
192
|
- lib/msgpack.rb
|
193
|
+
- lib/msgpack/core_ext.rb
|
191
194
|
- lib/msgpack/factory.rb
|
192
195
|
- lib/msgpack/packer.rb
|
196
|
+
- lib/msgpack/symbol.rb
|
197
|
+
- lib/msgpack/time.rb
|
198
|
+
- lib/msgpack/timestamp.rb
|
193
199
|
- lib/msgpack/unpacker.rb
|
194
200
|
- lib/msgpack/version.rb
|
195
201
|
- msgpack.gemspec
|
@@ -215,6 +221,7 @@ files:
|
|
215
221
|
- spec/packer_spec.rb
|
216
222
|
- spec/random_compat.rb
|
217
223
|
- spec/spec_helper.rb
|
224
|
+
- spec/timestamp_spec.rb
|
218
225
|
- spec/unpack_spec.rb
|
219
226
|
- spec/unpacker_spec.rb
|
220
227
|
homepage: http://msgpack.org/
|
@@ -236,8 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
236
243
|
- !ruby/object:Gem::Version
|
237
244
|
version: '0'
|
238
245
|
requirements: []
|
239
|
-
|
240
|
-
rubygems_version: 2.5.1
|
246
|
+
rubygems_version: 3.1.2
|
241
247
|
signing_key:
|
242
248
|
specification_version: 4
|
243
249
|
summary: MessagePack, a binary-based efficient data interchange format.
|
@@ -263,6 +269,6 @@ test_files:
|
|
263
269
|
- spec/packer_spec.rb
|
264
270
|
- spec/random_compat.rb
|
265
271
|
- spec/spec_helper.rb
|
272
|
+
- spec/timestamp_spec.rb
|
266
273
|
- spec/unpack_spec.rb
|
267
274
|
- spec/unpacker_spec.rb
|
268
|
-
has_rdoc: false
|