msgpack 1.4.2 → 1.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +89 -0
- data/README.md +73 -13
- data/ext/java/org/msgpack/jruby/Buffer.java +26 -19
- data/ext/java/org/msgpack/jruby/Decoder.java +29 -21
- data/ext/java/org/msgpack/jruby/Encoder.java +68 -30
- data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +43 -64
- data/ext/java/org/msgpack/jruby/ExtensionValue.java +6 -9
- data/ext/java/org/msgpack/jruby/Factory.java +43 -42
- data/ext/java/org/msgpack/jruby/Packer.java +37 -40
- data/ext/java/org/msgpack/jruby/Unpacker.java +80 -73
- data/ext/msgpack/buffer.c +54 -74
- data/ext/msgpack/buffer.h +21 -18
- data/ext/msgpack/buffer_class.c +161 -52
- data/ext/msgpack/buffer_class.h +1 -0
- data/ext/msgpack/compat.h +0 -99
- data/ext/msgpack/extconf.rb +25 -46
- data/ext/msgpack/factory_class.c +143 -87
- data/ext/msgpack/packer.c +66 -43
- data/ext/msgpack/packer.h +25 -20
- data/ext/msgpack/packer_class.c +102 -130
- data/ext/msgpack/packer_class.h +11 -0
- data/ext/msgpack/packer_ext_registry.c +35 -40
- data/ext/msgpack/packer_ext_registry.h +41 -38
- data/ext/msgpack/rbinit.c +1 -1
- data/ext/msgpack/rmem.c +3 -4
- data/ext/msgpack/sysdep.h +5 -2
- data/ext/msgpack/unpacker.c +136 -111
- data/ext/msgpack/unpacker.h +16 -13
- data/ext/msgpack/unpacker_class.c +86 -126
- data/ext/msgpack/unpacker_class.h +11 -0
- data/ext/msgpack/unpacker_ext_registry.c +40 -28
- data/ext/msgpack/unpacker_ext_registry.h +21 -18
- data/lib/msgpack/bigint.rb +69 -0
- data/lib/msgpack/buffer.rb +9 -0
- data/lib/msgpack/factory.rb +140 -10
- data/lib/msgpack/packer.rb +10 -1
- data/lib/msgpack/symbol.rb +21 -4
- data/lib/msgpack/time.rb +1 -1
- data/lib/msgpack/unpacker.rb +14 -1
- data/lib/msgpack/version.rb +1 -1
- data/lib/msgpack.rb +6 -7
- data/msgpack.gemspec +8 -5
- metadata +37 -82
- data/.gitignore +0 -23
- data/.rubocop.yml +0 -36
- data/.travis.yml +0 -39
- data/Gemfile +0 -9
- data/Rakefile +0 -71
- data/appveyor.yml +0 -18
- data/bench/pack.rb +0 -23
- data/bench/pack_log.rb +0 -33
- data/bench/pack_log_long.rb +0 -65
- data/bench/pack_symbols.rb +0 -28
- data/bench/run.sh +0 -14
- data/bench/run_long.sh +0 -35
- data/bench/run_symbols.sh +0 -26
- data/bench/unpack.rb +0 -21
- data/bench/unpack_log.rb +0 -34
- data/bench/unpack_log_long.rb +0 -67
- data/doclib/msgpack/buffer.rb +0 -193
- data/doclib/msgpack/core_ext.rb +0 -101
- data/doclib/msgpack/error.rb +0 -19
- data/doclib/msgpack/extension_value.rb +0 -9
- data/doclib/msgpack/factory.rb +0 -101
- data/doclib/msgpack/packer.rb +0 -208
- data/doclib/msgpack/time.rb +0 -22
- data/doclib/msgpack/timestamp.rb +0 -44
- data/doclib/msgpack/unpacker.rb +0 -183
- data/doclib/msgpack.rb +0 -87
- data/msgpack.org.md +0 -46
- data/spec/cases.json +0 -1
- data/spec/cases.msg +0 -0
- data/spec/cases_compact.msg +0 -0
- data/spec/cases_spec.rb +0 -39
- data/spec/cruby/buffer_io_spec.rb +0 -255
- data/spec/cruby/buffer_packer.rb +0 -29
- data/spec/cruby/buffer_spec.rb +0 -575
- data/spec/cruby/buffer_unpacker.rb +0 -19
- data/spec/cruby/unpacker_spec.rb +0 -70
- data/spec/ext_value_spec.rb +0 -99
- data/spec/exttypes.rb +0 -51
- data/spec/factory_spec.rb +0 -367
- data/spec/format_spec.rb +0 -301
- data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
- data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
- data/spec/jruby/unpacker_spec.rb +0 -186
- data/spec/msgpack_spec.rb +0 -214
- data/spec/pack_spec.rb +0 -61
- data/spec/packer_spec.rb +0 -557
- data/spec/random_compat.rb +0 -24
- data/spec/spec_helper.rb +0 -55
- data/spec/timestamp_spec.rb +0 -121
- data/spec/unpack_spec.rb +0 -57
- data/spec/unpacker_spec.rb +0 -819
data/spec/timestamp_spec.rb
DELETED
@@ -1,121 +0,0 @@
|
|
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/unpack_spec.rb
DELETED
@@ -1,57 +0,0 @@
|
|
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#read symbolize_keys' do
|
17
|
-
unpacker = MessagePack::Unpacker.new(:symbolize_keys => true)
|
18
|
-
symbolized_hash = {:a => 'b', :c => 'd'}
|
19
|
-
unpacker.feed(MessagePack.pack(symbolized_hash)).read.should == symbolized_hash
|
20
|
-
end
|
21
|
-
|
22
|
-
it "msgpack str 8 type" do
|
23
|
-
MessagePack.unpack([0xd9, 0x00].pack('C*')).should == ""
|
24
|
-
MessagePack.unpack([0xd9, 0x01].pack('C*') + 'a').should == "a"
|
25
|
-
MessagePack.unpack([0xd9, 0x02].pack('C*') + 'aa').should == "aa"
|
26
|
-
end
|
27
|
-
|
28
|
-
it "msgpack str 16 type" do
|
29
|
-
MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).should == ""
|
30
|
-
MessagePack.unpack([0xda, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
31
|
-
MessagePack.unpack([0xda, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "msgpack str 32 type" do
|
35
|
-
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
|
36
|
-
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
37
|
-
MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
38
|
-
end
|
39
|
-
|
40
|
-
it "msgpack bin 8 type" do
|
41
|
-
MessagePack.unpack([0xc4, 0x00].pack('C*')).should == ""
|
42
|
-
MessagePack.unpack([0xc4, 0x01].pack('C*') + 'a').should == "a"
|
43
|
-
MessagePack.unpack([0xc4, 0x02].pack('C*') + 'aa').should == "aa"
|
44
|
-
end
|
45
|
-
|
46
|
-
it "msgpack bin 16 type" do
|
47
|
-
MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).should == ""
|
48
|
-
MessagePack.unpack([0xc5, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
49
|
-
MessagePack.unpack([0xc5, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "msgpack bin 32 type" do
|
53
|
-
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
|
54
|
-
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
|
55
|
-
MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
|
56
|
-
end
|
57
|
-
end
|