msgpack 1.4.2 → 1.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +89 -0
  3. data/README.md +73 -13
  4. data/ext/java/org/msgpack/jruby/Buffer.java +26 -19
  5. data/ext/java/org/msgpack/jruby/Decoder.java +29 -21
  6. data/ext/java/org/msgpack/jruby/Encoder.java +68 -30
  7. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +43 -64
  8. data/ext/java/org/msgpack/jruby/ExtensionValue.java +6 -9
  9. data/ext/java/org/msgpack/jruby/Factory.java +43 -42
  10. data/ext/java/org/msgpack/jruby/Packer.java +37 -40
  11. data/ext/java/org/msgpack/jruby/Unpacker.java +80 -73
  12. data/ext/msgpack/buffer.c +54 -74
  13. data/ext/msgpack/buffer.h +21 -18
  14. data/ext/msgpack/buffer_class.c +161 -52
  15. data/ext/msgpack/buffer_class.h +1 -0
  16. data/ext/msgpack/compat.h +0 -99
  17. data/ext/msgpack/extconf.rb +25 -46
  18. data/ext/msgpack/factory_class.c +143 -87
  19. data/ext/msgpack/packer.c +66 -43
  20. data/ext/msgpack/packer.h +25 -20
  21. data/ext/msgpack/packer_class.c +102 -130
  22. data/ext/msgpack/packer_class.h +11 -0
  23. data/ext/msgpack/packer_ext_registry.c +35 -40
  24. data/ext/msgpack/packer_ext_registry.h +41 -38
  25. data/ext/msgpack/rbinit.c +1 -1
  26. data/ext/msgpack/rmem.c +3 -4
  27. data/ext/msgpack/sysdep.h +5 -2
  28. data/ext/msgpack/unpacker.c +136 -111
  29. data/ext/msgpack/unpacker.h +16 -13
  30. data/ext/msgpack/unpacker_class.c +86 -126
  31. data/ext/msgpack/unpacker_class.h +11 -0
  32. data/ext/msgpack/unpacker_ext_registry.c +40 -28
  33. data/ext/msgpack/unpacker_ext_registry.h +21 -18
  34. data/lib/msgpack/bigint.rb +69 -0
  35. data/lib/msgpack/buffer.rb +9 -0
  36. data/lib/msgpack/factory.rb +140 -10
  37. data/lib/msgpack/packer.rb +10 -1
  38. data/lib/msgpack/symbol.rb +21 -4
  39. data/lib/msgpack/time.rb +1 -1
  40. data/lib/msgpack/unpacker.rb +14 -1
  41. data/lib/msgpack/version.rb +1 -1
  42. data/lib/msgpack.rb +6 -7
  43. data/msgpack.gemspec +8 -5
  44. metadata +37 -82
  45. data/.gitignore +0 -23
  46. data/.rubocop.yml +0 -36
  47. data/.travis.yml +0 -39
  48. data/Gemfile +0 -9
  49. data/Rakefile +0 -71
  50. data/appveyor.yml +0 -18
  51. data/bench/pack.rb +0 -23
  52. data/bench/pack_log.rb +0 -33
  53. data/bench/pack_log_long.rb +0 -65
  54. data/bench/pack_symbols.rb +0 -28
  55. data/bench/run.sh +0 -14
  56. data/bench/run_long.sh +0 -35
  57. data/bench/run_symbols.sh +0 -26
  58. data/bench/unpack.rb +0 -21
  59. data/bench/unpack_log.rb +0 -34
  60. data/bench/unpack_log_long.rb +0 -67
  61. data/doclib/msgpack/buffer.rb +0 -193
  62. data/doclib/msgpack/core_ext.rb +0 -101
  63. data/doclib/msgpack/error.rb +0 -19
  64. data/doclib/msgpack/extension_value.rb +0 -9
  65. data/doclib/msgpack/factory.rb +0 -101
  66. data/doclib/msgpack/packer.rb +0 -208
  67. data/doclib/msgpack/time.rb +0 -22
  68. data/doclib/msgpack/timestamp.rb +0 -44
  69. data/doclib/msgpack/unpacker.rb +0 -183
  70. data/doclib/msgpack.rb +0 -87
  71. data/msgpack.org.md +0 -46
  72. data/spec/cases.json +0 -1
  73. data/spec/cases.msg +0 -0
  74. data/spec/cases_compact.msg +0 -0
  75. data/spec/cases_spec.rb +0 -39
  76. data/spec/cruby/buffer_io_spec.rb +0 -255
  77. data/spec/cruby/buffer_packer.rb +0 -29
  78. data/spec/cruby/buffer_spec.rb +0 -575
  79. data/spec/cruby/buffer_unpacker.rb +0 -19
  80. data/spec/cruby/unpacker_spec.rb +0 -70
  81. data/spec/ext_value_spec.rb +0 -99
  82. data/spec/exttypes.rb +0 -51
  83. data/spec/factory_spec.rb +0 -367
  84. data/spec/format_spec.rb +0 -301
  85. data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
  86. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
  87. data/spec/jruby/unpacker_spec.rb +0 -186
  88. data/spec/msgpack_spec.rb +0 -214
  89. data/spec/pack_spec.rb +0 -61
  90. data/spec/packer_spec.rb +0 -557
  91. data/spec/random_compat.rb +0 -24
  92. data/spec/spec_helper.rb +0 -55
  93. data/spec/timestamp_spec.rb +0 -121
  94. data/spec/unpack_spec.rb +0 -57
  95. data/spec/unpacker_spec.rb +0 -819
@@ -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