msgpack 0.6.0-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +26 -0
  4. data/ChangeLog +129 -0
  5. data/Dockerfile +62 -0
  6. data/LICENSE +177 -0
  7. data/README.rdoc +141 -0
  8. data/Rakefile +68 -0
  9. data/bench/pack.rb +23 -0
  10. data/bench/pack_log.rb +33 -0
  11. data/bench/pack_log_long.rb +65 -0
  12. data/bench/run.sh +14 -0
  13. data/bench/run_long.sh +35 -0
  14. data/bench/unpack.rb +21 -0
  15. data/bench/unpack_log.rb +34 -0
  16. data/bench/unpack_log_long.rb +67 -0
  17. data/doclib/msgpack.rb +77 -0
  18. data/doclib/msgpack/buffer.rb +193 -0
  19. data/doclib/msgpack/core_ext.rb +101 -0
  20. data/doclib/msgpack/error.rb +14 -0
  21. data/doclib/msgpack/packer.rb +134 -0
  22. data/doclib/msgpack/unpacker.rb +146 -0
  23. data/ext/java/org/msgpack/jruby/Buffer.java +221 -0
  24. data/ext/java/org/msgpack/jruby/Decoder.java +201 -0
  25. data/ext/java/org/msgpack/jruby/Encoder.java +308 -0
  26. data/ext/java/org/msgpack/jruby/ExtensionValue.java +136 -0
  27. data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +107 -0
  28. data/ext/java/org/msgpack/jruby/Packer.java +78 -0
  29. data/ext/java/org/msgpack/jruby/Types.java +37 -0
  30. data/ext/java/org/msgpack/jruby/Unpacker.java +170 -0
  31. data/ext/msgpack/buffer.c +695 -0
  32. data/ext/msgpack/buffer.h +447 -0
  33. data/ext/msgpack/buffer_class.c +507 -0
  34. data/ext/msgpack/buffer_class.h +32 -0
  35. data/ext/msgpack/compat.h +114 -0
  36. data/ext/msgpack/core_ext.c +129 -0
  37. data/ext/msgpack/core_ext.h +26 -0
  38. data/ext/msgpack/extconf.rb +30 -0
  39. data/ext/msgpack/packer.c +168 -0
  40. data/ext/msgpack/packer.h +441 -0
  41. data/ext/msgpack/packer_class.c +302 -0
  42. data/ext/msgpack/packer_class.h +30 -0
  43. data/ext/msgpack/rbinit.c +33 -0
  44. data/ext/msgpack/rmem.c +94 -0
  45. data/ext/msgpack/rmem.h +109 -0
  46. data/ext/msgpack/sysdep.h +115 -0
  47. data/ext/msgpack/sysdep_endian.h +50 -0
  48. data/ext/msgpack/sysdep_types.h +46 -0
  49. data/ext/msgpack/unpacker.c +771 -0
  50. data/ext/msgpack/unpacker.h +122 -0
  51. data/ext/msgpack/unpacker_class.c +405 -0
  52. data/ext/msgpack/unpacker_class.h +32 -0
  53. data/lib/msgpack.rb +13 -0
  54. data/lib/msgpack/version.rb +3 -0
  55. data/msgpack.gemspec +31 -0
  56. data/msgpack.org.md +46 -0
  57. data/spec/cases.json +1 -0
  58. data/spec/cases.msg +0 -0
  59. data/spec/cases_compact.msg +0 -0
  60. data/spec/cases_spec.rb +39 -0
  61. data/spec/cruby/buffer_io_spec.rb +256 -0
  62. data/spec/cruby/buffer_packer.rb +29 -0
  63. data/spec/cruby/buffer_spec.rb +572 -0
  64. data/spec/cruby/buffer_unpacker.rb +19 -0
  65. data/spec/cruby/packer_spec.rb +120 -0
  66. data/spec/cruby/unpacker_spec.rb +305 -0
  67. data/spec/format_spec.rb +282 -0
  68. data/spec/jruby/benchmarks/shootout_bm.rb +73 -0
  69. data/spec/jruby/benchmarks/symbolize_keys_bm.rb +25 -0
  70. data/spec/jruby/msgpack/unpacker_spec.rb +290 -0
  71. data/spec/jruby/msgpack_spec.rb +142 -0
  72. data/spec/pack_spec.rb +67 -0
  73. data/spec/random_compat.rb +24 -0
  74. data/spec/spec_helper.rb +27 -0
  75. data/spec/unpack_spec.rb +60 -0
  76. metadata +208 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 750e082e1238df1beda0325e9b4320e244f91ffe
4
+ data.tar.gz: de72c25c884a8861ddb5fbecb34370b766a7b7fe
5
+ SHA512:
6
+ metadata.gz: f5d4e47135bb11a437a132b63addc0b73462d0268fffe0f8493ac0a9ae464bceb7860728d9ed141e206bedcb24bf78eee3ec348294e4c8f1e8a942e4c15d1bc5
7
+ data.tar.gz: 8602e1475dc69392d2e22cb0fbba7b04a24170c28b534c1964a083ac1359b94f37ec12a47adc056e081d434ac65f33e307703ed5caad7881dfbabee1a284cdf1
@@ -0,0 +1,20 @@
1
+ *.o
2
+ *.so
3
+ *.bundle
4
+ *.gem
5
+ *.class
6
+ *.jar
7
+ doc
8
+ .yardoc
9
+ .bundle
10
+ Gemfile*
11
+ pkg
12
+ test/debug.log
13
+ *~
14
+ /rdoc
15
+ tmp
16
+ .classpath
17
+ .project
18
+ .settings
19
+ /nbproject/private/
20
+
@@ -0,0 +1,26 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.6
6
+ - 2.2.2
7
+ - ruby-head
8
+ - rbx-2
9
+ - jruby-19mode
10
+ - jruby-head
11
+
12
+ os:
13
+ - linux
14
+ - osx
15
+
16
+ branches:
17
+ only:
18
+ - master
19
+
20
+ gemfile:
21
+ - Gemfile
22
+
23
+ matrix:
24
+ allow_failures:
25
+ - rvm: ruby-head
26
+ - rvm: jruby-head
@@ -0,0 +1,129 @@
1
+
2
+ 2015-05-26 version 0.6.0:
3
+
4
+ * Added support for Binary types
5
+ * Fixed to encode/decode between Binary types and ASCII-8BIT Ruby String objects
6
+
7
+ 2015-05-21 version 0.5.12:
8
+
9
+ * Added support for JRuby 9K.
10
+ * Added a benchmarking suite.
11
+ * Fixed a bug in the handling of options given to MessagePack.unpack in JRuby.
12
+
13
+
14
+ 2015-02-04 version 0.5.11:
15
+
16
+ * Fixed Encoding::CompatibilityError error when serializing a long string
17
+ longer than write_reference_threshold (5KB by default) and whose encoding
18
+ is not ASCII-8BIT.
19
+ * Fix read_(map|array)_header (@funny-falcon++).
20
+ * Internally, rename msgpack_unpacker_{init,reset,destroy} functions
21
+ so that we can load msgpack-c in the same process (@miihael++)
22
+
23
+
24
+ 2015-01-09 version 0.5.10:
25
+
26
+ * Merged msgpack-jruby by @iconara. JRuby can run `require 'msgpack'` to use
27
+ msgpack-jruby.
28
+
29
+
30
+ 2014-10-05 version 0.5.9:
31
+
32
+ * Fixed Unpacker#read_map_header and #read_array_header
33
+ * Added support for Symbol GC added since MRI 2.2.0
34
+
35
+
36
+ 2013-12-14 version 0.5.8:
37
+
38
+ * Fixed compatibility with Ruby 2.1.0
39
+ * Added :symbolize_keys option to MessagePack.load and Unpacker#initialize
40
+
41
+
42
+ 2013-10-12 version 0.5.7:
43
+
44
+ * Added deserialization support for the new MessagePack spec
45
+
46
+
47
+ 2013-09-23 version 0.5.6:
48
+
49
+ * Fixed "can't modify frozen String" exception in Unpacker with ruby 2.1.0-dev
50
+ * Getting work with Ruby v2.0 on Windows (Thank you @thegreendroid)
51
+ * Fixed EOFError handling in Unpacker
52
+
53
+
54
+ 2013-05-12 version 0.5.5:
55
+
56
+ * Fixed SEGV problem in to_msgpack
57
+ * Fixed a possible race condition in MessagePack.load when it loads data from IO
58
+ * mingw32 package includes binary for ruby-2.0.0
59
+
60
+
61
+ 2013-03-15 version 0.5.4:
62
+
63
+ * Added missing MessagePack::Unpacker#reset method
64
+
65
+
66
+ 2013-02-14 version 0.5.3:
67
+
68
+ * Fixed segfault problem on Buffer#clear (reuse rmem internal fragment optimization)
69
+ * Fixed segfault problem on Buffer (rmem free code)
70
+
71
+
72
+ 2013-02-07 version 0.5.2:
73
+
74
+ * Fixed invalid pack/unpack on 32bit architecture such as Win32
75
+ * Disable rmem on Rubinius because rmem is not thread safe
76
+
77
+
78
+ 2012-12-23 version 0.5.1:
79
+
80
+ * Fixed compile error with Rubinius 2.0.0-dev
81
+ * Optimized msgpack_packer_write_hash for Rubinius
82
+
83
+
84
+ 2012-12-20 version 0.5.0:
85
+
86
+ * Rewrote all code and improved performance significantly
87
+ * Added MessagePack::Buffer class
88
+ * Added MessagePack::Packer class
89
+ * Added Packer#buffer and Unpacker#buffer accessors which return MessagePack::Buffer
90
+ * Added Packer#write_{array,map}_header and Unpacker#read_{array,map}_header methods
91
+ * Added Packer#write_nil and Unpacker#skip_nil methods
92
+ * Added Packer#write -> #pack alias and Unpacker#read method
93
+ * Added exception classes - UnpackError, MalformedFormatError, StackError and TypeError
94
+ * Added MessagePack.dup -> .pack and MessagePack.load -> .unpack aliases
95
+ * Added Packer#empty?, #size and #clear methods
96
+ * Added Packer#write_to(io) method to flush serialized data to IO efficiently
97
+ * Added Unpacker#skip method to skip an object efficiently
98
+ * Removed obsoleted Unpacker#fill, #execute, #execute_limit, #finished? and #data methods
99
+ * Removed obsoleted Unapcker#stream and #stream= methods. Use unpacker.buffer.io instead
100
+
101
+
102
+ 2012-05-05 version 0.4.7:
103
+
104
+ * Fixed serialization of double values on ARM OABI architectures
105
+ * Fixed byteorder problem on big-endian platforms
106
+ * Don't use MRI internals in the Ruby extension for Rubinius
107
+ * Detect whether st.h is present and don't use RUBY_VM as the condition for
108
+ Rubinius
109
+
110
+ 2011-08-08 version 0.4.6:
111
+
112
+ * Fixed compile error problem on Mac OS X Lion
113
+
114
+ 2011-05-09 version 0.4.5:
115
+
116
+ * Improves compatibility with JRuby
117
+
118
+ 2010-11-28 version 0.4.4:
119
+
120
+ * Adds Unpacker#feed_each method
121
+ * Improves compatibility with Rubinius
122
+ * Improves compatibility with ruby-1.8.5
123
+ * Encodings of String instances to UTF-8 on Ruby 1.9
124
+
125
+ 2010-06-29 version 0.4.3:
126
+
127
+ * Adds MessagePack::VERSION constant
128
+ * Fixes SEGV problem caused by GC bug at MessagePack_Unpacker_mark
129
+
@@ -0,0 +1,62 @@
1
+ FROM ubuntu:14.04
2
+ MAINTAINER TAGOMORI Satoshi <tagomoris@gmail.com>
3
+ LABEL Description="Host image to cross-compile msgpack.gem for mingw32" Vendor="MessagePack Organization" Version="1.0"
4
+
5
+ RUN apt-get update -y && apt-get install -y \
6
+ git \
7
+ curl \
8
+ autoconf \
9
+ bison \
10
+ build-essential \
11
+ libssl-dev \
12
+ libyaml-dev \
13
+ libreadline6-dev \
14
+ zlib1g-dev \
15
+ libncurses5-dev \
16
+ libffi-dev \
17
+ libgdbm3 \
18
+ libgdbm-dev \
19
+ mingw-w64 \
20
+ gcc-mingw-w64-i686 \
21
+ gcc-mingw-w64-x86-64 \
22
+ && rm -rf /var/lib/apt/lists/*
23
+
24
+ RUN useradd ubuntu -d /home/ubuntu -m -U
25
+ RUN chown -R ubuntu:ubuntu /home/ubuntu
26
+
27
+ USER ubuntu
28
+
29
+ WORKDIR /home/ubuntu
30
+
31
+ RUN git clone https://github.com/tagomoris/xbuild.git
32
+ RUN git clone https://github.com/msgpack/msgpack-ruby.git
33
+
34
+ RUN /home/ubuntu/xbuild/ruby-install 2.0.0-p643 /home/ubuntu/local/ruby-2.0
35
+
36
+ ENV PATH /home/ubuntu/local/ruby-2.0/bin:$PATH
37
+ RUN gem install rake-compiler
38
+ RUN rake-compiler cross-ruby VERSION=2.0.0-p643 HOST=i686-w64-mingw32 EXTS=--without-extensions
39
+ RUN rake-compiler cross-ruby VERSION=2.0.0-p643 HOST=x86_64-w64-mingw32 EXTS=--without-extensions
40
+
41
+ RUN /home/ubuntu/xbuild/ruby-install 2.1.5 /home/ubuntu/local/ruby-2.1
42
+
43
+ ENV PATH /home/ubuntu/local/ruby-2.1/bin:$PATH
44
+ RUN gem install rake-compiler
45
+ RUN rake-compiler cross-ruby VERSION=2.1.5 HOST=i686-w64-mingw32 EXTS=--without-extensions
46
+ RUN rake-compiler cross-ruby VERSION=2.1.5 HOST=x86_64-w64-mingw32 EXTS=--without-extensions
47
+
48
+ RUN /home/ubuntu/xbuild/ruby-install 2.2.2 /home/ubuntu/local/ruby-2.2
49
+
50
+ ENV PATH /home/ubuntu/local/ruby-2.2/bin:$PATH
51
+ RUN gem install rake-compiler
52
+ RUN rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 EXTS=--without-extensions
53
+ RUN rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 EXTS=--without-extensions
54
+
55
+ WORKDIR /home/ubuntu/msgpack-ruby
56
+
57
+ ENV MSGPACK_REPO https://github.com/msgpack/msgpack-ruby.git
58
+ ENV BUILD_BRANCH master
59
+ ENV BUILD_POSITION HEAD
60
+
61
+ ### docker run -v `pwd`/pkg:/home/ubuntu/msgpack-ruby/pkg IMAGENAME
62
+ CMD ["bash", "-c", "git remote add dockerbuild $MSGPACK_REPO && git fetch dockerbuild && git checkout $BUILD_BRANCH && git reset --hard $BUILD_POSITION && bundle && rake cross native gem"]
data/LICENSE ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,141 @@
1
+
2
+ = MessagePack
3
+
4
+ MessagePack[http://msgpack.org] is an efficient binary serialization format.
5
+ It lets you exchange data among multiple languages like JSON but it's faster and smaller.
6
+ For example, small integers (like flags or error code) are encoded into a single byte,
7
+ and typical short strings only require an extra byte in addition to the strings themselves.
8
+
9
+ If you ever wished to use JSON for convenience (storing an image with metadata) but could
10
+ not for technical reasons (binary data, size, speed...), MessagePack is a perfect replacement.
11
+
12
+ require 'msgpack'
13
+ msg = [1,2,3].to_msgpack #=> "\x93\x01\x02\x03"
14
+ MessagePack.unpack(msg) #=> [1,2,3]
15
+
16
+ Use RubyGems to install:
17
+
18
+ gem install msgpack
19
+
20
+ or build msgpack-ruby and install:
21
+
22
+ bundle
23
+ rake
24
+ gem install --local pkg/msgpack
25
+
26
+
27
+ = Use cases
28
+
29
+ * Create REST API returing MessagePack using Rails + [RABL](https://github.com/nesquena/rabl)
30
+ * Store objects efficiently serialized by msgpack on memcached or Redis
31
+ * In fact Redis supports msgpack in EVAL-scripts[http://redis.io/commands/eval]
32
+ * Upload data in efficient format from mobile devices such as smartphones
33
+ * MessagePack works on iPhone/iPad and Android. See also Objective-C[https://github.com/msgpack/msgpack-objectivec] and Java[https://github.com/msgpack/msgpack-java] implementations
34
+ * Design a portable protocol to communicate with embedded devices
35
+ * Check also Fluentd[http://fluentd.org/] which is a log collector which uses msgpack for the log format (they say it uses JSON but actually it's msgpack, which is compatible with JSON)
36
+ * Exchange objects between software components written in different languages
37
+ * You'll need a flexible but efficient format so that components exchange objects while keeping compatibility
38
+
39
+
40
+ = Portability
41
+
42
+ MessagePack for Ruby should run on x86, ARM, PowerPC, SPARC and other CPU architectures.
43
+
44
+ And it works with MRI (CRuby) and Rubinius.
45
+ Patches to improve portability is highly welcomed.
46
+
47
+
48
+ = Serializing objects
49
+
50
+ Use *MessagePack.pack* or *to_msgpack*:
51
+
52
+ require 'msgpack'
53
+ msg = MessagePack.pack(obj) # or
54
+ msg = obj.to_msgpack
55
+
56
+ == Streaming serialization
57
+
58
+ Packer provides advanced API to serialize objects in streaming style:
59
+
60
+ # serialize a 2-element array [e1, e2]
61
+ pk = MessagePack::Packer.new(io)
62
+ pk.write_array_header(2).write(e1).write(e2).flush
63
+
64
+ See {API reference}[http://ruby.msgpack.org/MessagePack/Packer.html] for details.
65
+
66
+ = Deserializing objects
67
+
68
+ Use *MessagePack.unpack*:
69
+
70
+ require 'msgpack'
71
+ obj = MessagePack.unpack(msg)
72
+
73
+ == Streaming deserialization
74
+
75
+ Unpacker provides advanced API to deserialize objects in streaming style:
76
+
77
+ # deserialize objects from an IO
78
+ u = MessagePack::Unpacker.new(io)
79
+ u.each do |obj|
80
+ # ...
81
+ end
82
+
83
+ or event-driven style which works well with EventMachine:
84
+
85
+ # event-driven deserialization
86
+ def on_read(data)
87
+ @u ||= MessagePack::Unpacker.new
88
+ @u.feed_each(data) {|obj|
89
+ # ...
90
+ }
91
+ end
92
+
93
+ See {API reference}[http://ruby.msgpack.org/MessagePack/Unpacker.html] for details.
94
+
95
+
96
+ = Buffer API
97
+
98
+ MessagePack for Ruby provides a buffer API so that you can read or write data by hand, not via Packer or Unpacker API.
99
+
100
+ This {MessagePack::Buffer}[http://ruby.msgpack.org/MessagePack/Buffer.html] is backed with a fixed-length shared memory pool which is very fast for small data (<= 4KB),
101
+ and has zero-copy capability which significantly affects performance to handle large binary data.
102
+
103
+ = How to build and run tests
104
+
105
+ Before building msgpack, you need to install bundler and dependencies.
106
+
107
+ gem install bundler
108
+ bundle install
109
+
110
+ Then, you can run the tasks as follows:
111
+
112
+ * Build
113
+
114
+ bundle exec rake build
115
+
116
+ * Run tests
117
+
118
+ bundle exec rake spec
119
+
120
+ * Generating docs
121
+
122
+ bundle exec rake doc
123
+
124
+ == How to build -mingw32 rubygems
125
+
126
+ MessagePack mingw32 rubygems build process uses {Docker}[https://docs.docker.com/].
127
+
128
+ Set up docker environment at first, and then run docker container to build gems, with shared directory "pkg".
129
+
130
+ docker run -it --rm -v `pwd`/pkg:/home/ubuntu/msgpack-ruby/pkg msgpack/msgpack-rubygem-cross01
131
+
132
+ Once this step successes, target gems exist in pkg/msgpack-*-{x86,x64}-mingw32.gem.
133
+
134
+ See also: https://registry.hub.docker.com/u/msgpack/msgpack-rubygem-cross01/
135
+
136
+ = Copyright
137
+
138
+ Author:: Sadayuki Furuhashi <frsyuki@gmail.com>
139
+ Copyright:: Copyright (c) 2008-2013 Sadayuki Furuhashi
140
+ License:: Apache License, Version 2.0
141
+