msgpack 0.6.0pre1-x64-mingw32

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.
Files changed (79) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +26 -0
  4. data/ChangeLog +117 -0
  5. data/Dockerfile +30 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE +177 -0
  8. data/README.rdoc +129 -0
  9. data/Rakefile +114 -0
  10. data/bench/pack.rb +23 -0
  11. data/bench/pack_log.rb +33 -0
  12. data/bench/pack_log_long.rb +65 -0
  13. data/bench/run.sh +14 -0
  14. data/bench/run_long.sh +35 -0
  15. data/bench/unpack.rb +21 -0
  16. data/bench/unpack_log.rb +34 -0
  17. data/bench/unpack_log_long.rb +67 -0
  18. data/cross-build.sh +9 -0
  19. data/doclib/msgpack/buffer.rb +193 -0
  20. data/doclib/msgpack/core_ext.rb +101 -0
  21. data/doclib/msgpack/error.rb +14 -0
  22. data/doclib/msgpack/packer.rb +134 -0
  23. data/doclib/msgpack/unpacker.rb +146 -0
  24. data/doclib/msgpack.rb +77 -0
  25. data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
  26. data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
  27. data/ext/java/org/msgpack/jruby/Encoder.java +308 -0
  28. data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
  29. data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +107 -0
  30. data/ext/java/org/msgpack/jruby/Packer.java +78 -0
  31. data/ext/java/org/msgpack/jruby/Types.java +37 -0
  32. data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
  33. data/ext/msgpack/buffer.c +695 -0
  34. data/ext/msgpack/buffer.h +447 -0
  35. data/ext/msgpack/buffer_class.c +507 -0
  36. data/ext/msgpack/buffer_class.h +32 -0
  37. data/ext/msgpack/compat.h +113 -0
  38. data/ext/msgpack/core_ext.c +129 -0
  39. data/ext/msgpack/core_ext.h +26 -0
  40. data/ext/msgpack/extconf.rb +28 -0
  41. data/ext/msgpack/packer.c +168 -0
  42. data/ext/msgpack/packer.h +441 -0
  43. data/ext/msgpack/packer_class.c +302 -0
  44. data/ext/msgpack/packer_class.h +30 -0
  45. data/ext/msgpack/rbinit.c +33 -0
  46. data/ext/msgpack/rmem.c +94 -0
  47. data/ext/msgpack/rmem.h +109 -0
  48. data/ext/msgpack/sysdep.h +115 -0
  49. data/ext/msgpack/sysdep_endian.h +50 -0
  50. data/ext/msgpack/sysdep_types.h +46 -0
  51. data/ext/msgpack/unpacker.c +771 -0
  52. data/ext/msgpack/unpacker.h +122 -0
  53. data/ext/msgpack/unpacker_class.c +405 -0
  54. data/ext/msgpack/unpacker_class.h +32 -0
  55. data/lib/msgpack/msgpack.so +0 -0
  56. data/lib/msgpack/version.rb +3 -0
  57. data/lib/msgpack.rb +13 -0
  58. data/msgpack.gemspec +31 -0
  59. data/msgpack.org.md +46 -0
  60. data/spec/cases.json +1 -0
  61. data/spec/cases.msg +0 -0
  62. data/spec/cases_compact.msg +0 -0
  63. data/spec/cases_spec.rb +39 -0
  64. data/spec/cruby/buffer_io_spec.rb +256 -0
  65. data/spec/cruby/buffer_packer.rb +29 -0
  66. data/spec/cruby/buffer_spec.rb +572 -0
  67. data/spec/cruby/buffer_unpacker.rb +19 -0
  68. data/spec/cruby/packer_spec.rb +120 -0
  69. data/spec/cruby/unpacker_spec.rb +305 -0
  70. data/spec/format_spec.rb +282 -0
  71. data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
  72. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
  73. data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
  74. data/spec/jruby/msgpack_spec.rb +142 -0
  75. data/spec/pack_spec.rb +67 -0
  76. data/spec/random_compat.rb +24 -0
  77. data/spec/spec_helper.rb +27 -0
  78. data/spec/unpack_spec.rb +60 -0
  79. metadata +209 -0
@@ -0,0 +1,65 @@
1
+ # viiite report --regroup bench,threads bench/pack_log_long.rb
2
+
3
+ require 'viiite'
4
+ require 'msgpack'
5
+
6
+ data_plain = { 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"' }
7
+ data_structure = {
8
+ 'remote_host' => '127.0.0.1',
9
+ 'remote_user' => '-',
10
+ 'date' => '10/Oct/2000:13:55:36 -0700',
11
+ 'request' => 'GET /apache_pb.gif HTTP/1.0',
12
+ 'method' => 'GET',
13
+ 'path' => '/apache_pb.gif',
14
+ 'protocol' => 'HTTP/1.0',
15
+ 'status' => 200,
16
+ 'bytes' => 2326,
17
+ 'referer' => 'http://www.example.com/start.html',
18
+ 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
19
+ }
20
+
21
+ seconds = 3600 # 1 hour
22
+
23
+ Viiite.bench do |b|
24
+ b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
25
+ b.report(:plain) do
26
+ ths = []
27
+ end_at = Time.now + seconds
28
+ threads.times do
29
+ t = Thread.new do
30
+ packs = 0
31
+ while Time.now < end_at
32
+ 10000.times do
33
+ MessagePack.pack(data_plain)
34
+ end
35
+ packs += 10000
36
+ end
37
+ packs
38
+ end
39
+ ths.push t
40
+ end
41
+ sum = ths.reduce(0){|r,t| r + t.value }
42
+ puts "MessagePack.pack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
43
+ end
44
+
45
+ b.report(:structure) do
46
+ ths = []
47
+ end_at = Time.now + seconds
48
+ threads.times do
49
+ t = Thread.new do
50
+ packs = 0
51
+ while Time.now < end_at
52
+ 10000.times do
53
+ MessagePack.pack(data_structure)
54
+ end
55
+ packs += 10000
56
+ end
57
+ packs
58
+ end
59
+ ths.push t
60
+ end
61
+ sum = ths.reduce(0){|r,t| r + t.value }
62
+ puts "MessagePack.pack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
63
+ end
64
+ end
65
+ end
data/bench/run.sh ADDED
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+
3
+ # prerequisites
4
+ # $ rbenv shell 2.2.1 (or jruby-x.x.x or ...)
5
+ # $ rake install
6
+
7
+ echo "pack"
8
+ viiite report --regroup bench,runs bench/pack.rb
9
+ echo "unpack"
10
+ viiite report --regroup bench,runs bench/unpack.rb
11
+ echo "pack log"
12
+ viiite report --regroup bench,runs bench/pack_log.rb
13
+ echo "unpack log"
14
+ viiite report --regroup bench,runs bench/unpack_log.rb
data/bench/run_long.sh ADDED
@@ -0,0 +1,35 @@
1
+ #!/bin/sh
2
+
3
+ # prerequisites
4
+ # $ sudo apt-get install sysstat
5
+ # $ rbenv shell 2.2.1 (or jruby-x.x.x or ...)
6
+ # $ rake install
7
+
8
+ # 60 * 600 : 60*60 * 5[threads] * 2[bench]
9
+
10
+ ruby -v
11
+
12
+ echo "pack log long"
13
+ viiite report --regroup bench,threads bench/pack_log_long.rb &
14
+ sar -o pack_log_long.sar -r 60 600 > /dev/null 2>&1 &
15
+
16
+ declare -i i=0
17
+ while [ $i -lt 600 ]; do
18
+ ps auxww | grep ruby | grep -v grep | awk '{print $5,$6;}' >> pack_log_long.mem.txt
19
+ i=i+1
20
+ sleep 60
21
+ done
22
+
23
+ sleep 120 # cool down
24
+
25
+ echo "unpack log long"
26
+ viiite report --regroup bench,threads bench/unpack_log_long.rb &
27
+ sar -o unpack_log_long.sar -r 60 600 > /dev/null 2>&1 &
28
+
29
+ i=0
30
+ while [ $i -lt 600 ]; do
31
+ ps auxww | grep ruby | grep -v grep | awk '{print $5,$6;}' >> pack_log_long.mem.txt
32
+ i=i+1
33
+ sleep 60
34
+ done
35
+
data/bench/unpack.rb ADDED
@@ -0,0 +1,21 @@
1
+ require 'viiite'
2
+ require 'msgpack'
3
+
4
+ data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}])
5
+
6
+ Viiite.bench do |b|
7
+ b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
8
+ b.report(:strings) do
9
+ runs.times do
10
+ MessagePack.unpack(data)
11
+ end
12
+ end
13
+
14
+ b.report(:symbols) do
15
+ options = {:symbolize_keys => true}
16
+ runs.times do
17
+ MessagePack.unpack(data, options)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,34 @@
1
+ require 'viiite'
2
+ require 'msgpack'
3
+
4
+ data_plain = MessagePack.pack({ 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"' })
5
+
6
+ data_structure = MessagePack.pack({
7
+ 'remote_host' => '127.0.0.1',
8
+ 'remote_user' => '-',
9
+ 'date' => '10/Oct/2000:13:55:36 -0700',
10
+ 'request' => 'GET /apache_pb.gif HTTP/1.0',
11
+ 'method' => 'GET',
12
+ 'path' => '/apache_pb.gif',
13
+ 'protocol' => 'HTTP/1.0',
14
+ 'status' => 200,
15
+ 'bytes' => 2326,
16
+ 'referer' => 'http://www.example.com/start.html',
17
+ 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
18
+ })
19
+
20
+ Viiite.bench do |b|
21
+ b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
22
+ b.report(:plain) do
23
+ runs.times do
24
+ MessagePack.unpack(data_plain)
25
+ end
26
+ end
27
+
28
+ b.report(:structure) do
29
+ runs.times do
30
+ MessagePack.unpack(data_structure)
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,67 @@
1
+ # viiite report --regroup bench,threads bench/pack_log_long.rb
2
+
3
+ require 'viiite'
4
+ require 'msgpack'
5
+
6
+ data_plain = MessagePack.pack({
7
+ 'message' => '127.0.0.1 - - [10/Oct/2000:13:55:36 -0700] "GET /apache_pb.gif HTTP/1.0" 200 2326 "http://www.example.com/start.html" "Mozilla/4.08 [en] (Win98; I ;Nav)"'
8
+ })
9
+ data_structure = MessagePack.pack({
10
+ 'remote_host' => '127.0.0.1',
11
+ 'remote_user' => '-',
12
+ 'date' => '10/Oct/2000:13:55:36 -0700',
13
+ 'request' => 'GET /apache_pb.gif HTTP/1.0',
14
+ 'method' => 'GET',
15
+ 'path' => '/apache_pb.gif',
16
+ 'protocol' => 'HTTP/1.0',
17
+ 'status' => 200,
18
+ 'bytes' => 2326,
19
+ 'referer' => 'http://www.example.com/start.html',
20
+ 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
21
+ })
22
+
23
+ seconds = 3600 # 1 hour
24
+
25
+ Viiite.bench do |b|
26
+ b.range_over([1, 2, 4, 8, 16], :threads) do |threads|
27
+ b.report(:plain) do
28
+ ths = []
29
+ end_at = Time.now + seconds
30
+ threads.times do
31
+ t = Thread.new do
32
+ packs = 0
33
+ while Time.now < end_at
34
+ 10000.times do
35
+ MessagePack.unpack(data_plain)
36
+ end
37
+ packs += 10000
38
+ end
39
+ packs
40
+ end
41
+ ths.push t
42
+ end
43
+ sum = ths.reduce(0){|r,t| r + t.value }
44
+ puts "MessagePack.unpack, plain, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
45
+ end
46
+
47
+ b.report(:structure) do
48
+ ths = []
49
+ end_at = Time.now + seconds
50
+ threads.times do
51
+ t = Thread.new do
52
+ packs = 0
53
+ while Time.now < end_at
54
+ 10000.times do
55
+ MessagePack.unpack(data_structure)
56
+ end
57
+ packs += 10000
58
+ end
59
+ packs
60
+ end
61
+ ths.push t
62
+ end
63
+ sum = ths.reduce(0){|r,t| r + t.value }
64
+ puts "MessagePack.unpack, structured, #{threads} threads: #{sum} times, #{sum / seconds} times/second."
65
+ end
66
+ end
67
+ end
data/cross-build.sh ADDED
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ cd /home/ubuntu/msgpack-ruby
4
+ git remote add onetime $MSGPACK_REPO
5
+ git checkout master
6
+ git pull onetime $BUILD_BRANCH
7
+ git reset --hard $BUILD_POSITION
8
+ bundle install
9
+ bundle rake cross native gem
@@ -0,0 +1,193 @@
1
+ module MessagePack
2
+
3
+ class Buffer
4
+ #
5
+ # Creates a MessagePack::Buffer instance.
6
+ #
7
+ # @overload initialize(options={})
8
+ # @param options [Hash]
9
+ #
10
+ # @overload initialize(io, options={})
11
+ # @param io [IO]
12
+ # @param options [Hash]
13
+ # This buffer writes written data into the IO when it is filled.
14
+ # This buffer reads data from the IO when it is empty.
15
+ #
16
+ # _io_ must respond to readpartial(length, [,string]) or read(string) method and
17
+ # write(string) or append(string) method.
18
+ #
19
+ # Supported options:
20
+ #
21
+ # * *:io_buffer_size* buffer size to read data from the internal IO. (default: 32768)
22
+ # * *:read_reference_threshold* the threshold size to enable zero-copy deserialize optimization. Read strings longer than this threshold will refer the original string instead of copying it. (default: 256) (supported in MRI only)
23
+ # * *:write_reference_threshold* the threshold size to enable zero-copy serialize optimization. The buffer refers written strings longer than this threshold instead of copying it. (default: 524288) (supported in MRI only)
24
+ #
25
+ def initialize(*args)
26
+ end
27
+
28
+ #
29
+ # Makes the buffer empty
30
+ #
31
+ # @return nil
32
+ #
33
+ def clear
34
+ end
35
+
36
+ #
37
+ # Returns byte size of the buffer.
38
+ #
39
+ # @return nil
40
+ #
41
+ def size
42
+ end
43
+
44
+ #
45
+ # Returns _true_ if the buffer is empty.
46
+ # This method is slightly faster than _size_.
47
+ #
48
+ # @return [Boolean]
49
+ #
50
+ def empty?
51
+ end
52
+
53
+ #
54
+ # Appends the given data to the buffer.
55
+ #
56
+ # @param data [String]
57
+ # @return [Integer] byte size written
58
+ #
59
+ def write(data)
60
+ end
61
+
62
+ #
63
+ # Appends the given data to the buffer.
64
+ #
65
+ # @param data [String]
66
+ # @return [Buffer] self
67
+ #
68
+ def <<(data)
69
+ end
70
+
71
+ #
72
+ # Consumes _n_ bytes from the head of the buffer and returns consumed data.
73
+ # If the size of the buffer is less than _n_, it reads all of data in the buffer.
74
+ #
75
+ # If _n_ is 0, it does nothing and returns an empty string.
76
+ # If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
77
+ #
78
+ # @overload read
79
+ #
80
+ # @overload read(n)
81
+ # @param n [Integer] bytes to read
82
+ #
83
+ # @overload read(n, buffer)
84
+ # @param n [Integer] bytes to read
85
+ # @param buffer [String] buffer to read into
86
+ #
87
+ # @return [String]
88
+ #
89
+ def read(n)
90
+ end
91
+
92
+ #
93
+ # Consumes _n_ bytes from the head of the buffer and returns consumed data.
94
+ # If the size of the buffer is less than _n_, it does nothing and raises EOFError.
95
+ #
96
+ # If _n_ is 0, it does nothing and returns an empty string.
97
+ # If the optional _buffer_ argument is given, the content of the string will be replaced with the consumed data.
98
+ #
99
+ # @overload read_all
100
+ #
101
+ # @overload read_all(n)
102
+ # @param n [Integer] bytes to read
103
+ #
104
+ # @overload read_all(n, buffer)
105
+ # @param n [Integer] bytes to read
106
+ # @param buffer [String] buffer to read into
107
+ #
108
+ # @return [String]
109
+ #
110
+ def read_all(n, buffer=nil)
111
+ end
112
+
113
+ #
114
+ # Consumes _n_ bytes from the head of the buffer.
115
+ # If the size of the buffer is less than _n_, it skips all of data in the buffer and returns integer less than _n_.
116
+ #
117
+ # If _n_ is 0, it does nothing and returns _0_.
118
+ #
119
+ # @param n [Integer] byte size to skip
120
+ # @return [Integer] byte size actually skipped
121
+ #
122
+ def skip(n)
123
+ end
124
+
125
+ #
126
+ # Consumes _n_ bytes from the head of the buffer.
127
+ # If the size of the buffer is less than _n_, it does nothing and raises EOFError.
128
+ # If _n_ is 0, it does nothing.
129
+ #
130
+ # @param n [Integer] byte size to skip
131
+ # @return [Buffer] self
132
+ #
133
+ def skip_all(n)
134
+ end
135
+
136
+ #
137
+ # Returns all data in the buffer as a string.
138
+ # Destructive update to the returned string does NOT effect the buffer.
139
+ #
140
+ # @return [String]
141
+ #
142
+ def to_str
143
+ end
144
+
145
+ #
146
+ # Returns content of the buffer as an array of strings.
147
+ #
148
+ # This method is sometimes faster than to_s because the internal
149
+ # structure of the buffer is a queue of buffer chunks.
150
+ #
151
+ # @return [Array] array of strings
152
+ #
153
+ def to_a
154
+ end
155
+
156
+ #
157
+ # Internal io
158
+ #
159
+ # @return IO
160
+ #
161
+ attr_reader :io
162
+
163
+ #
164
+ # Flushes data in the internal buffer to the internal IO.
165
+ # If internal IO is not set, it does nothing.
166
+ #
167
+ # @return [Buffer] self
168
+ #
169
+ def flush
170
+ end
171
+
172
+ #
173
+ # Closes internal IO if its set.
174
+ # If internal IO is not set, it does nothing
175
+ #
176
+ # @return nil
177
+ #
178
+ def close
179
+ end
180
+
181
+ #
182
+ # Writes all of data in the internal buffer into the given IO.
183
+ # This method consumes and removes data from the internal buffer.
184
+ # _io_ must respond to write(data) method.
185
+ #
186
+ # @param io [IO]
187
+ # @return [Integer] byte size of written data
188
+ #
189
+ def write_to(io)
190
+ end
191
+ end
192
+
193
+ end
@@ -0,0 +1,101 @@
1
+
2
+ class NilClass
3
+ #
4
+ # Same as MessagePack.to_msgpack(self[, io]).
5
+ #
6
+ # @return [String] serialized data
7
+ #
8
+ def to_msgpack(io=nil)
9
+ end
10
+ end
11
+
12
+ class TrueClass
13
+ #
14
+ # Same as MessagePack.to_msgpack(self[, io]).
15
+ #
16
+ # @return [String] serialized data
17
+ #
18
+ def to_msgpack(io=nil)
19
+ end
20
+ end
21
+
22
+ class FalseClass
23
+ #
24
+ # Same as MessagePack.to_msgpack(self[, io]).
25
+ #
26
+ # @return [String] serialized data
27
+ #
28
+ def to_msgpack(io=nil)
29
+ end
30
+ end
31
+
32
+ class Fixnum < Integer
33
+ #
34
+ # Same as MessagePack.to_msgpack(self[, io]).
35
+ #
36
+ # @return [String] serialized data
37
+ #
38
+ def to_msgpack(io=nil)
39
+ end
40
+ end
41
+
42
+ class Bignum < Integer
43
+ #
44
+ # Same as MessagePack.to_msgpack(self[, io]).
45
+ #
46
+ # @return [String] serialized data
47
+ #
48
+ def to_msgpack(io=nil)
49
+ end
50
+ end
51
+
52
+ class Float < Numeric
53
+ #
54
+ # Same as MessagePack.to_msgpack(self[, io]).
55
+ #
56
+ # @return [String] serialized data
57
+ #
58
+ def to_msgpack(io=nil)
59
+ end
60
+ end
61
+
62
+ class String
63
+ #
64
+ # Same as MessagePack.to_msgpack(self[, io]).
65
+ #
66
+ # @return [String] serialized data
67
+ #
68
+ def to_msgpack(io=nil)
69
+ end
70
+ end
71
+
72
+ class Array
73
+ #
74
+ # Same as MessagePack.to_msgpack(self[, io]).
75
+ #
76
+ # @return [String] serialized data
77
+ #
78
+ def to_msgpack(io=nil)
79
+ end
80
+ end
81
+
82
+ class Hash
83
+ #
84
+ # Same as MessagePack.to_msgpack(self[, io]).
85
+ #
86
+ # @return [String] serialized data
87
+ #
88
+ def to_msgpack(io=nil)
89
+ end
90
+ end
91
+
92
+ class Symbol
93
+ #
94
+ # Same as MessagePack.to_msgpack(self[, io]).
95
+ #
96
+ # @return [String] serialized data
97
+ #
98
+ def to_msgpack(io=nil)
99
+ end
100
+ end
101
+
@@ -0,0 +1,14 @@
1
+ module MessagePack
2
+
3
+ class UnpackError < StandardError
4
+ end
5
+
6
+ class MalformedFormatError < UnpackError
7
+ end
8
+
9
+ class StackError < UnpackError
10
+ end
11
+
12
+ class TypeError < StandardError
13
+ end
14
+ end
@@ -0,0 +1,134 @@
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 serialzied objects into the IO when the internal buffer is filled.
18
+ # _io_ must respond to write(string) or append(string) method.
19
+ #
20
+ # See also Buffer#initialize for options.
21
+ #
22
+ def initialize(*args)
23
+ end
24
+
25
+ #
26
+ # Internal buffer
27
+ #
28
+ # @return MessagePack::Buffer
29
+ #
30
+ attr_reader :buffer
31
+
32
+ #
33
+ # Serializes an object into internal buffer, and flushes to io if necessary.
34
+ #
35
+ # If it could not serialize the object, it raises
36
+ # NoMethodError: undefined method `to_msgpack' for #<the_object>.
37
+ #
38
+ # @param obj [Object] object to serialize
39
+ # @return [Packer] self
40
+ #
41
+ def write(obj)
42
+ end
43
+
44
+ alias pack write
45
+
46
+ #
47
+ # Serializes a nil object. Same as write(nil).
48
+ #
49
+ def write_nil
50
+ end
51
+
52
+ #
53
+ # Write a header of an array whose size is _n_.
54
+ # For example, write_array_header(1).write(true) is same as write([ true ]).
55
+ #
56
+ # @return [Packer] self
57
+ #
58
+ def write_array_header(n)
59
+ end
60
+
61
+ #
62
+ # Write a header of an map whose size is _n_.
63
+ # For example, write_map_header(1).write('key').write(true) is same as write('key'=>true).
64
+ #
65
+ # @return [Packer] self
66
+ #
67
+ def write_map_header(n)
68
+ end
69
+
70
+ #
71
+ # Flushes data in the internal buffer to the internal IO. Same as _buffer.flush.
72
+ # If internal IO is not set, it does nothing.
73
+ #
74
+ # @return [Packer] self
75
+ #
76
+ def flush
77
+ end
78
+
79
+ #
80
+ # Makes the internal buffer empty. Same as _buffer.clear_.
81
+ #
82
+ # @return nil
83
+ #
84
+ def clear
85
+ end
86
+
87
+ #
88
+ # Returns size of the internal buffer. Same as buffer.size.
89
+ #
90
+ # @return [Integer]
91
+ #
92
+ def size
93
+ end
94
+
95
+ #
96
+ # Returns _true_ if the internal buffer is empty. Same as buffer.empty?.
97
+ # This method is slightly faster than _size_.
98
+ #
99
+ # @return [Boolean]
100
+ #
101
+ def empty?
102
+ end
103
+
104
+ #
105
+ # Returns all data in the buffer as a string. Same as buffer.to_str.
106
+ #
107
+ # @return [String]
108
+ #
109
+ def to_str
110
+ end
111
+
112
+ alias to_s to_str
113
+
114
+ #
115
+ # Returns content of the internal buffer as an array of strings. Same as buffer.to_a.
116
+ # This method is faster than _to_str_.
117
+ #
118
+ # @return [Array] array of strings
119
+ #
120
+ def to_a
121
+ end
122
+
123
+ #
124
+ # Writes all of data in the internal buffer into the given IO. Same as buffer.write_to(io).
125
+ # This method consumes and removes data from the internal buffer.
126
+ # _io_ must respond to write(data) method.
127
+ #
128
+ # @param io [IO]
129
+ # @return [Integer] byte size of written data
130
+ #
131
+ def write_to(io)
132
+ end
133
+ end
134
+ end