msgpack 0.7.6-java → 1.0.0-java
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/lib/msgpack.rb +1 -0
- data/lib/msgpack/msgpack.jar +0 -0
- data/lib/msgpack/symbol.rb +9 -0
- data/lib/msgpack/version.rb +1 -1
- data/spec/factory_spec.rb +60 -0
- data/spec/packer_spec.rb +36 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 562692a376709457f14a581c27339a94e4221279
|
4
|
+
data.tar.gz: 81353eb21eecadd00f74f535ec2463184d296c31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0da9c7a1cb5c02e31eff7d5f15652ae13a57991a19380d92d5b75172446abe3de7816e699498f8dce8c53289a789e5e51f73f3a1251666330b364d5ea278dcfe
|
7
|
+
data.tar.gz: 06017bbfb8da463004c839791b68d0cd246435af15ad7d1edba431d2956b332d8040f9d7d9c1c7b88b31d97c91b93622c38a0dfd85069da0a719a350ba85c408
|
data/lib/msgpack.rb
CHANGED
data/lib/msgpack/msgpack.jar
CHANGED
Binary file
|
data/lib/msgpack/version.rb
CHANGED
data/spec/factory_spec.rb
CHANGED
@@ -210,6 +210,66 @@ describe MessagePack::Factory do
|
|
210
210
|
end
|
211
211
|
end
|
212
212
|
|
213
|
+
describe 'the special treatment of symbols with ext type' do
|
214
|
+
let(:packer) { subject.packer }
|
215
|
+
let(:unpacker) { subject.unpacker }
|
216
|
+
|
217
|
+
def symbol_after_roundtrip
|
218
|
+
packed_symbol = packer.pack(:symbol).to_s
|
219
|
+
unpacker.feed(packed_symbol).unpack
|
220
|
+
end
|
221
|
+
|
222
|
+
context 'if no ext type is registered for symbols' do
|
223
|
+
it 'converts symbols to string' do
|
224
|
+
expect(symbol_after_roundtrip).to eq 'symbol'
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
context 'if an ext type is registered for symbols' do
|
229
|
+
context 'if using the default serializer' do
|
230
|
+
before { subject.register_type(0x00, ::Symbol) }
|
231
|
+
|
232
|
+
it 'lets symbols survive a roundtrip' do
|
233
|
+
expect(symbol_after_roundtrip).to be :symbol
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
context 'if using a custom serializer' do
|
238
|
+
before do
|
239
|
+
class Symbol
|
240
|
+
alias_method :to_msgpack_ext_orig, :to_msgpack_ext
|
241
|
+
def to_msgpack_ext
|
242
|
+
self.to_s.codepoints.to_a.pack('n*')
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
class << Symbol
|
247
|
+
alias_method :from_msgpack_ext_orig, :from_msgpack_ext
|
248
|
+
def from_msgpack_ext(data)
|
249
|
+
data.unpack('n*').map(&:chr).join.to_sym
|
250
|
+
end
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
before { subject.register_type(0x00, ::Symbol) }
|
255
|
+
|
256
|
+
it 'lets symbols survive a roundtrip' do
|
257
|
+
expect(symbol_after_roundtrip).to be :symbol
|
258
|
+
end
|
259
|
+
|
260
|
+
after do
|
261
|
+
class Symbol
|
262
|
+
alias_method :to_msgpack_ext, :to_msgpack_ext_orig
|
263
|
+
end
|
264
|
+
|
265
|
+
class << Symbol
|
266
|
+
alias_method :from_msgpack_ext, :from_msgpack_ext_orig
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
213
273
|
describe 'DefaultFactory' do
|
214
274
|
it 'is a factory' do
|
215
275
|
MessagePack::DefaultFactory.should be_kind_of(MessagePack::Factory)
|
data/spec/packer_spec.rb
CHANGED
@@ -323,6 +323,42 @@ describe MessagePack::Packer do
|
|
323
323
|
expect(two[:class]).to eq(ValueTwo)
|
324
324
|
expect(two[:packer]).to eq(:to_msgpack_ext)
|
325
325
|
end
|
326
|
+
|
327
|
+
context 'when registering a type for symbols' do
|
328
|
+
before { packer.register_type(0x00, ::Symbol, :to_msgpack_ext) }
|
329
|
+
|
330
|
+
it 'packs symbols in an ext type' do
|
331
|
+
expect(packer.pack(:symbol).to_s).to eq "\xc7\x06\x00symbol"
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
335
|
+
|
336
|
+
describe "fixnum and bignum" do
|
337
|
+
it "fixnum.to_msgpack" do
|
338
|
+
23.to_msgpack.should == "\x17"
|
339
|
+
end
|
340
|
+
|
341
|
+
it "fixnum.to_msgpack(packer)" do
|
342
|
+
23.to_msgpack(packer)
|
343
|
+
packer.to_s.should == "\x17"
|
344
|
+
end
|
345
|
+
|
346
|
+
it "bignum.to_msgpack" do
|
347
|
+
-4294967296.to_msgpack.should == "\xD3\xFF\xFF\xFF\xFF\x00\x00\x00\x00"
|
348
|
+
end
|
349
|
+
|
350
|
+
it "bignum.to_msgpack(packer)" do
|
351
|
+
-4294967296.to_msgpack(packer)
|
352
|
+
packer.to_s.should == "\xD3\xFF\xFF\xFF\xFF\x00\x00\x00\x00"
|
353
|
+
end
|
354
|
+
|
355
|
+
it "unpack(fixnum)" do
|
356
|
+
MessagePack.unpack("\x17").should == 23
|
357
|
+
end
|
358
|
+
|
359
|
+
it "unpack(bignum)" do
|
360
|
+
MessagePack.unpack("\xD3\xFF\xFF\xFF\xFF\x00\x00\x00\x00").should == -4294967296
|
361
|
+
end
|
326
362
|
end
|
327
363
|
|
328
364
|
describe "ext formats" 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: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-
|
13
|
+
date: 2016-07-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/msgpack/factory.rb
|
110
110
|
- lib/msgpack/msgpack.jar
|
111
111
|
- lib/msgpack/packer.rb
|
112
|
+
- lib/msgpack/symbol.rb
|
112
113
|
- lib/msgpack/unpacker.rb
|
113
114
|
- lib/msgpack/version.rb
|
114
115
|
- spec/cases.json
|