msgpack 1.5.6 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +14 -0
  3. data/ext/java/org/msgpack/jruby/ExtensionRegistry.java +4 -9
  4. data/ext/msgpack/buffer.c +51 -38
  5. data/ext/msgpack/buffer.h +5 -9
  6. data/ext/msgpack/buffer_class.c +62 -32
  7. data/ext/msgpack/extconf.rb +3 -5
  8. data/ext/msgpack/factory_class.c +49 -26
  9. data/ext/msgpack/packer.c +3 -4
  10. data/ext/msgpack/packer.h +2 -2
  11. data/ext/msgpack/packer_class.c +58 -63
  12. data/ext/msgpack/packer_class.h +11 -0
  13. data/ext/msgpack/packer_ext_registry.c +2 -2
  14. data/ext/msgpack/packer_ext_registry.h +2 -2
  15. data/ext/msgpack/rbinit.c +1 -1
  16. data/ext/msgpack/sysdep.h +5 -2
  17. data/ext/msgpack/unpacker.c +6 -9
  18. data/ext/msgpack/unpacker.h +4 -3
  19. data/ext/msgpack/unpacker_class.c +55 -37
  20. data/ext/msgpack/unpacker_class.h +11 -0
  21. data/ext/msgpack/unpacker_ext_registry.c +2 -2
  22. data/ext/msgpack/unpacker_ext_registry.h +2 -2
  23. data/lib/msgpack/buffer.rb +9 -0
  24. data/lib/msgpack/packer.rb +4 -0
  25. data/lib/msgpack/unpacker.rb +4 -0
  26. data/lib/msgpack/version.rb +1 -1
  27. data/lib/msgpack.rb +1 -0
  28. data/msgpack.gemspec +5 -2
  29. metadata +18 -46
  30. data/.github/workflows/ci.yaml +0 -57
  31. data/.gitignore +0 -23
  32. data/.rubocop.yml +0 -36
  33. data/Gemfile +0 -9
  34. data/Rakefile +0 -70
  35. data/appveyor.yml +0 -18
  36. data/bench/bench.rb +0 -78
  37. data/doclib/msgpack/buffer.rb +0 -193
  38. data/doclib/msgpack/core_ext.rb +0 -101
  39. data/doclib/msgpack/error.rb +0 -19
  40. data/doclib/msgpack/extension_value.rb +0 -9
  41. data/doclib/msgpack/factory.rb +0 -145
  42. data/doclib/msgpack/packer.rb +0 -209
  43. data/doclib/msgpack/time.rb +0 -22
  44. data/doclib/msgpack/timestamp.rb +0 -44
  45. data/doclib/msgpack/unpacker.rb +0 -183
  46. data/doclib/msgpack.rb +0 -87
  47. data/msgpack.org.md +0 -46
  48. data/spec/bigint_spec.rb +0 -26
  49. data/spec/cases.json +0 -1
  50. data/spec/cases.msg +0 -0
  51. data/spec/cases_compact.msg +0 -0
  52. data/spec/cases_spec.rb +0 -39
  53. data/spec/cruby/buffer_io_spec.rb +0 -255
  54. data/spec/cruby/buffer_packer.rb +0 -29
  55. data/spec/cruby/buffer_spec.rb +0 -575
  56. data/spec/cruby/buffer_unpacker.rb +0 -19
  57. data/spec/cruby/unpacker_spec.rb +0 -70
  58. data/spec/ext_value_spec.rb +0 -99
  59. data/spec/exttypes.rb +0 -51
  60. data/spec/factory_spec.rb +0 -688
  61. data/spec/format_spec.rb +0 -301
  62. data/spec/jruby/benchmarks/shootout_bm.rb +0 -73
  63. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +0 -25
  64. data/spec/jruby/unpacker_spec.rb +0 -186
  65. data/spec/msgpack_spec.rb +0 -214
  66. data/spec/pack_spec.rb +0 -61
  67. data/spec/packer_spec.rb +0 -575
  68. data/spec/random_compat.rb +0 -24
  69. data/spec/spec_helper.rb +0 -71
  70. data/spec/timestamp_spec.rb +0 -159
  71. data/spec/unpack_spec.rb +0 -57
  72. data/spec/unpacker_spec.rb +0 -859
@@ -1,209 +0,0 @@
1
- module MessagePack
2
-
3
- #
4
- # MessagePack::Packer is a class to serialize objects.
5
- #
6
- class Packer
7
- #
8
- # Creates a MessagePack::Packer instance.
9
- # See Buffer#initialize for supported options.
10
- #
11
- # @overload initialize(options={})
12
- # @param options [Hash]
13
- #
14
- # @overload initialize(io, options={})
15
- # @param io [IO]
16
- # @param options [Hash]
17
- # This packer writes serialized objects into the IO when the internal buffer is filled.
18
- # _io_ must respond to write(string) or append(string) method.
19
- #
20
- # Supported options:
21
- #
22
- # * *:compatibility_mode* serialize in older versions way, without str8 and bin types
23
- #
24
- # See also Buffer#initialize for other options.
25
- #
26
- def initialize(*args)
27
- end
28
-
29
- #
30
- # Register a new ext type to serialize it. This method should be called with one of
31
- # method name or block, which returns bytes(ASCII-8BIT String) representation of
32
- # object to be serialized.
33
- #
34
- # @overload register_type(type, klass, &block)
35
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
36
- # @param klass [Class] Class to be serialized with specified type id
37
- # @yieldparam object [Object] object to be serialized
38
- #
39
- # @overload register_type(type, klass, method_name)
40
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
41
- # @param klass [Class] Class to be serialized with specified type id
42
- # @param method_name [Symbol] method which returns bytes of serialized representation
43
- #
44
- # @return nil
45
- #
46
- def register_type(type, klass, method_name, &block)
47
- end
48
-
49
- #
50
- # Returns a list of registered types, ordered by type id.
51
- # Each element is a Hash object includes keys :type, :class and :packer.
52
- #
53
- # @return Array
54
- #
55
- def registered_types
56
- end
57
-
58
- #
59
- # Returns true/false which indicate specified class or type id is registered or not.
60
- #
61
- # @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
62
- # @return true or false
63
- #
64
- def type_registered?(klass_or_type)
65
- end
66
-
67
- #
68
- # Internal buffer
69
- #
70
- # @return MessagePack::Buffer
71
- #
72
- attr_reader :buffer
73
-
74
- #
75
- # Serializes an object into internal buffer, and flushes to io if necessary.
76
- #
77
- # If it could not serialize the object, it raises
78
- # NoMethodError: undefined method `to_msgpack' for #<the_object>.
79
- #
80
- # @param obj [Object] object to serialize
81
- # @return [Packer] self
82
- #
83
- def write(obj)
84
- end
85
-
86
- alias pack write
87
-
88
- #
89
- # Serializes a nil object. Same as write(nil).
90
- #
91
- def write_nil
92
- end
93
-
94
- #
95
- # Serializes a string object as binary data. Same as write("string".encode(Encoding::BINARY)).
96
- #
97
- def write_bin(obj)
98
- end
99
-
100
- #
101
- # Write a header of an array whose size is _n_.
102
- # For example, write_array_header(1).write(true) is same as write([ true ]).
103
- #
104
- # @return [Packer] self
105
- #
106
- def write_array_header(n)
107
- end
108
-
109
- #
110
- # Write a header of an map whose size is _n_.
111
- # For example, write_map_header(1).write('key').write(true) is same as write('key'=>true).
112
- #
113
- # @return [Packer] self
114
- #
115
- def write_map_header(n)
116
- end
117
-
118
- #
119
- # Write a header of a binary string whose size is _n_. Useful if you want to append large binary data without loading it into memory at once.
120
- # For example,
121
- # MessagePack::Packer.new(io).write_bin_header(12).flush
122
- # io.write('chunk1')
123
- # io.write('chunk2')
124
- # is the same as
125
- # write('chunk1chunk2'.encode(Encoding::BINARY)).
126
- #
127
- # @return [Packer] self
128
- #
129
- def write_bin_header(n)
130
- end
131
-
132
- #
133
- # Serializes _value_ as 32-bit single precision float into internal buffer.
134
- # _value_ will be approximated with the nearest possible single precision float, thus
135
- # being potentially lossy. However, the serialized string will only take up 5 bytes
136
- # instead of 9 bytes compared to directly serializing a 64-bit double precision Ruby Float.
137
- #
138
- # @param value [Numeric]
139
- # @return [Packer] self
140
- #
141
- def write_float32(value)
142
- end
143
-
144
- #
145
- # Flushes data in the internal buffer to the internal IO. Same as _buffer.flush.
146
- # If internal IO is not set, it does nothing.
147
- #
148
- # @return [Packer] self
149
- #
150
- def flush
151
- end
152
-
153
- #
154
- # Makes the internal buffer empty. Same as _buffer.clear_.
155
- #
156
- # @return nil
157
- #
158
- def reset
159
- end
160
- alias clear reset
161
-
162
- #
163
- # Returns size of the internal buffer. Same as buffer.size.
164
- #
165
- # @return [Integer]
166
- #
167
- def size
168
- end
169
-
170
- #
171
- # Returns _true_ if the internal buffer is empty. Same as buffer.empty?.
172
- # This method is slightly faster than _size_.
173
- #
174
- # @return [Boolean]
175
- #
176
- def empty?
177
- end
178
-
179
- #
180
- # Returns all data in the buffer as a string. Same as buffer.to_str.
181
- #
182
- # @return [String]
183
- #
184
- def to_str
185
- end
186
-
187
- alias to_s to_str
188
-
189
- #
190
- # Returns content of the internal buffer as an array of strings. Same as buffer.to_a.
191
- # This method is faster than _to_str_.
192
- #
193
- # @return [Array] array of strings
194
- #
195
- def to_a
196
- end
197
-
198
- #
199
- # Writes all of data in the internal buffer into the given IO. Same as buffer.write_to(io).
200
- # This method consumes and removes data from the internal buffer.
201
- # _io_ must respond to write(data) method.
202
- #
203
- # @param io [IO]
204
- # @return [Integer] byte size of written data
205
- #
206
- def write_to(io)
207
- end
208
- end
209
- end
@@ -1,22 +0,0 @@
1
- module MessagePack
2
-
3
- # MessagePack::Time provides packer and unpacker functions for a timestamp type.
4
- # @example Setup for DefaultFactory
5
- # MessagePack::DefaultFactory.register_type(
6
- # MessagePack::Timestamp::TYPE,
7
- # Time,
8
- # packer: MessagePack::Time::Packer,
9
- # unpacker: MessagePack::Time::Unpacker
10
- # )
11
- class Time
12
- # A packer function that packs a Time instance to a MessagePack timestamp.
13
- Packer = lambda { |payload|
14
- # ...
15
- }
16
-
17
- # An unpacker function that unpacks a MessagePack timestamp to a Time instance.
18
- Unpacker = lambda { |time|
19
- # ...
20
- }
21
- end
22
- end
@@ -1,44 +0,0 @@
1
- module MessagePack
2
- # A utility class for MessagePack timestamp type
3
- class Timestamp
4
- #
5
- # The timestamp extension type defined in the MessagePack spec.
6
- #
7
- # See https://github.com/msgpack/msgpack/blob/master/spec.md#timestamp-extension-type for details.
8
- #
9
- TYPE = -1
10
-
11
- # @return [Integer] Second part of the timestamp.
12
- attr_reader :sec
13
-
14
- # @return [Integer] Nanosecond part of the timestamp.
15
- attr_reader :nsec
16
-
17
- # @param [Integer] sec
18
- # @param [Integer] nsec
19
- def initialize(sec, nsec)
20
- end
21
-
22
- # @example An unpacker implementation for the Time class
23
- # lambda do |payload|
24
- # tv = MessagePack::Timestamp.from_msgpack_ext(payload)
25
- # Time.at(tv.sec, tv.nsec, :nanosecond)
26
- # end
27
- #
28
- # @param [String] data
29
- # @return [MessagePack::Timestamp]
30
- def self.from_msgpack_ext(data)
31
- end
32
-
33
- # @example A packer implementation for the Time class
34
- # unpacker = lambda do |time|
35
- # MessagePack::Timestamp.to_msgpack_ext(time.tv_sec, time.tv_nsec)
36
- # end
37
- #
38
- # @param [Integer] sec
39
- # @param [Integer] nsec
40
- # @return [String]
41
- def self.to_msgpack_ext(sec, nsec)
42
- end
43
- end
44
- end
@@ -1,183 +0,0 @@
1
- module MessagePack
2
-
3
- #
4
- # MessagePack::Unpacker is a class to deserialize objects.
5
- #
6
- class Unpacker
7
- #
8
- # Creates a MessagePack::Unpacker instance.
9
- #
10
- # @overload initialize(options={})
11
- # @param options [Hash]
12
- #
13
- # @overload initialize(io, options={})
14
- # @param io [IO]
15
- # @param options [Hash]
16
- # This unpacker reads data from the _io_ to fill the internal buffer.
17
- # _io_ must respond to readpartial(length [,string]) or read(length [,string]) method.
18
- #
19
- # Supported options:
20
- #
21
- # * *:symbolize_keys* deserialize keys of Hash objects as Symbol instead of String
22
- # * *:allow_unknown_ext* allow to deserialize ext type object with unknown type id as ExtensionValue instance. Otherwise (by default), unpacker throws UnknownExtTypeError.
23
- #
24
- # See also Buffer#initialize for other options.
25
- #
26
- def initialize(*args)
27
- end
28
-
29
- #
30
- # Register a new ext type to deserialize it. This method should be called with
31
- # Class and its class method name, or block, which returns a instance object.
32
- #
33
- # @overload register_type(type, &block)
34
- # @param type [Fixnum] type id (0-127) user defined type id for specified deserializer block
35
- # @yieldparam data [String] bytes(ASCII-8BIT String) represents serialized object, to be deserialized
36
- #
37
- # @overload register_type(type, klass, class_method_name)
38
- # @param type [Fixnum] type id (0-127) user defined type id for specified Class
39
- # @param klass [Class] Class to be serialized with specified type id
40
- # @param class_method_name [Symbol] class method which returns an instance object
41
- #
42
- # @return nil
43
- #
44
- def register_type(type, klass, method_name, &block)
45
- end
46
-
47
- #
48
- # Returns a list of registered types, ordered by type id.
49
- # Each element is a Hash object includes keys :type, :class and :unpacker.
50
- #
51
- # @return Array
52
- #
53
- def registered_types
54
- end
55
-
56
- #
57
- # Returns true/false which indicate specified class or type id is registered or not.
58
- #
59
- # @param klass_or_type [Class or Fixnum] Class or type id (0-127) to be checked
60
- # @return true or false
61
- #
62
- def type_registered?(klass_or_type)
63
- end
64
-
65
- #
66
- # Internal buffer
67
- #
68
- # @return [MessagePack::Buffer]
69
- #
70
- attr_reader :buffer
71
-
72
- #
73
- # Deserializes an object from the io or internal buffer and returns it.
74
- #
75
- # This method reads data from io into the internal buffer and deserializes an object
76
- # from the buffer. It repeats reading data from the io until enough data is available
77
- # to deserialize at least one object. After deserializing one object, unused data is
78
- # left in the internal buffer.
79
- #
80
- # If there're not enough data to deserialize one object, this method raises EOFError.
81
- # If data format is invalid, this method raises MessagePack::MalformedFormatError.
82
- # If the object nests too deeply, this method raises MessagePack::StackError.
83
- #
84
- # @return [Object] deserialized object
85
- #
86
- def read
87
- end
88
-
89
- alias unpack read
90
-
91
- #
92
- # Deserializes an object and ignores it. This method is faster than _read_.
93
- #
94
- # This method could raise the same errors with _read_.
95
- #
96
- # @return nil
97
- #
98
- def skip
99
- end
100
-
101
- #
102
- # Deserializes a nil value if it exists and returns _true_.
103
- # Otherwise, if a byte exists but the byte doesn't represent nil value,
104
- # returns _false_.
105
- #
106
- # If there're not enough data, this method raises EOFError.
107
- #
108
- # @return [Boolean]
109
- #
110
- def skip_nil
111
- end
112
-
113
- #
114
- # Read a header of an array and returns its size.
115
- # It converts a serialized array into a stream of elements.
116
- #
117
- # If the serialized object is not an array, it raises MessagePack::UnexpectedTypeError.
118
- # If there're not enough data, this method raises EOFError.
119
- #
120
- # @return [Integer] size of the array
121
- #
122
- def read_array_header
123
- end
124
-
125
- #
126
- # Reads a header of an map and returns its size.
127
- # It converts a serialized map into a stream of key-value pairs.
128
- #
129
- # If the serialized object is not a map, it raises MessagePack::UnexpectedTypeError.
130
- # If there're not enough data, this method raises EOFError.
131
- #
132
- # @return [Integer] size of the map
133
- #
134
- def read_map_header
135
- end
136
-
137
- #
138
- # Appends data into the internal buffer.
139
- # This method is equivalent to unpacker.buffer.append(data).
140
- #
141
- # @param data [String]
142
- # @return [Unpacker] self
143
- #
144
- def feed(data)
145
- end
146
-
147
- #
148
- # Repeats to deserialize objects.
149
- #
150
- # It repeats until the io or internal buffer does not include any complete objects.
151
- #
152
- # If an IO is set, it repeats to read data from the IO when the buffer
153
- # becomes empty until the IO raises EOFError.
154
- #
155
- # This method could raise same errors with _read_ excepting EOFError.
156
- #
157
- # @yieldparam object [Object] deserialized object
158
- # @return nil
159
- #
160
- def each(&block)
161
- end
162
-
163
- #
164
- # Appends data into the internal buffer and repeats to deserialize objects.
165
- # This method is equivalent to unpacker.feed(data) && unpacker.each { ... }.
166
- #
167
- # @param data [String]
168
- # @yieldparam object [Object] deserialized object
169
- # @return nil
170
- #
171
- def feed_each(data, &block)
172
- end
173
-
174
- #
175
- # Clears the internal buffer and resets deserialization state of the unpacker.
176
- #
177
- # @return nil
178
- #
179
- def reset
180
- end
181
- end
182
-
183
- end
data/doclib/msgpack.rb DELETED
@@ -1,87 +0,0 @@
1
-
2
- module MessagePack
3
- #
4
- # Serializes an object into an IO or String.
5
- #
6
- # @overload dump(obj, options={})
7
- # @param obj [Object] object to be serialized
8
- # @param options [Hash]
9
- # @return [String] serialized data
10
- #
11
- # @overload dump(obj, io, options={})
12
- # @param obj [Object] object to be serialized
13
- # @param io [IO]
14
- # @param options [Hash]
15
- # @return [nil]
16
- #
17
- # See Packer#initialize for supported options.
18
- #
19
- def self.dump(obj)
20
- end
21
-
22
- #
23
- # Serializes an object into an IO or String. Alias of dump.
24
- #
25
- # @overload pack(obj, options={})
26
- # @param obj [Object] object to be serialized
27
- # @param options [Hash]
28
- # @return [String] serialized data
29
- #
30
- # @overload pack(obj, io, options={})
31
- # @param obj [Object] object to be serialized
32
- # @param io [IO]
33
- # @param options [Hash]
34
- # @return [nil]
35
- #
36
- # See Packer#initialize for supported options.
37
- #
38
- def self.pack(obj)
39
- end
40
-
41
- #
42
- # Deserializes an object from an IO or String.
43
- #
44
- # @overload load(string, options={})
45
- # @param string [String] data to deserialize
46
- # @param options [Hash]
47
- #
48
- # @overload load(io, options={})
49
- # @param io [IO]
50
- # @param options [Hash]
51
- #
52
- # @return [Object] deserialized object
53
- #
54
- # See Unpacker#initialize for supported options.
55
- #
56
- def self.load(src, options={})
57
- end
58
-
59
- #
60
- # Deserializes an object from an IO or String. Alias of load.
61
- #
62
- # @overload unpack(string, options={})
63
- # @param string [String] data to deserialize
64
- # @param options [Hash]
65
- #
66
- # @overload unpack(io, options={})
67
- # @param io [IO]
68
- # @param options [Hash]
69
- #
70
- # @return [Object] deserialized object
71
- #
72
- # See Unpacker#initialize for supported options.
73
- #
74
- def self.unpack(src, options={})
75
- end
76
-
77
- #
78
- # An instance of Factory class. DefaultFactory is also used
79
- # by global pack/unpack methods such as MessagePack.dump/load,
80
- # Hash#to_msgpack, and other to_msgpack methods.
81
- #
82
- # Calling DefaultFactory.register_type lets you add an extension
83
- # type globally.
84
- #
85
- DefaultFactory = Factory.new
86
- end
87
-
data/msgpack.org.md DELETED
@@ -1,46 +0,0 @@
1
- # MessagePack for Ruby
2
-
3
- ```
4
- require 'msgpack'
5
- msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03"
6
- MessagePack.unpack(msg) #=> [1,2,3]
7
- ```
8
-
9
- ## Install
10
-
11
- ```
12
- gem install msgpack
13
- ```
14
-
15
- ## Use cases
16
-
17
- * Create REST API returing MessagePack using Rails + [RABL](https://github.com/nesquena/rabl)
18
- * Store objects efficiently in memcached or Redis
19
- * Upload data in efficient format from mobile devices. See also MessagePack for [Objective-C](https://github.com/msgpack/msgpack-objectivec) and [Java](https://github.com/msgpack/msgpack-java)
20
-
21
- ## Links
22
-
23
- * [Github](https://github.com/msgpack/msgpack-ruby)
24
- * [API document](http://ruby.msgpack.org/)
25
-
26
- ## Streaming API
27
-
28
- ```
29
- # serialize a 2-element array [e1, e2]
30
- pk = MessagePack::Packer.new(io)
31
- pk.write_array_header(2).write(e1).write(e2).flush
32
- ```
33
-
34
- ```
35
- # deserialize objects from an IO
36
- u = MessagePack::Unpacker.new(io)
37
- u.each { |obj| ... }
38
- ```
39
-
40
- ```
41
- # event-driven deserialization
42
- def on_read(data)
43
- @u ||= MessagePack::Unpacker.new
44
- @u.feed_each(data) { |obj| ... }
45
- end
46
- ```
data/spec/bigint_spec.rb DELETED
@@ -1,26 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe MessagePack::Bigint do
4
- it 'serialize and deserialize arbitrary sized integer' do
5
- [
6
- 1,
7
- -1,
8
- 120938120391283122132313,
9
- -21903120391203912391023920332103,
10
- 210290021321301203912933021323,
11
- ].each do |int|
12
- expect(MessagePack::Bigint.from_msgpack_ext(MessagePack::Bigint.to_msgpack_ext(int))).to be == int
13
- end
14
- end
15
-
16
- it 'has a stable format' do
17
- {
18
- 120938120391283122132313 => "\x00\x9F\xF4UY\x11\x92\x9A?\x00\x00\x19\x9C".b,
19
- -21903120391203912391023920332103 => "\x01/\xB2\xBDG\xBD\xDE\xAA\xEBt\xCC\x8A\xC1\x00\x00\x01\x14".b,
20
- 210290021321301203912933021323 => "\x00\xC4\xD8\x96\x8Bm\xCB\xC7\x03\xA7{\xD4\"\x00\x00\x00\x02".b,
21
- }.each do |int, payload|
22
- expect(MessagePack::Bigint.to_msgpack_ext(int)).to be == payload
23
- expect(MessagePack::Bigint.from_msgpack_ext(payload)).to be == int
24
- end
25
- end
26
- end
data/spec/cases.json DELETED
@@ -1 +0,0 @@
1
- [false,true,null,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,127,127,255,65535,4294967295,-32,-32,-128,-32768,-2147483648,0.0,-0.0,1.0,-1.0,"a","a","a","","","",[0],[0],[0],[],[],[],{},{},{},{"a":97},{"a":97},{"a":97},[[]],[["a"]]]
data/spec/cases.msg DELETED
Binary file
Binary file
data/spec/cases_spec.rb DELETED
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- require 'json'
3
-
4
- describe MessagePack do
5
- here = File.dirname(__FILE__)
6
- CASES = File.read("#{here}/cases.msg")
7
- CASES_JSON = File.read("#{here}/cases.json")
8
- CASES_COMPACT = File.read("#{here}/cases_compact.msg")
9
-
10
- it 'compare with json' do
11
- ms = []
12
- MessagePack::Unpacker.new.feed_each(CASES) {|m|
13
- ms << m
14
- }
15
-
16
- js = JSON.load(CASES_JSON)
17
-
18
- ms.zip(js) {|m,j|
19
- m.should == j
20
- }
21
- end
22
-
23
- it 'compare with compat' do
24
- ms = []
25
- MessagePack::Unpacker.new.feed_each(CASES) {|m|
26
- ms << m
27
- }
28
-
29
- cs = []
30
- MessagePack::Unpacker.new.feed_each(CASES_COMPACT) {|c|
31
- cs << c
32
- }
33
-
34
- ms.zip(cs) {|m,c|
35
- m.should == c
36
- }
37
- end
38
- end
39
-