msgpack 1.2.6 → 1.4.4
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 +4 -4
- data/.github/workflows/ci.yaml +56 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +4 -1
- data/ChangeLog +59 -0
- data/Gemfile +3 -0
- data/README.md +242 -0
- data/Rakefile +3 -8
- data/doclib/msgpack/factory.rb +1 -0
- data/doclib/msgpack/packer.rb +20 -0
- data/doclib/msgpack/time.rb +22 -0
- data/doclib/msgpack/timestamp.rb +44 -0
- data/doclib/msgpack.rb +2 -2
- data/ext/java/org/msgpack/jruby/Buffer.java +21 -16
- data/ext/java/org/msgpack/jruby/Decoder.java +29 -10
- data/ext/java/org/msgpack/jruby/Encoder.java +38 -19
- data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +9 -9
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +5 -8
- data/ext/java/org/msgpack/jruby/Factory.java +8 -3
- data/ext/java/org/msgpack/jruby/Packer.java +31 -8
- data/ext/java/org/msgpack/jruby/Unpacker.java +40 -27
- data/ext/msgpack/buffer.c +4 -16
- data/ext/msgpack/buffer.h +60 -5
- data/ext/msgpack/compat.h +1 -12
- data/ext/msgpack/extconf.rb +39 -7
- data/ext/msgpack/factory_class.c +10 -5
- data/ext/msgpack/packer.c +18 -5
- data/ext/msgpack/packer.h +0 -16
- data/ext/msgpack/packer_class.c +21 -9
- data/ext/msgpack/packer_ext_registry.c +0 -22
- data/ext/msgpack/unpacker.c +41 -49
- data/ext/msgpack/unpacker.h +8 -0
- data/ext/msgpack/unpacker_class.c +23 -13
- data/lib/msgpack/symbol.rb +14 -4
- data/lib/msgpack/time.rb +29 -0
- data/lib/msgpack/timestamp.rb +76 -0
- data/lib/msgpack/version.rb +4 -7
- data/lib/msgpack.rb +8 -10
- data/msgpack.gemspec +3 -7
- data/spec/cruby/buffer_spec.rb +6 -1
- data/spec/factory_spec.rb +17 -0
- data/spec/msgpack_spec.rb +44 -1
- data/spec/packer_spec.rb +54 -0
- data/spec/spec_helper.rb +27 -0
- data/spec/timestamp_spec.rb +161 -0
- data/spec/unpacker_spec.rb +113 -1
- metadata +19 -51
- data/.travis.yml +0 -41
- data/README.rdoc +0 -201
data/spec/msgpack_spec.rb
CHANGED
@@ -115,7 +115,7 @@ describe MessagePack do
|
|
115
115
|
expect { MessagePack.pack(self) }.to raise_error(NoMethodError, /^undefined method `to_msgpack'/)
|
116
116
|
end
|
117
117
|
|
118
|
-
it '
|
118
|
+
it 'raises an error on #unpack with garbage' do
|
119
119
|
skip "but nothing was raised. why?"
|
120
120
|
expect { MessagePack.unpack('asdka;sd') }.to raise_error(MessagePack::UnpackError)
|
121
121
|
end
|
@@ -168,4 +168,47 @@ describe MessagePack do
|
|
168
168
|
end
|
169
169
|
end
|
170
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
|
171
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"],
|
@@ -193,6 +228,7 @@ describe MessagePack::Packer do
|
|
193
228
|
packer = MessagePack::Packer.new
|
194
229
|
expect { packer.write_float "hello" }.to raise_error(TypeError)
|
195
230
|
expect { packer.write_string 1 }.to raise_error(TypeError)
|
231
|
+
expect { packer.write_bin 1 }.to raise_error(TypeError)
|
196
232
|
expect { packer.write_array "hello" }.to raise_error(TypeError)
|
197
233
|
expect { packer.write_hash "hello" }.to raise_error(TypeError)
|
198
234
|
expect { packer.write_symbol "hello" }.to raise_error(TypeError)
|
@@ -452,6 +488,24 @@ describe MessagePack::Packer do
|
|
452
488
|
it { is_expected.to eq "\xC7\x0F\x01value_msgpacked" }
|
453
489
|
end
|
454
490
|
|
491
|
+
shared_examples_for 'extension subclasses core type' do |klass|
|
492
|
+
before { stub_const('Value', Class.new(klass)) }
|
493
|
+
let(:object) { Value.new }
|
494
|
+
subject { packer.pack(object).to_s }
|
495
|
+
|
496
|
+
it "defaults to #{klass.name} packer if no extension is present" do
|
497
|
+
expect(subject).to eq(MessagePack.dump(klass.new))
|
498
|
+
end
|
499
|
+
|
500
|
+
it "uses core type extension for #{klass.name}" do
|
501
|
+
packer.register_type(0x01, Value, ->(_) { 'value_msgpacked' })
|
502
|
+
expect(subject).to eq("\xC7\x0F\x01value_msgpacked")
|
503
|
+
end
|
504
|
+
end
|
505
|
+
it_behaves_like 'extension subclasses core type', Hash
|
506
|
+
it_behaves_like 'extension subclasses core type', Array
|
507
|
+
it_behaves_like 'extension subclasses core type', String
|
508
|
+
|
455
509
|
context 'when registering a type for symbols' do
|
456
510
|
before { packer.register_type(0x00, ::Symbol, :to_msgpack_ext) }
|
457
511
|
|
data/spec/spec_helper.rb
CHANGED
@@ -15,10 +15,37 @@ end
|
|
15
15
|
|
16
16
|
require 'msgpack'
|
17
17
|
|
18
|
+
if GC.respond_to?(:verify_compaction_references)
|
19
|
+
# This method was added in Ruby 3.0.0. Calling it this way asks the GC to
|
20
|
+
# move objects around, helping to find object movement bugs.
|
21
|
+
GC.verify_compaction_references(double_heap: true, toward: :empty)
|
22
|
+
end
|
23
|
+
|
24
|
+
if GC.respond_to?(:auto_compact=)
|
25
|
+
GC.auto_compact = true
|
26
|
+
end
|
27
|
+
|
18
28
|
def java?
|
19
29
|
/java/ =~ RUBY_PLATFORM
|
20
30
|
end
|
21
31
|
|
32
|
+
# checking if Hash#[]= (rb_hash_aset) dedupes string keys
|
33
|
+
def automatic_string_keys_deduplication?
|
34
|
+
h = {}
|
35
|
+
x = {}
|
36
|
+
r = rand.to_s
|
37
|
+
h[%W(#{r}).join('')] = :foo
|
38
|
+
x[%W(#{r}).join('')] = :foo
|
39
|
+
|
40
|
+
x.keys[0].equal?(h.keys[0])
|
41
|
+
end
|
42
|
+
|
43
|
+
def string_deduplication?
|
44
|
+
r1 = rand.to_s
|
45
|
+
r2 = r1.dup
|
46
|
+
(-r1).equal?(-r2)
|
47
|
+
end
|
48
|
+
|
22
49
|
if java?
|
23
50
|
RSpec.configure do |c|
|
24
51
|
c.treat_symbols_as_metadata_keys_with_true_values = true
|
@@ -0,0 +1,161 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
IS_JRUBY = Kernel.const_defined?(:JRUBY_VERSION)
|
6
|
+
|
7
|
+
describe MessagePack::Timestamp do
|
8
|
+
describe 'malformed format' do
|
9
|
+
it do
|
10
|
+
expect do
|
11
|
+
MessagePack::Timestamp.from_msgpack_ext([0xd4, 0x00].pack("C*"))
|
12
|
+
end.to raise_error(MessagePack::MalformedFormatError)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'register_type with Time' do
|
17
|
+
let(:factory) do
|
18
|
+
factory = MessagePack::Factory.new
|
19
|
+
factory.register_type(
|
20
|
+
MessagePack::Timestamp::TYPE,
|
21
|
+
Time,
|
22
|
+
packer: MessagePack::Time::Packer,
|
23
|
+
unpacker: MessagePack::Time::Unpacker
|
24
|
+
)
|
25
|
+
factory
|
26
|
+
end
|
27
|
+
|
28
|
+
let(:time) { Time.local(2019, 6, 17, 1, 2, 3, 123_456_789 / 1000.0) }
|
29
|
+
it 'serializes and deserializes Time' do
|
30
|
+
prefix_fixext8_with_type_id = [0xd7, -1].pack("c*")
|
31
|
+
|
32
|
+
packed = factory.pack(time)
|
33
|
+
expect(packed).to start_with(prefix_fixext8_with_type_id)
|
34
|
+
expect(packed.size).to eq(10)
|
35
|
+
unpacked = factory.unpack(packed)
|
36
|
+
expect(unpacked.to_i).to eq(time.to_i)
|
37
|
+
expect(unpacked.to_f).to eq(time.to_f)
|
38
|
+
# expect(unpacked).to eq(time) # we can't do it because of nsec (rational vs float?)
|
39
|
+
end
|
40
|
+
|
41
|
+
let(:time_without_nsec) { Time.local(2019, 6, 17, 1, 2, 3, 0) }
|
42
|
+
it 'serializes time without nanosec as fixext4' do
|
43
|
+
prefix_fixext4_with_type_id = [0xd6, -1].pack("c*")
|
44
|
+
|
45
|
+
packed = factory.pack(time_without_nsec)
|
46
|
+
expect(packed).to start_with(prefix_fixext4_with_type_id)
|
47
|
+
expect(packed.size).to eq(6)
|
48
|
+
unpacked = factory.unpack(packed)
|
49
|
+
expect(unpacked).to eq(time_without_nsec)
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:time_after_2514) { Time.at(1 << 34) } # the max num of 34bit int means 2514-05-30 01:53:04 UTC
|
53
|
+
it 'serializes time after 2038 as ext8' do
|
54
|
+
prefix_ext8_with_12bytes_payload_and_type_id = [0xc7, 12, -1].pack("c*")
|
55
|
+
|
56
|
+
expect(time_after_2514.to_i).to be > 0xffffffff
|
57
|
+
packed = factory.pack(time_after_2514)
|
58
|
+
expect(packed).to start_with(prefix_ext8_with_12bytes_payload_and_type_id)
|
59
|
+
expect(packed.size).to eq(15)
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'runs correctly (regression)' do
|
63
|
+
expect(factory.unpack(factory.pack(Time.utc(2200)))).to eq(Time.utc(2200))
|
64
|
+
end
|
65
|
+
|
66
|
+
let(:time32_max) { Time.new(2106, 2, 7, 6, 28, 15, "+00:00") }
|
67
|
+
it 'is serialized into timestamp32' do
|
68
|
+
expect(factory.pack(time32_max).size).to be 6
|
69
|
+
expect(factory.unpack(factory.pack(time32_max)).utc).to eq(time32_max)
|
70
|
+
end
|
71
|
+
|
72
|
+
let(:time64_min) { Time.new(2106, 2, 7, 6, 28, 16, "+00:00") }
|
73
|
+
it 'is serialized into timestamp64' do
|
74
|
+
expect(factory.pack(time64_min).size).to be 10
|
75
|
+
expect(factory.unpack(factory.pack(time64_min)).utc).to eq(time64_min)
|
76
|
+
end
|
77
|
+
|
78
|
+
let(:time64_max) { Time.at(Time.new(2514, 5, 30, 1, 53, 3, "+00:00").to_i, 999999999 / 1000.0r).utc } # TODO: use Time.at(sec, nsec, :nsec) when removing Ruby 2.4 from the list
|
79
|
+
it 'is serialized into timestamp64' do
|
80
|
+
expect(factory.pack(time64_max).size).to be 10
|
81
|
+
expect(factory.unpack(factory.pack(time64_max)).utc).to eq(time64_max)
|
82
|
+
end
|
83
|
+
|
84
|
+
let(:time96_positive_min) { Time.new(2514, 5, 30, 1, 53, 4, "+00:00") }
|
85
|
+
it 'is serialized into timestamp96' do
|
86
|
+
expect(factory.pack(time96_positive_min).size).to be 15
|
87
|
+
expect(factory.unpack(factory.pack(time96_positive_min)).utc).to eq(time96_positive_min)
|
88
|
+
end
|
89
|
+
|
90
|
+
let(:time96_min) { Time.at(-2**63).utc }
|
91
|
+
it 'is serialized into timestamp96' do
|
92
|
+
skip if IS_JRUBY # JRuby cannot handle numerics larger than long
|
93
|
+
expect(factory.pack(time96_min).size).to be 15
|
94
|
+
expect(factory.unpack(factory.pack(time96_min)).utc).to eq(time96_min)
|
95
|
+
end
|
96
|
+
|
97
|
+
let(:time96_max) { Time.at(2**63 - 1).utc }
|
98
|
+
it 'is serialized into timestamp96' do
|
99
|
+
skip if IS_JRUBY # JRuby cannot handle numerics larger than long
|
100
|
+
expect(factory.pack(time96_max).size).to be 15
|
101
|
+
expect(factory.unpack(factory.pack(time96_max)).utc).to eq(time96_max)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe 'register_type with MessagePack::Timestamp' do
|
106
|
+
let(:factory) do
|
107
|
+
factory = MessagePack::Factory.new
|
108
|
+
factory.register_type(MessagePack::Timestamp::TYPE, MessagePack::Timestamp)
|
109
|
+
factory
|
110
|
+
end
|
111
|
+
|
112
|
+
let(:timestamp) { MessagePack::Timestamp.new(Time.now.tv_sec, 123_456_789) }
|
113
|
+
it 'serializes and deserializes MessagePack::Timestamp' do
|
114
|
+
packed = factory.pack(timestamp)
|
115
|
+
unpacked = factory.unpack(packed)
|
116
|
+
expect(unpacked).to eq(timestamp)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'timestamp32' do
|
121
|
+
it 'handles [1, 0]' do
|
122
|
+
t = MessagePack::Timestamp.new(1, 0)
|
123
|
+
|
124
|
+
payload = t.to_msgpack_ext
|
125
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
126
|
+
|
127
|
+
expect(unpacked).to eq(t)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
describe 'timestamp64' do
|
132
|
+
it 'handles [1, 1]' do
|
133
|
+
t = MessagePack::Timestamp.new(1, 1)
|
134
|
+
|
135
|
+
payload = t.to_msgpack_ext
|
136
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
137
|
+
|
138
|
+
expect(unpacked).to eq(t)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe 'timestamp96' do
|
143
|
+
it 'handles [-1, 0]' do
|
144
|
+
t = MessagePack::Timestamp.new(-1, 0)
|
145
|
+
|
146
|
+
payload = t.to_msgpack_ext
|
147
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
148
|
+
|
149
|
+
expect(unpacked).to eq(t)
|
150
|
+
end
|
151
|
+
|
152
|
+
it 'handles [-1, 999_999_999]' do
|
153
|
+
t = MessagePack::Timestamp.new(-1, 999_999_999)
|
154
|
+
|
155
|
+
payload = t.to_msgpack_ext
|
156
|
+
unpacked = MessagePack::Timestamp.from_msgpack_ext(payload)
|
157
|
+
|
158
|
+
expect(unpacked).to eq(t)
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
data/spec/unpacker_spec.rb
CHANGED
@@ -18,13 +18,35 @@ describe MessagePack::Unpacker do
|
|
18
18
|
it 'gets options to specify how to unpack values' do
|
19
19
|
u1 = MessagePack::Unpacker.new
|
20
20
|
u1.symbolize_keys?.should == false
|
21
|
+
u1.freeze?.should == false
|
21
22
|
u1.allow_unknown_ext?.should == false
|
22
23
|
|
23
|
-
u2 = MessagePack::Unpacker.new(symbolize_keys: true, allow_unknown_ext: true)
|
24
|
+
u2 = MessagePack::Unpacker.new(symbolize_keys: true, freeze: true, allow_unknown_ext: true)
|
24
25
|
u2.symbolize_keys?.should == true
|
26
|
+
u2.freeze?.should == true
|
25
27
|
u2.allow_unknown_ext?.should == true
|
26
28
|
end
|
27
29
|
|
30
|
+
if automatic_string_keys_deduplication?
|
31
|
+
it 'ensure string hash keys are deduplicated' do
|
32
|
+
sample_data = [{"foo" => 1}, {"foo" => 2}]
|
33
|
+
sample_packed = MessagePack.pack(sample_data).force_encoding('ASCII-8BIT')
|
34
|
+
unpacker.feed(sample_packed)
|
35
|
+
hashes = nil
|
36
|
+
unpacker.each { |obj| hashes = obj }
|
37
|
+
expect(hashes[0].keys.first).to equal(hashes[1].keys.first)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'ensure strings are not deduplicated' do
|
41
|
+
sample_data = ["foo"]
|
42
|
+
sample_packed = MessagePack.pack(sample_data).force_encoding('ASCII-8BIT')
|
43
|
+
unpacker.feed(sample_packed)
|
44
|
+
ary = nil
|
45
|
+
unpacker.each { |obj| ary = obj }
|
46
|
+
expect(ary.first.frozen?).to eq(false)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
28
50
|
it 'gets IO or object which has #read to read data from it' do
|
29
51
|
sample_data = {"message" => "morning!", "num" => 1}
|
30
52
|
sample_packed = MessagePack.pack(sample_data).force_encoding('ASCII-8BIT')
|
@@ -621,6 +643,14 @@ describe MessagePack::Unpacker do
|
|
621
643
|
array = ['foo'] * 10_000
|
622
644
|
MessagePack.unpack(MessagePack.pack(array)).size.should == 10_000
|
623
645
|
end
|
646
|
+
|
647
|
+
it 'preserves string encoding (issue #200)' do
|
648
|
+
string = 'a'.force_encoding(Encoding::UTF_8)
|
649
|
+
MessagePack.unpack(MessagePack.pack(string)).encoding.should == string.encoding
|
650
|
+
|
651
|
+
string *= 256
|
652
|
+
MessagePack.unpack(MessagePack.pack(string)).encoding.should == string.encoding
|
653
|
+
end
|
624
654
|
end
|
625
655
|
|
626
656
|
context 'extensions' do
|
@@ -651,6 +681,88 @@ describe MessagePack::Unpacker do
|
|
651
681
|
end
|
652
682
|
end
|
653
683
|
|
684
|
+
context 'freeze' do
|
685
|
+
let :struct do
|
686
|
+
{'hello' => 'world', 'nested' => ['object', {'structure' => true}]}
|
687
|
+
end
|
688
|
+
|
689
|
+
let :buffer do
|
690
|
+
MessagePack.pack(struct)
|
691
|
+
end
|
692
|
+
|
693
|
+
let :unpacker do
|
694
|
+
described_class.new(:freeze => true)
|
695
|
+
end
|
696
|
+
|
697
|
+
it 'can freeze objects when using .unpack' do
|
698
|
+
parsed_struct = MessagePack.unpack(buffer, freeze: true)
|
699
|
+
parsed_struct.should == struct
|
700
|
+
|
701
|
+
parsed_struct.should be_frozen
|
702
|
+
parsed_struct['hello'].should be_frozen
|
703
|
+
parsed_struct['nested'].should be_frozen
|
704
|
+
parsed_struct['nested'][0].should be_frozen
|
705
|
+
parsed_struct['nested'][1].should be_frozen
|
706
|
+
|
707
|
+
if string_deduplication?
|
708
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
709
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
710
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
711
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
712
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
713
|
+
end
|
714
|
+
end
|
715
|
+
|
716
|
+
it 'can freeze objects when using #each' do
|
717
|
+
objs = []
|
718
|
+
unpacker.feed(buffer)
|
719
|
+
unpacker.each do |obj|
|
720
|
+
objs << obj
|
721
|
+
end
|
722
|
+
|
723
|
+
parsed_struct = objs.first
|
724
|
+
parsed_struct.should == struct
|
725
|
+
|
726
|
+
parsed_struct.should be_frozen
|
727
|
+
parsed_struct['hello'].should be_frozen
|
728
|
+
parsed_struct['nested'].should be_frozen
|
729
|
+
parsed_struct['nested'][0].should be_frozen
|
730
|
+
parsed_struct['nested'][1].should be_frozen
|
731
|
+
|
732
|
+
if string_deduplication?
|
733
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
734
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
735
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
736
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
737
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
738
|
+
end
|
739
|
+
end
|
740
|
+
|
741
|
+
it 'can freeze objects when using #feed_each' do
|
742
|
+
objs = []
|
743
|
+
unpacker.feed_each(buffer) do |obj|
|
744
|
+
objs << obj
|
745
|
+
end
|
746
|
+
|
747
|
+
parsed_struct = objs.first
|
748
|
+
parsed_struct.should == struct
|
749
|
+
|
750
|
+
parsed_struct.should be_frozen
|
751
|
+
parsed_struct['hello'].should be_frozen
|
752
|
+
parsed_struct['nested'].should be_frozen
|
753
|
+
parsed_struct['nested'][0].should be_frozen
|
754
|
+
parsed_struct['nested'][1].should be_frozen
|
755
|
+
|
756
|
+
if string_deduplication?
|
757
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
758
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
759
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
760
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
761
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
762
|
+
end
|
763
|
+
end
|
764
|
+
end
|
765
|
+
|
654
766
|
context 'binary encoding', :encodings do
|
655
767
|
let :buffer do
|
656
768
|
MessagePack.pack({'hello' => 'world', 'nested' => ['object', {'structure' => true}]})
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
- Theo Hultberg
|
9
9
|
- Satoshi Tagomori
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2022-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -44,30 +44,16 @@ dependencies:
|
|
44
44
|
name: rake-compiler
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- - "
|
48
|
-
- !ruby/object:Gem::Version
|
49
|
-
version: '1.0'
|
50
|
-
type: :development
|
51
|
-
prerelease: false
|
52
|
-
version_requirements: !ruby/object:Gem::Requirement
|
53
|
-
requirements:
|
54
|
-
- - "~>"
|
55
|
-
- !ruby/object:Gem::Version
|
56
|
-
version: '1.0'
|
57
|
-
- !ruby/object:Gem::Dependency
|
58
|
-
name: rake-compiler-dock
|
59
|
-
requirement: !ruby/object:Gem::Requirement
|
60
|
-
requirements:
|
61
|
-
- - "~>"
|
47
|
+
- - ">="
|
62
48
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
49
|
+
version: 1.1.9
|
64
50
|
type: :development
|
65
51
|
prerelease: false
|
66
52
|
version_requirements: !ruby/object:Gem::Requirement
|
67
53
|
requirements:
|
68
|
-
- - "
|
54
|
+
- - ">="
|
69
55
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
56
|
+
version: 1.1.9
|
71
57
|
- !ruby/object:Gem::Dependency
|
72
58
|
name: rspec
|
73
59
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,13 +108,13 @@ extensions:
|
|
122
108
|
- ext/msgpack/extconf.rb
|
123
109
|
extra_rdoc_files: []
|
124
110
|
files:
|
111
|
+
- ".github/workflows/ci.yaml"
|
125
112
|
- ".gitignore"
|
126
113
|
- ".rubocop.yml"
|
127
|
-
- ".travis.yml"
|
128
114
|
- ChangeLog
|
129
115
|
- Gemfile
|
130
116
|
- LICENSE
|
131
|
-
- README.
|
117
|
+
- README.md
|
132
118
|
- Rakefile
|
133
119
|
- appveyor.yml
|
134
120
|
- bench/pack.rb
|
@@ -148,6 +134,8 @@ files:
|
|
148
134
|
- doclib/msgpack/extension_value.rb
|
149
135
|
- doclib/msgpack/factory.rb
|
150
136
|
- doclib/msgpack/packer.rb
|
137
|
+
- doclib/msgpack/time.rb
|
138
|
+
- doclib/msgpack/timestamp.rb
|
151
139
|
- doclib/msgpack/unpacker.rb
|
152
140
|
- ext/java/org/msgpack/jruby/Buffer.java
|
153
141
|
- ext/java/org/msgpack/jruby/Decoder.java
|
@@ -192,6 +180,8 @@ files:
|
|
192
180
|
- lib/msgpack/factory.rb
|
193
181
|
- lib/msgpack/packer.rb
|
194
182
|
- lib/msgpack/symbol.rb
|
183
|
+
- lib/msgpack/time.rb
|
184
|
+
- lib/msgpack/timestamp.rb
|
195
185
|
- lib/msgpack/unpacker.rb
|
196
186
|
- lib/msgpack/version.rb
|
197
187
|
- msgpack.gemspec
|
@@ -217,13 +207,14 @@ files:
|
|
217
207
|
- spec/packer_spec.rb
|
218
208
|
- spec/random_compat.rb
|
219
209
|
- spec/spec_helper.rb
|
210
|
+
- spec/timestamp_spec.rb
|
220
211
|
- spec/unpack_spec.rb
|
221
212
|
- spec/unpacker_spec.rb
|
222
213
|
homepage: http://msgpack.org/
|
223
214
|
licenses:
|
224
215
|
- Apache 2.0
|
225
216
|
metadata: {}
|
226
|
-
post_install_message:
|
217
|
+
post_install_message:
|
227
218
|
rdoc_options: []
|
228
219
|
require_paths:
|
229
220
|
- lib
|
@@ -231,38 +222,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
222
|
requirements:
|
232
223
|
- - ">="
|
233
224
|
- !ruby/object:Gem::Version
|
234
|
-
version: '
|
225
|
+
version: '2.4'
|
235
226
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
227
|
requirements:
|
237
228
|
- - ">="
|
238
229
|
- !ruby/object:Gem::Version
|
239
230
|
version: '0'
|
240
231
|
requirements: []
|
241
|
-
rubygems_version: 3.
|
242
|
-
signing_key:
|
232
|
+
rubygems_version: 3.3.3
|
233
|
+
signing_key:
|
243
234
|
specification_version: 4
|
244
235
|
summary: MessagePack, a binary-based efficient data interchange format.
|
245
|
-
test_files:
|
246
|
-
- spec/cases.json
|
247
|
-
- spec/cases.msg
|
248
|
-
- spec/cases_compact.msg
|
249
|
-
- spec/cases_spec.rb
|
250
|
-
- spec/cruby/buffer_io_spec.rb
|
251
|
-
- spec/cruby/buffer_packer.rb
|
252
|
-
- spec/cruby/buffer_spec.rb
|
253
|
-
- spec/cruby/buffer_unpacker.rb
|
254
|
-
- spec/cruby/unpacker_spec.rb
|
255
|
-
- spec/ext_value_spec.rb
|
256
|
-
- spec/exttypes.rb
|
257
|
-
- spec/factory_spec.rb
|
258
|
-
- spec/format_spec.rb
|
259
|
-
- spec/jruby/benchmarks/shootout_bm.rb
|
260
|
-
- spec/jruby/benchmarks/symbolize_keys_bm.rb
|
261
|
-
- spec/jruby/unpacker_spec.rb
|
262
|
-
- spec/msgpack_spec.rb
|
263
|
-
- spec/pack_spec.rb
|
264
|
-
- spec/packer_spec.rb
|
265
|
-
- spec/random_compat.rb
|
266
|
-
- spec/spec_helper.rb
|
267
|
-
- spec/unpack_spec.rb
|
268
|
-
- spec/unpacker_spec.rb
|
236
|
+
test_files: []
|
data/.travis.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
sudo: false
|
4
|
-
|
5
|
-
branches:
|
6
|
-
only:
|
7
|
-
- master
|
8
|
-
|
9
|
-
gemfile:
|
10
|
-
- Gemfile
|
11
|
-
|
12
|
-
before_install:
|
13
|
-
# This is only for Ruby 2.5.0, Bundler 1.16.1 and rubygems 2.7.3
|
14
|
-
# See https://github.com/travis-ci/travis-ci/issues/8969
|
15
|
-
- "[ \"x2.7.3\" = \"x\"$(gem --version) ] && gem update --system --no-document || echo \"no need to update rubygem\""
|
16
|
-
|
17
|
-
# http://rubies.travis-ci.org/
|
18
|
-
matrix:
|
19
|
-
include:
|
20
|
-
- rvm: 2.3.8
|
21
|
-
os: linux
|
22
|
-
- rvm: 2.4.5
|
23
|
-
os: linux
|
24
|
-
- rvm: 2.5.3
|
25
|
-
os: linux
|
26
|
-
- rvm: 2.6.0
|
27
|
-
os: linux
|
28
|
-
- rvm: 2.6.0
|
29
|
-
os: osx
|
30
|
-
- rvm: ruby-head
|
31
|
-
os: linux
|
32
|
-
- rvm: jruby-9.1.9.0
|
33
|
-
os: linux
|
34
|
-
- rvm: jruby-head
|
35
|
-
os: linux
|
36
|
-
- rvm: jruby-19mode
|
37
|
-
os: linux
|
38
|
-
allow_failures:
|
39
|
-
- rvm: ruby-head
|
40
|
-
- rvm: jruby-head
|
41
|
-
- rvm: jruby-19mode
|