msgpack 0.5.9 → 0.5.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -2
- data/.travis.yml +2 -3
- data/ChangeLog +6 -0
- data/Rakefile +5 -1
- data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
- data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
- data/ext/java/org/msgpack/jruby/Encoder.java +309 -0
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
- data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +113 -0
- data/ext/java/org/msgpack/jruby/Packer.java +78 -0
- data/ext/java/org/msgpack/jruby/Types.java +37 -0
- data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
- data/lib/msgpack.rb +11 -4
- data/lib/msgpack/version.rb +1 -1
- data/msgpack.gemspec +11 -6
- data/spec/{packer_spec.rb → cruby/packer_spec.rb} +0 -0
- data/spec/{unpacker_spec.rb → cruby/unpacker_spec.rb} +0 -0
- data/spec/format_spec.rb +32 -30
- data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
- data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
- data/spec/jruby/msgpack_spec.rb +136 -0
- data/spec/pack_spec.rb +67 -0
- data/spec/spec_helper.rb +10 -4
- data/spec/unpack_spec.rb +72 -0
- metadata +30 -7
data/spec/pack_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'stringio'
|
5
|
+
if defined?(Encoding)
|
6
|
+
Encoding.default_external = 'ASCII-8BIT'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe MessagePack do
|
10
|
+
it 'to_msgpack returns String' do
|
11
|
+
nil.to_msgpack.class.should == String
|
12
|
+
true.to_msgpack.class.should == String
|
13
|
+
false.to_msgpack.class.should == String
|
14
|
+
1.to_msgpack.class.should == String
|
15
|
+
1.0.to_msgpack.class.should == String
|
16
|
+
"".to_msgpack.class.should == String
|
17
|
+
Hash.new.to_msgpack.class.should == String
|
18
|
+
Array.new.to_msgpack.class.should == String
|
19
|
+
end
|
20
|
+
|
21
|
+
class CustomPack01
|
22
|
+
def to_msgpack(pk=nil)
|
23
|
+
return MessagePack.pack(self, pk) unless pk.class == MessagePack::Packer
|
24
|
+
pk.write_array_header(2)
|
25
|
+
pk.write(1)
|
26
|
+
pk.write(2)
|
27
|
+
return pk
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class CustomPack02
|
32
|
+
def to_msgpack(pk=nil)
|
33
|
+
[1,2].to_msgpack(pk)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'calls custom to_msgpack method' do
|
38
|
+
if /java/ =~ RUBY_PLATFORM
|
39
|
+
skip "custom to_msgpack fallback is not supported yet in JRuby implementation"
|
40
|
+
end
|
41
|
+
MessagePack.pack(CustomPack01.new).should == [1,2].to_msgpack
|
42
|
+
MessagePack.pack(CustomPack02.new).should == [1,2].to_msgpack
|
43
|
+
CustomPack01.new.to_msgpack.should == [1,2].to_msgpack
|
44
|
+
CustomPack02.new.to_msgpack.should == [1,2].to_msgpack
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'calls custom to_msgpack method with io' do
|
48
|
+
if /java/ =~ RUBY_PLATFORM
|
49
|
+
skip "custom to_msgpack fallback with io is not supported yet in JRuby implementation"
|
50
|
+
end
|
51
|
+
s01 = StringIO.new
|
52
|
+
MessagePack.pack(CustomPack01.new, s01)
|
53
|
+
s01.string.should == [1,2].to_msgpack
|
54
|
+
|
55
|
+
s02 = StringIO.new
|
56
|
+
MessagePack.pack(CustomPack02.new, s02)
|
57
|
+
s02.string.should == [1,2].to_msgpack
|
58
|
+
|
59
|
+
s03 = StringIO.new
|
60
|
+
CustomPack01.new.to_msgpack(s03)
|
61
|
+
s03.string.should == [1,2].to_msgpack
|
62
|
+
|
63
|
+
s04 = StringIO.new
|
64
|
+
CustomPack02.new.to_msgpack(s04)
|
65
|
+
s04.string.should == [1,2].to_msgpack
|
66
|
+
end
|
67
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,7 +15,13 @@ end
|
|
15
15
|
|
16
16
|
require 'msgpack'
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
if /java/ =~ RUBY_PLATFORM
|
19
|
+
RSpec.configure do |c|
|
20
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
21
|
+
c.filter_run_excluding :encodings => !(defined? Encoding)
|
22
|
+
end
|
23
|
+
else
|
24
|
+
Packer = MessagePack::Packer
|
25
|
+
Unpacker = MessagePack::Unpacker
|
26
|
+
Buffer = MessagePack::Buffer
|
27
|
+
end
|
data/spec/unpack_spec.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
require 'stringio'
|
5
|
+
if defined?(Encoding)
|
6
|
+
Encoding.default_external = 'ASCII-8BIT'
|
7
|
+
end
|
8
|
+
|
9
|
+
describe MessagePack do
|
10
|
+
it 'MessagePack.unpack symbolize_keys' do
|
11
|
+
symbolized_hash = {:a => 'b', :c => 'd'}
|
12
|
+
MessagePack.load(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
|
13
|
+
MessagePack.unpack(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'Unpacker#unpack symbolize_keys' do
|
17
|
+
if /java/ =~ RUBY_PLATFORM
|
18
|
+
skip "Unpacker#unpack returns nil in JRuby (incompatible)"
|
19
|
+
end
|
20
|
+
unpacker = MessagePack::Unpacker.new(:symbolize_keys => true)
|
21
|
+
symbolized_hash = {:a => 'b', :c => 'd'}
|
22
|
+
unpacker.feed(MessagePack.pack(symbolized_hash)).read.should == symbolized_hash
|
23
|
+
end
|
24
|
+
|
25
|
+
it "msgpack str 8 type" do
|
26
|
+
if /java/ =~ RUBY_PLATFORM
|
27
|
+
skip "str 8 type is not supported in JRuby (incompatibility)"
|
28
|
+
end
|
29
|
+
MessagePack.unpack([0xd9, 0x00].pack('C*')).should == ""
|
30
|
+
MessagePack.unpack([0xd9, 0x01].pack('C*') + 'a').should == "a"
|
31
|
+
MessagePack.unpack([0xd9, 0x02].pack('C*') + 'aa').should == "aa"
|
32
|
+
end
|
33
|
+
|
34
|
+
it "msgpack str 16 type" do
|
35
|
+
MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).should == ""
|
36
|
+
MessagePack.unpack([0xda, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
37
|
+
MessagePack.unpack([0xda, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "msgpack str 32 type" do
|
41
|
+
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
|
42
|
+
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
43
|
+
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "msgpack bin 8 type" do
|
47
|
+
if /java/ =~ RUBY_PLATFORM
|
48
|
+
skip "bin 8 type is not supported in JRuby (incompatibility)"
|
49
|
+
end
|
50
|
+
MessagePack.unpack([0xc4, 0x00].pack('C*')).should == ""
|
51
|
+
MessagePack.unpack([0xc4, 0x01].pack('C*') + 'a').should == "a"
|
52
|
+
MessagePack.unpack([0xc4, 0x02].pack('C*') + 'aa').should == "aa"
|
53
|
+
end
|
54
|
+
|
55
|
+
it "msgpack bin 16 type" do
|
56
|
+
if /java/ =~ RUBY_PLATFORM
|
57
|
+
skip "bin 16 type is not supported in JRuby (incompatibility)"
|
58
|
+
end
|
59
|
+
MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).should == ""
|
60
|
+
MessagePack.unpack([0xc5, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
61
|
+
MessagePack.unpack([0xc5, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "msgpack bin 32 type" do
|
65
|
+
if /java/ =~ RUBY_PLATFORM
|
66
|
+
skip "bin 32 type is not supported in JRuby (incompatibility)"
|
67
|
+
end
|
68
|
+
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
|
69
|
+
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
70
|
+
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
71
|
+
end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
|
+
- Theo Hultberg
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
@@ -97,7 +98,9 @@ dependencies:
|
|
97
98
|
description: MessagePack is a binary-based efficient object serialization library.
|
98
99
|
It enables to exchange structured objects between many languages like JSON. But
|
99
100
|
unlike JSON, it is very fast and small.
|
100
|
-
email:
|
101
|
+
email:
|
102
|
+
- frsyuki@gmail.com
|
103
|
+
- theo@iconara.net
|
101
104
|
executables: []
|
102
105
|
extensions:
|
103
106
|
- ext/msgpack/extconf.rb
|
@@ -115,6 +118,14 @@ files:
|
|
115
118
|
- doclib/msgpack/error.rb
|
116
119
|
- doclib/msgpack/packer.rb
|
117
120
|
- doclib/msgpack/unpacker.rb
|
121
|
+
- ext/java/org/msgpack/jruby/Buffer.java
|
122
|
+
- ext/java/org/msgpack/jruby/Decoder.java
|
123
|
+
- ext/java/org/msgpack/jruby/Encoder.java
|
124
|
+
- ext/java/org/msgpack/jruby/ExtensionValue.java
|
125
|
+
- ext/java/org/msgpack/jruby/MessagePackLibrary.java
|
126
|
+
- ext/java/org/msgpack/jruby/Packer.java
|
127
|
+
- ext/java/org/msgpack/jruby/Types.java
|
128
|
+
- ext/java/org/msgpack/jruby/Unpacker.java
|
118
129
|
- ext/msgpack/buffer.c
|
119
130
|
- ext/msgpack/buffer.h
|
120
131
|
- ext/msgpack/buffer_class.c
|
@@ -149,11 +160,17 @@ files:
|
|
149
160
|
- spec/cruby/buffer_packer.rb
|
150
161
|
- spec/cruby/buffer_spec.rb
|
151
162
|
- spec/cruby/buffer_unpacker.rb
|
163
|
+
- spec/cruby/packer_spec.rb
|
164
|
+
- spec/cruby/unpacker_spec.rb
|
152
165
|
- spec/format_spec.rb
|
153
|
-
- spec/
|
166
|
+
- spec/jruby/benchmarks/shootout_bm.rb
|
167
|
+
- spec/jruby/benchmarks/symbolize_keys_bm.rb
|
168
|
+
- spec/jruby/msgpack/unpacker_spec.rb
|
169
|
+
- spec/jruby/msgpack_spec.rb
|
170
|
+
- spec/pack_spec.rb
|
154
171
|
- spec/random_compat.rb
|
155
172
|
- spec/spec_helper.rb
|
156
|
-
- spec/
|
173
|
+
- spec/unpack_spec.rb
|
157
174
|
homepage: http://msgpack.org/
|
158
175
|
licenses:
|
159
176
|
- Apache 2.0
|
@@ -187,9 +204,15 @@ test_files:
|
|
187
204
|
- spec/cruby/buffer_packer.rb
|
188
205
|
- spec/cruby/buffer_spec.rb
|
189
206
|
- spec/cruby/buffer_unpacker.rb
|
207
|
+
- spec/cruby/packer_spec.rb
|
208
|
+
- spec/cruby/unpacker_spec.rb
|
190
209
|
- spec/format_spec.rb
|
191
|
-
- spec/
|
210
|
+
- spec/jruby/benchmarks/shootout_bm.rb
|
211
|
+
- spec/jruby/benchmarks/symbolize_keys_bm.rb
|
212
|
+
- spec/jruby/msgpack/unpacker_spec.rb
|
213
|
+
- spec/jruby/msgpack_spec.rb
|
214
|
+
- spec/pack_spec.rb
|
192
215
|
- spec/random_compat.rb
|
193
216
|
- spec/spec_helper.rb
|
194
|
-
- spec/
|
217
|
+
- spec/unpack_spec.rb
|
195
218
|
has_rdoc: false
|