msgpack 0.5.8 → 0.5.9
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 +15 -0
- data/.gitignore +1 -0
- data/.travis.yml +26 -0
- data/ChangeLog +6 -0
- data/README.rdoc +1 -0
- data/Rakefile +19 -10
- data/doclib/msgpack/packer.rb +2 -3
- data/doclib/msgpack/unpacker.rb +17 -13
- data/ext/msgpack/extconf.rb +3 -0
- data/ext/msgpack/packer.h +6 -1
- data/ext/msgpack/unpacker.c +12 -0
- data/ext/msgpack/unpacker_class.c +2 -2
- data/lib/msgpack/version.rb +1 -1
- data/msgpack.org.md +46 -0
- data/spec/{buffer_io_spec.rb → cruby/buffer_io_spec.rb} +0 -0
- data/spec/cruby/buffer_packer.rb +29 -0
- data/spec/{buffer_spec.rb → cruby/buffer_spec.rb} +0 -0
- data/spec/cruby/buffer_unpacker.rb +19 -0
- data/spec/packer_spec.rb +0 -7
- data/spec/unpacker_spec.rb +30 -12
- metadata +15 -23
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YjA2YWVlMmNiZTg2NGJkNWQ1ZDk5ZGFlM2NlNTVjOTgwNGU4YTgyZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YWYzZGZlNDM5MTEwZmEyMzcyZmU1MmE5ODkzOGM0MTAwOTNhNTM5NQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZmVkYWI4MWRiYWZlYjJjNmQzYzkwNTJiZWMyZTJlN2UzNzJiMGJiZDk3NjRl
|
10
|
+
NzE1ZWNkMzY3YzQ0NjQxNmQ1NTk1MjBlOTdjMjlkZjA5NTQ1YmYxNjg2MzAw
|
11
|
+
OGUzN2Q0MzdlMmQxYmYwNmEyZTI5Mjg3Y2Q1ZDkyMzUyYzUwYTY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MGJkMzdlODI3ZTQwZWRlNzU2ZmY4YmRkNmUwZDIzYzk5MzY5MTE2NzNjYzQy
|
14
|
+
ZDNkZWY0NjYyNDQ1ZmU4NDY4NTFhN2EyMzFiZjU2ODJiM2IyNDE5NzY4OTI5
|
15
|
+
MmE4MWY3ZTEyNjM5ODQ1Y2ZkMjJmM2IyZDU2OGM5NTY5YmUwMzM=
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
language: ruby
|
2
|
+
|
3
|
+
rvm:
|
4
|
+
- 1.8.7
|
5
|
+
- 1.9.3
|
6
|
+
- 2.0.0
|
7
|
+
- 2.1
|
8
|
+
- ruby-head
|
9
|
+
- rbx-2
|
10
|
+
#- jruby-18mode
|
11
|
+
#- jruby-19mode
|
12
|
+
|
13
|
+
os:
|
14
|
+
- linux
|
15
|
+
- osx
|
16
|
+
|
17
|
+
branches:
|
18
|
+
only:
|
19
|
+
- master
|
20
|
+
|
21
|
+
gemfile:
|
22
|
+
- Gemfile
|
23
|
+
|
24
|
+
matrix:
|
25
|
+
allow_failures:
|
26
|
+
- rvm: ruby-head
|
data/ChangeLog
CHANGED
data/README.rdoc
CHANGED
@@ -26,6 +26,7 @@ or build msgpack-ruby and install:
|
|
26
26
|
|
27
27
|
= Use cases
|
28
28
|
|
29
|
+
* Create REST API returing MessagePack using Rails + [RABL](https://github.com/nesquena/rabl)
|
29
30
|
* Store objects efficiently serialized by msgpack on memcached or Redis
|
30
31
|
* In fact Redis supports msgpack in EVAL-scripts[http://redis.io/commands/eval]
|
31
32
|
* Upload data in efficient format from mobile devices such as smartphones
|
data/Rakefile
CHANGED
@@ -8,13 +8,6 @@ require 'rspec/core'
|
|
8
8
|
require 'rspec/core/rake_task'
|
9
9
|
require 'yard'
|
10
10
|
|
11
|
-
RSpec::Core::RakeTask.new(:spec) do |t|
|
12
|
-
t.rspec_opts = ["-c", "-f progress"]
|
13
|
-
t.rspec_opts << "-Ilib"
|
14
|
-
t.pattern = 'spec/**/*_spec.rb'
|
15
|
-
t.verbose = true
|
16
|
-
end
|
17
|
-
|
18
11
|
task :spec => :compile
|
19
12
|
|
20
13
|
desc 'Run RSpec code examples and measure coverage'
|
@@ -37,21 +30,37 @@ if RUBY_PLATFORM =~ /java/
|
|
37
30
|
|
38
31
|
Rake::JavaExtensionTask.new('msgpack', spec) do |ext|
|
39
32
|
ext.ext_dir = 'ext/java'
|
40
|
-
|
41
|
-
|
42
|
-
|
33
|
+
ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
|
34
|
+
ext.classpath = Dir['lib/msgpack/java/*.jar'].map { |x| File.expand_path x }.join ':'
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
38
|
+
t.rspec_opts = ["-c", "-f progress"]
|
39
|
+
t.rspec_opts << "-Ilib"
|
40
|
+
t.pattern = 'spec/{,jruby/}*_spec.rb'
|
41
|
+
t.verbose = true
|
43
42
|
end
|
44
43
|
|
45
44
|
else
|
46
45
|
require 'rake/extensiontask'
|
47
46
|
|
48
47
|
Rake::ExtensionTask.new('msgpack', spec) do |ext|
|
48
|
+
ext.ext_dir = 'ext/msgpack'
|
49
49
|
ext.cross_compile = true
|
50
50
|
ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
|
51
51
|
#ext.cross_platform = 'i386-mswin32'
|
52
52
|
end
|
53
|
+
|
54
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
55
|
+
t.rspec_opts = ["-c", "-f progress"]
|
56
|
+
t.rspec_opts << "-Ilib"
|
57
|
+
t.pattern = 'spec/{,cruby/}*_spec.rb'
|
58
|
+
t.verbose = true
|
59
|
+
end
|
53
60
|
end
|
54
61
|
|
62
|
+
CLEAN.include('lib/msgpack/msgpack.*')
|
63
|
+
|
55
64
|
task :default => [:spec, :build, :doc]
|
56
65
|
|
57
66
|
|
data/doclib/msgpack/packer.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module MessagePack
|
2
2
|
|
3
3
|
#
|
4
|
-
# MessagePack::Packer is
|
5
|
-
# which is a MessagePack::Buffer.
|
4
|
+
# MessagePack::Packer is a class to serialize objects.
|
6
5
|
#
|
7
6
|
class Packer
|
8
7
|
#
|
@@ -31,7 +30,7 @@ module MessagePack
|
|
31
30
|
attr_reader :buffer
|
32
31
|
|
33
32
|
#
|
34
|
-
# Serializes an object into internal buffer.
|
33
|
+
# Serializes an object into internal buffer, and flushes to io if necessary.
|
35
34
|
#
|
36
35
|
# If it could not serialize the object, it raises
|
37
36
|
# NoMethodError: undefined method `to_msgpack' for #<the_object>.
|
data/doclib/msgpack/unpacker.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
module MessagePack
|
2
2
|
|
3
3
|
#
|
4
|
-
# MessagePack::Unpacker is
|
5
|
-
# which is a MessagePack::Buffer.
|
4
|
+
# MessagePack::Unpacker is a class to deserialize objects.
|
6
5
|
#
|
7
6
|
class Unpacker
|
8
7
|
#
|
@@ -34,11 +33,16 @@ module MessagePack
|
|
34
33
|
attr_reader :buffer
|
35
34
|
|
36
35
|
#
|
37
|
-
# Deserializes an object from internal buffer and returns it.
|
36
|
+
# Deserializes an object from the io or internal buffer and returns it.
|
38
37
|
#
|
39
|
-
#
|
38
|
+
# This method reads data from io into the internal buffer and deserializes an object
|
39
|
+
# from the buffer. It repeats reading data from the io until enough data is available
|
40
|
+
# to deserialize at least one object. After deserializing one object, unused data is
|
41
|
+
# left in the internal buffer.
|
42
|
+
#
|
43
|
+
# If there're not enough data to deserialize one object, this method raises EOFError.
|
40
44
|
# If data format is invalid, this method raises MessagePack::MalformedFormatError.
|
41
|
-
# If the
|
45
|
+
# If the object nests too deeply, this method raises MessagePack::StackError.
|
42
46
|
#
|
43
47
|
# @return [Object] deserialized object
|
44
48
|
#
|
@@ -50,7 +54,7 @@ module MessagePack
|
|
50
54
|
#
|
51
55
|
# Deserializes an object and ignores it. This method is faster than _read_.
|
52
56
|
#
|
53
|
-
# This method could raise same errors with _read_.
|
57
|
+
# This method could raise the same errors with _read_.
|
54
58
|
#
|
55
59
|
# @return nil
|
56
60
|
#
|
@@ -62,7 +66,7 @@ module MessagePack
|
|
62
66
|
# Otherwise, if a byte exists but the byte doesn't represent nil value,
|
63
67
|
# returns _false_.
|
64
68
|
#
|
65
|
-
# If there're not enough
|
69
|
+
# If there're not enough data, this method raises EOFError.
|
66
70
|
#
|
67
71
|
# @return [Boolean]
|
68
72
|
#
|
@@ -74,7 +78,7 @@ module MessagePack
|
|
74
78
|
# It converts a serialized array into a stream of elements.
|
75
79
|
#
|
76
80
|
# If the serialized object is not an array, it raises MessagePack::TypeError.
|
77
|
-
# If there're not enough
|
81
|
+
# If there're not enough data, this method raises EOFError.
|
78
82
|
#
|
79
83
|
# @return [Integer] size of the array
|
80
84
|
#
|
@@ -86,7 +90,7 @@ module MessagePack
|
|
86
90
|
# It converts a serialized map into a stream of key-value pairs.
|
87
91
|
#
|
88
92
|
# If the serialized object is not a map, it raises MessagePack::TypeError.
|
89
|
-
# If there're not enough
|
93
|
+
# If there're not enough data, this method raises EOFError.
|
90
94
|
#
|
91
95
|
# @return [Integer] size of the map
|
92
96
|
#
|
@@ -95,7 +99,7 @@ module MessagePack
|
|
95
99
|
|
96
100
|
#
|
97
101
|
# Appends data into the internal buffer.
|
98
|
-
# This method
|
102
|
+
# This method is equivalent to unpacker.buffer.append(data).
|
99
103
|
#
|
100
104
|
# @param data [String]
|
101
105
|
# @return [Unpacker] self
|
@@ -106,7 +110,7 @@ module MessagePack
|
|
106
110
|
#
|
107
111
|
# Repeats to deserialize objects.
|
108
112
|
#
|
109
|
-
# It repeats until the internal buffer does not include any complete objects.
|
113
|
+
# It repeats until the io or internal buffer does not include any complete objects.
|
110
114
|
#
|
111
115
|
# If the an IO is set, it repeats to read data from the IO when the buffer
|
112
116
|
# becomes empty until the IO raises EOFError.
|
@@ -121,7 +125,7 @@ module MessagePack
|
|
121
125
|
|
122
126
|
#
|
123
127
|
# Appends data into the internal buffer and repeats to deserialize objects.
|
124
|
-
# This method is
|
128
|
+
# This method is equivalent to unpacker.feed(data) && unpacker.each { ... }.
|
125
129
|
#
|
126
130
|
# @param data [String]
|
127
131
|
# @yieldparam object [Object] deserialized object
|
@@ -131,7 +135,7 @@ module MessagePack
|
|
131
135
|
end
|
132
136
|
|
133
137
|
#
|
134
|
-
#
|
138
|
+
# Clears the internal buffer and resets deserialization state of the unpacker.
|
135
139
|
#
|
136
140
|
# @return nil
|
137
141
|
#
|
data/ext/msgpack/extconf.rb
CHANGED
@@ -3,6 +3,9 @@ require 'mkmf'
|
|
3
3
|
have_header("ruby/st.h")
|
4
4
|
have_header("st.h")
|
5
5
|
have_func("rb_str_replace", ["ruby.h"])
|
6
|
+
have_func("rb_intern_str", ["ruby.h"])
|
7
|
+
have_func("rb_sym2str", ["ruby.h"])
|
8
|
+
have_func("rb_str_intern", ["ruby.h"])
|
6
9
|
|
7
10
|
$CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
|
8
11
|
#$CFLAGS << %[ -DDISABLE_RMEM]
|
data/ext/msgpack/packer.h
CHANGED
@@ -334,15 +334,20 @@ static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE
|
|
334
334
|
|
335
335
|
static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE v)
|
336
336
|
{
|
337
|
+
#ifdef HAVE_RB_SYM2STR
|
338
|
+
/* rb_sym2str is added since MRI 2.2.0 */
|
339
|
+
msgpack_packer_write_string_value(pk, rb_sym2str(v));
|
340
|
+
#else
|
337
341
|
const char* name = rb_id2name(SYM2ID(v));
|
338
|
-
/* actual return type of strlen is size_t */
|
339
342
|
unsigned long len = strlen(name);
|
343
|
+
/* actual return type of strlen is size_t */
|
340
344
|
if(len > 0xffffffffUL) {
|
341
345
|
// TODO rb_eArgError?
|
342
346
|
rb_raise(rb_eArgError, "size of symbol is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
|
343
347
|
}
|
344
348
|
msgpack_packer_write_raw_header(pk, (unsigned int)len);
|
345
349
|
msgpack_buffer_append(PACKER_BUFFER_(pk), name, len);
|
350
|
+
#endif
|
346
351
|
}
|
347
352
|
|
348
353
|
static inline void msgpack_packer_write_fixnum_value(msgpack_packer_t* pk, VALUE v)
|
data/ext/msgpack/unpacker.c
CHANGED
@@ -549,6 +549,7 @@ int msgpack_unpacker_read_array_header(msgpack_unpacker_t* uk, uint32_t* result_
|
|
549
549
|
return PRIMITIVE_UNEXPECTED_TYPE;
|
550
550
|
}
|
551
551
|
|
552
|
+
reset_head_byte(uk);
|
552
553
|
return 0;
|
553
554
|
}
|
554
555
|
|
@@ -576,6 +577,7 @@ int msgpack_unpacker_read_map_header(msgpack_unpacker_t* uk, uint32_t* result_si
|
|
576
577
|
return PRIMITIVE_UNEXPECTED_TYPE;
|
577
578
|
}
|
578
579
|
|
580
|
+
reset_head_byte(uk);
|
579
581
|
return 0;
|
580
582
|
}
|
581
583
|
|
@@ -609,7 +611,17 @@ int msgpack_unpacker_read(msgpack_unpacker_t* uk, size_t target_stack_depth)
|
|
609
611
|
case STACK_TYPE_MAP_VALUE:
|
610
612
|
if(uk->symbolize_keys && rb_type(top->key) == T_STRING) {
|
611
613
|
/* here uses rb_intern_str instead of rb_intern so that Ruby VM can GC unused symbols */
|
614
|
+
#ifdef HAVE_RB_STR_INTERN
|
615
|
+
/* rb_str_intern is added since MRI 2.2.0 */
|
616
|
+
rb_hash_aset(top->object, rb_str_intern(top->key), uk->last_object);
|
617
|
+
#else
|
618
|
+
#ifndef HAVE_RB_INTERN_STR
|
619
|
+
/* MRI 1.8 doesn't have rb_intern_str or rb_intern2 */
|
620
|
+
rb_hash_aset(top->object, ID2SYM(rb_intern(RSTRING_PTR(top->key))), uk->last_object);
|
621
|
+
#else
|
612
622
|
rb_hash_aset(top->object, ID2SYM(rb_intern_str(top->key)), uk->last_object);
|
623
|
+
#endif
|
624
|
+
#endif
|
613
625
|
} else {
|
614
626
|
rb_hash_aset(top->object, top->key, uk->last_object);
|
615
627
|
}
|
@@ -85,7 +85,7 @@ static VALUE Unpacker_initialize(int argc, VALUE* argv, VALUE self)
|
|
85
85
|
}
|
86
86
|
|
87
87
|
} else {
|
88
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..
|
88
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0..2)", argc);
|
89
89
|
}
|
90
90
|
|
91
91
|
UNPACKER(self, uk);
|
@@ -313,7 +313,7 @@ VALUE MessagePack_unpack(int argc, VALUE* argv)
|
|
313
313
|
src = argv[0];
|
314
314
|
break;
|
315
315
|
default:
|
316
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1)", argc);
|
316
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%d for 1..2)", argc);
|
317
317
|
}
|
318
318
|
|
319
319
|
VALUE self = Unpacker_alloc(cMessagePack_Unpacker);
|
data/lib/msgpack/version.rb
CHANGED
data/msgpack.org.md
ADDED
@@ -0,0 +1,46 @@
|
|
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
|
+
```
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
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 Packer do
|
10
|
+
let :packer do
|
11
|
+
Packer.new
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'initialize' do
|
15
|
+
Packer.new
|
16
|
+
Packer.new(nil)
|
17
|
+
Packer.new(StringIO.new)
|
18
|
+
Packer.new({})
|
19
|
+
Packer.new(StringIO.new, {})
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'buffer' do
|
23
|
+
o1 = packer.buffer.object_id
|
24
|
+
packer.buffer << 'frsyuki'
|
25
|
+
packer.buffer.to_s.should == 'frsyuki'
|
26
|
+
packer.buffer.object_id.should == o1
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
File without changes
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# encoding: ascii-8bit
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Unpacker do
|
5
|
+
let :unpacker do
|
6
|
+
Unpacker.new
|
7
|
+
end
|
8
|
+
|
9
|
+
let :packer do
|
10
|
+
Packer.new
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'buffer' do
|
14
|
+
o1 = unpacker.buffer.object_id
|
15
|
+
unpacker.buffer << 'frsyuki'
|
16
|
+
unpacker.buffer.to_s.should == 'frsyuki'
|
17
|
+
unpacker.buffer.object_id.should == o1
|
18
|
+
end
|
19
|
+
end
|
data/spec/packer_spec.rb
CHANGED
@@ -65,13 +65,6 @@ describe Packer do
|
|
65
65
|
io.string.should == "\xc0"
|
66
66
|
end
|
67
67
|
|
68
|
-
it 'buffer' do
|
69
|
-
o1 = packer.buffer.object_id
|
70
|
-
packer.buffer << 'frsyuki'
|
71
|
-
packer.buffer.to_s.should == 'frsyuki'
|
72
|
-
packer.buffer.object_id.should == o1
|
73
|
-
end
|
74
|
-
|
75
68
|
it 'to_msgpack returns String' do
|
76
69
|
nil.to_msgpack.class.should == String
|
77
70
|
true.to_msgpack.class.should == String
|
data/spec/unpacker_spec.rb
CHANGED
@@ -24,11 +24,33 @@ describe Unpacker do
|
|
24
24
|
}.should raise_error(MessagePack::TypeError)
|
25
25
|
end
|
26
26
|
|
27
|
+
it 'read_map_header converts an map to key-value sequence' do
|
28
|
+
packer.write_array_header(2)
|
29
|
+
packer.write("e")
|
30
|
+
packer.write(1)
|
31
|
+
unpacker = Unpacker.new
|
32
|
+
unpacker.feed(packer.to_s)
|
33
|
+
unpacker.read_array_header.should == 2
|
34
|
+
unpacker.read.should == "e"
|
35
|
+
unpacker.read.should == 1
|
36
|
+
end
|
37
|
+
|
27
38
|
it 'read_map_header succeeds' do
|
28
39
|
unpacker.feed("\x81")
|
29
40
|
unpacker.read_map_header.should == 1
|
30
41
|
end
|
31
42
|
|
43
|
+
it 'read_map_header converts an map to key-value sequence' do
|
44
|
+
packer.write_map_header(1)
|
45
|
+
packer.write("k")
|
46
|
+
packer.write("v")
|
47
|
+
unpacker = Unpacker.new
|
48
|
+
unpacker.feed(packer.to_s)
|
49
|
+
unpacker.read_map_header.should == 1
|
50
|
+
unpacker.read.should == "k"
|
51
|
+
unpacker.read.should == "v"
|
52
|
+
end
|
53
|
+
|
32
54
|
it 'read_map_header fails' do
|
33
55
|
unpacker.feed("\x91")
|
34
56
|
lambda {
|
@@ -53,7 +75,8 @@ describe Unpacker do
|
|
53
75
|
packer.write(4)
|
54
76
|
packer.write(5)
|
55
77
|
|
56
|
-
unpacker = Unpacker.new
|
78
|
+
unpacker = Unpacker.new
|
79
|
+
unpacker.feed(packer.to_s)
|
57
80
|
|
58
81
|
unpacker.read.should == 1
|
59
82
|
unpacker.skip
|
@@ -131,13 +154,6 @@ describe Unpacker do
|
|
131
154
|
unpacker.each.map {|x| x }.should == [1]
|
132
155
|
end
|
133
156
|
|
134
|
-
it 'buffer' do
|
135
|
-
o1 = unpacker.buffer.object_id
|
136
|
-
unpacker.buffer << 'frsyuki'
|
137
|
-
unpacker.buffer.to_s.should == 'frsyuki'
|
138
|
-
unpacker.buffer.object_id.should == o1
|
139
|
-
end
|
140
|
-
|
141
157
|
it 'frozen short strings' do
|
142
158
|
raw = sample_object.to_msgpack.to_s.force_encoding('UTF-8')
|
143
159
|
lambda {
|
@@ -156,7 +172,8 @@ describe Unpacker do
|
|
156
172
|
512.times { packer.write_array_header(1) }
|
157
173
|
packer.write(nil)
|
158
174
|
|
159
|
-
unpacker = Unpacker.new
|
175
|
+
unpacker = Unpacker.new
|
176
|
+
unpacker.feed(packer.to_s)
|
160
177
|
lambda {
|
161
178
|
unpacker.read
|
162
179
|
}.should raise_error(MessagePack::StackError)
|
@@ -166,7 +183,8 @@ describe Unpacker do
|
|
166
183
|
512.times { packer.write_array_header(1) }
|
167
184
|
packer.write(nil)
|
168
185
|
|
169
|
-
unpacker = Unpacker.new
|
186
|
+
unpacker = Unpacker.new
|
187
|
+
unpacker.feed(packer.to_s)
|
170
188
|
lambda {
|
171
189
|
unpacker.skip
|
172
190
|
}.should raise_error(MessagePack::StackError)
|
@@ -232,8 +250,8 @@ describe Unpacker do
|
|
232
250
|
|
233
251
|
it 'MessagePack.unpack symbolize_keys' do
|
234
252
|
symbolized_hash = {:a => 'b', :c => 'd'}
|
235
|
-
MessagePack.load(MessagePack.pack(symbolized_hash), symbolize_keys
|
236
|
-
MessagePack.unpack(MessagePack.pack(symbolized_hash), symbolize_keys
|
253
|
+
MessagePack.load(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
|
254
|
+
MessagePack.unpack(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
|
237
255
|
end
|
238
256
|
|
239
257
|
it 'Unpacker#unpack symbolize_keys' do
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
5
|
-
prerelease:
|
4
|
+
version: 0.5.9
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sadayuki Furuhashi
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-10-06 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -46,7 +41,6 @@ dependencies:
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: rake-compiler
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
45
|
- - ~>
|
52
46
|
- !ruby/object:Gem::Version
|
@@ -54,7 +48,6 @@ dependencies:
|
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
52
|
- - ~>
|
60
53
|
- !ruby/object:Gem::Version
|
@@ -62,7 +55,6 @@ dependencies:
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: rspec
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
59
|
- - ~>
|
68
60
|
- !ruby/object:Gem::Version
|
@@ -70,7 +62,6 @@ dependencies:
|
|
70
62
|
type: :development
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
66
|
- - ~>
|
76
67
|
- !ruby/object:Gem::Version
|
@@ -78,7 +69,6 @@ dependencies:
|
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: json
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
73
|
- - ~>
|
84
74
|
- !ruby/object:Gem::Version
|
@@ -86,7 +76,6 @@ dependencies:
|
|
86
76
|
type: :development
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
80
|
- - ~>
|
92
81
|
- !ruby/object:Gem::Version
|
@@ -94,7 +83,6 @@ dependencies:
|
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: yard
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
87
|
- - ~>
|
100
88
|
- !ruby/object:Gem::Version
|
@@ -102,7 +90,6 @@ dependencies:
|
|
102
90
|
type: :development
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
94
|
- - ~>
|
108
95
|
- !ruby/object:Gem::Version
|
@@ -117,6 +104,7 @@ extensions:
|
|
117
104
|
extra_rdoc_files: []
|
118
105
|
files:
|
119
106
|
- .gitignore
|
107
|
+
- .travis.yml
|
120
108
|
- ChangeLog
|
121
109
|
- Gemfile
|
122
110
|
- README.rdoc
|
@@ -152,12 +140,15 @@ files:
|
|
152
140
|
- lib/msgpack.rb
|
153
141
|
- lib/msgpack/version.rb
|
154
142
|
- msgpack.gemspec
|
155
|
-
-
|
156
|
-
- spec/buffer_spec.rb
|
143
|
+
- msgpack.org.md
|
157
144
|
- spec/cases.json
|
158
145
|
- spec/cases.msg
|
159
146
|
- spec/cases_compact.msg
|
160
147
|
- spec/cases_spec.rb
|
148
|
+
- spec/cruby/buffer_io_spec.rb
|
149
|
+
- spec/cruby/buffer_packer.rb
|
150
|
+
- spec/cruby/buffer_spec.rb
|
151
|
+
- spec/cruby/buffer_unpacker.rb
|
161
152
|
- spec/format_spec.rb
|
162
153
|
- spec/packer_spec.rb
|
163
154
|
- spec/random_compat.rb
|
@@ -166,35 +157,36 @@ files:
|
|
166
157
|
homepage: http://msgpack.org/
|
167
158
|
licenses:
|
168
159
|
- Apache 2.0
|
160
|
+
metadata: {}
|
169
161
|
post_install_message:
|
170
162
|
rdoc_options: []
|
171
163
|
require_paths:
|
172
164
|
- lib
|
173
165
|
required_ruby_version: !ruby/object:Gem::Requirement
|
174
|
-
none: false
|
175
166
|
requirements:
|
176
167
|
- - ! '>='
|
177
168
|
- !ruby/object:Gem::Version
|
178
169
|
version: '0'
|
179
170
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
-
none: false
|
181
171
|
requirements:
|
182
172
|
- - ! '>='
|
183
173
|
- !ruby/object:Gem::Version
|
184
174
|
version: '0'
|
185
175
|
requirements: []
|
186
176
|
rubyforge_project: msgpack
|
187
|
-
rubygems_version:
|
177
|
+
rubygems_version: 2.2.2
|
188
178
|
signing_key:
|
189
|
-
specification_version:
|
179
|
+
specification_version: 4
|
190
180
|
summary: MessagePack, a binary-based efficient data interchange format.
|
191
181
|
test_files:
|
192
|
-
- spec/buffer_io_spec.rb
|
193
|
-
- spec/buffer_spec.rb
|
194
182
|
- spec/cases.json
|
195
183
|
- spec/cases.msg
|
196
184
|
- spec/cases_compact.msg
|
197
185
|
- spec/cases_spec.rb
|
186
|
+
- spec/cruby/buffer_io_spec.rb
|
187
|
+
- spec/cruby/buffer_packer.rb
|
188
|
+
- spec/cruby/buffer_spec.rb
|
189
|
+
- spec/cruby/buffer_unpacker.rb
|
198
190
|
- spec/format_spec.rb
|
199
191
|
- spec/packer_spec.rb
|
200
192
|
- spec/random_compat.rb
|