msgpack 0.6.0pre1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
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
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 672b7a4df1a4b231bb4a07352b1269f2f5e02162
4
+ data.tar.gz: bbc2bc931d13eea5dac6347c2dd2870d1fa1cf4b
5
+ SHA512:
6
+ metadata.gz: fa6a45fefd0a1500a408c94d54d7cabb4f5b45319cabaff110e8022caba938df554b52fa72fd23f7d735c3baad47cce4125d8ef66f8ffd821112b4b65415acb7
7
+ data.tar.gz: c6fdbf9a9cb27abc1435688520b5702756ae356fd9911a6d8eb70cd600e4e80d16feebdf484b3149cab229402fd12b08db40d16e2a8ed01d73d82cd23932784f
data/.gitignore ADDED
@@ -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
+
data/.travis.yml ADDED
@@ -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
data/ChangeLog ADDED
@@ -0,0 +1,117 @@
1
+
2
+ 2015-02-04 version 0.5.11:
3
+
4
+ * Fixed Encoding::CompatibilityError error when serializing a long string
5
+ longer than write_reference_threshold (5KB by default) and whose encoding
6
+ is not ASCII-8BIT.
7
+ * Fix read_(map|array)_header (@funny-falcon++).
8
+ * Internally, rename msgpack_unpacker_{init,reset,destroy} functions
9
+ so that we can load msgpack-c in the same process (@miihael++)
10
+
11
+
12
+ 2015-01-09 version 0.5.10:
13
+
14
+ * Merged msgpack-jruby by @iconara. JRuby can run `require 'msgpack'` to use
15
+ msgpack-jruby.
16
+
17
+
18
+ 2014-10-05 version 0.5.9:
19
+
20
+ * Fixed Unpacker#read_map_header and #read_array_header
21
+ * Added support for Symbol GC added since MRI 2.2.0
22
+
23
+
24
+ 2013-12-14 version 0.5.8:
25
+
26
+ * Fixed compatibility with Ruby 2.1.0
27
+ * Added :symbolize_keys option to MessagePack.load and Unpacker#initialize
28
+
29
+
30
+ 2013-10-12 version 0.5.7:
31
+
32
+ * Added deserialization support for the new MessagePack spec
33
+
34
+
35
+ 2013-09-23 version 0.5.6:
36
+
37
+ * Fixed "can't modify frozen String" exception in Unpacker with ruby 2.1.0-dev
38
+ * Getting work with Ruby v2.0 on Windows (Thank you @thegreendroid)
39
+ * Fixed EOFError handling in Unpacker
40
+
41
+
42
+ 2013-05-12 version 0.5.5:
43
+
44
+ * Fixed SEGV problem in to_msgpack
45
+ * Fixed a possible race condition in MessagePack.load when it loads data from IO
46
+ * mingw32 package includes binary for ruby-2.0.0
47
+
48
+
49
+ 2013-03-15 version 0.5.4:
50
+
51
+ * Added missing MessagePack::Unpacker#reset method
52
+
53
+
54
+ 2013-02-14 version 0.5.3:
55
+
56
+ * Fixed segfault problem on Buffer#clear (reuse rmem internal fragment optimization)
57
+ * Fixed segfault problem on Buffer (rmem free code)
58
+
59
+
60
+ 2013-02-07 version 0.5.2:
61
+
62
+ * Fixed invalid pack/unpack on 32bit architecture such as Win32
63
+ * Disable rmem on Rubinius because rmem is not thread safe
64
+
65
+
66
+ 2012-12-23 version 0.5.1:
67
+
68
+ * Fixed compile error with Rubinius 2.0.0-dev
69
+ * Optimized msgpack_packer_write_hash for Rubinius
70
+
71
+
72
+ 2012-12-20 version 0.5.0:
73
+
74
+ * Rewrote all code and improved performance significantly
75
+ * Added MessagePack::Buffer class
76
+ * Added MessagePack::Packer class
77
+ * Added Packer#buffer and Unpacker#buffer accessors which return MessagePack::Buffer
78
+ * Added Packer#write_{array,map}_header and Unpacker#read_{array,map}_header methods
79
+ * Added Packer#write_nil and Unpacker#skip_nil methods
80
+ * Added Packer#write -> #pack alias and Unpacker#read method
81
+ * Added exception classes - UnpackError, MalformedFormatError, StackError and TypeError
82
+ * Added MessagePack.dup -> .pack and MessagePack.load -> .unpack aliases
83
+ * Added Packer#empty?, #size and #clear methods
84
+ * Added Packer#write_to(io) method to flush serialized data to IO efficiently
85
+ * Added Unpacker#skip method to skip an object efficiently
86
+ * Removed obsoleted Unpacker#fill, #execute, #execute_limit, #finished? and #data methods
87
+ * Removed obsoleted Unapcker#stream and #stream= methods. Use unpacker.buffer.io instead
88
+
89
+
90
+ 2012-05-05 version 0.4.7:
91
+
92
+ * Fixed serialization of double values on ARM OABI architectures
93
+ * Fixed byteorder problem on big-endian platforms
94
+ * Don't use MRI internals in the Ruby extension for Rubinius
95
+ * Detect whether st.h is present and don't use RUBY_VM as the condition for
96
+ Rubinius
97
+
98
+ 2011-08-08 version 0.4.6:
99
+
100
+ * Fixed compile error problem on Mac OS X Lion
101
+
102
+ 2011-05-09 version 0.4.5:
103
+
104
+ * Improves compatibility with JRuby
105
+
106
+ 2010-11-28 version 0.4.4:
107
+
108
+ * Adds Unpacker#feed_each method
109
+ * Improves compatibility with Rubinius
110
+ * Improves compatibility with ruby-1.8.5
111
+ * Encodings of String instances to UTF-8 on Ruby 1.9
112
+
113
+ 2010-06-29 version 0.4.3:
114
+
115
+ * Adds MessagePack::VERSION constant
116
+ * Fixes SEGV problem caused by GC bug at MessagePack_Unpacker_mark
117
+
data/Dockerfile ADDED
@@ -0,0 +1,30 @@
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
+ USER ubuntu
6
+
7
+ RUN apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
8
+ RUN apt-get install gcc-mingw32 mingw-w64
9
+ # RUN git?
10
+ RUN git clone https://github.com/tagomoris/xbuild.git /home/ubuntu/.xbuild
11
+ RUN /home/ubuntu/.xbuild/ruby-install 2.2.2 /home/ubuntu/local/ruby-2.2
12
+ RUN PATH=/home/ubuntu/local/ruby-2.2/bin:$PATH /home/ubuntu/local/ruby-2.2/bin/gem install rake-compiler
13
+ RUN PATH=/home/ubuntu/local/ruby-2.2/bin:$PATH rake-compiler cross-ruby VERSION=2.2.2 EXTS=--without-extensions
14
+ RUN /home/ubuntu/.xbuild/ruby-install 2.1.5 /home/ubuntu/local/ruby-2.1
15
+ RUN PATH=/home/ubuntu/local/ruby-2.1/bin:$PATH /home/ubuntu/local/ruby-2.1/bin/gem install rake-compiler
16
+ RUN PATH=/home/ubuntu/local/ruby-2.1/bin:$PATH rake-compiler cross-ruby VERSION=2.1.5 EXTS=--without-extensions
17
+ RUN /home/ubuntu/.xbuild/ruby-install 2.0.0-p643 /home/ubuntu/local/ruby-2.0
18
+ RUN PATH=/home/ubuntu/local/ruby-2.0/bin:$PATH /home/ubuntu/local/ruby-2.0/bin/gem install rake-compiler
19
+ RUN PATH=/home/ubuntu/local/ruby-2.0/bin:$PATH rake-compiler cross-ruby VERSION=2.0.0-p643 EXTS=--without-extensions
20
+
21
+ RUN git clone https://github.com/msgpack/msgpack-ruby.git /home/ubuntu/msgpack-ruby
22
+
23
+ WORKDIR /home/ubuntu/msgpack-ruby
24
+
25
+ ENV MSGPACK_REPO https://github.com/msgpack/msgpack-ruby.git
26
+ ENV BUILD_BRANCH master
27
+ ENV BUILD_POSITION HEAD
28
+
29
+ ENTRYPOINT ["/home/ubuntu/msgpack-ruby/cross-build.sh", "/home/ubuntu/local/ruby-2.2", "2.0.0-p643:2.1.5:2.2.2"]
30
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
4
+ gem "viiite"
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
data/README.rdoc ADDED
@@ -0,0 +1,129 @@
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
+ = Copyright
125
+
126
+ Author:: Sadayuki Furuhashi <frsyuki@gmail.com>
127
+ Copyright:: Copyright (c) 2008-2013 Sadayuki Furuhashi
128
+ License:: Apache License, Version 2.0
129
+
data/Rakefile ADDED
@@ -0,0 +1,114 @@
1
+
2
+ require 'bundler'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ require 'fileutils'
6
+
7
+ require 'rspec/core'
8
+ require 'rspec/core/rake_task'
9
+ require 'yard'
10
+
11
+ task :spec => :compile
12
+
13
+ desc 'Run RSpec code examples and measure coverage'
14
+ task :coverage do |t|
15
+ ENV['SIMPLE_COV'] = '1'
16
+ Rake::Task["spec"].invoke
17
+ end
18
+
19
+ desc 'Generate YARD document'
20
+ YARD::Rake::YardocTask.new(:doc) do |t|
21
+ t.files = ['lib/msgpack/version.rb','doclib/**/*.rb']
22
+ t.options = []
23
+ t.options << '--debug' << '--verbose' if $trace
24
+ end
25
+
26
+ spec = eval File.read("msgpack.gemspec")
27
+
28
+ if RUBY_PLATFORM =~ /java/
29
+ require 'rake/javaextensiontask'
30
+
31
+ Rake::JavaExtensionTask.new('msgpack', spec) do |ext|
32
+ ext.ext_dir = 'ext/java'
33
+ jruby_home = RbConfig::CONFIG['prefix']
34
+ jars = ["#{jruby_home}/lib/jruby.jar"]
35
+ ext.classpath = jars.map { |x| File.expand_path(x) }.join(':')
36
+ ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
37
+ ext.source_version = '1.6'
38
+ ext.target_version = '1.6'
39
+ end
40
+
41
+ RSpec::Core::RakeTask.new(:spec) do |t|
42
+ t.rspec_opts = ["-c", "-f progress"]
43
+ t.rspec_opts << "-Ilib"
44
+ t.pattern = 'spec/{,jruby/}*_spec.rb'
45
+ t.verbose = true
46
+ end
47
+
48
+ else
49
+ require 'rake/extensiontask'
50
+
51
+ Rake::ExtensionTask.new('msgpack', spec) do |ext|
52
+ ext.ext_dir = 'ext/msgpack'
53
+ ext.cross_compile = true
54
+ ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
55
+ ext.cross_platform = ['x86-mswin32', 'x64-mingw32']
56
+ end
57
+
58
+ RSpec::Core::RakeTask.new(:spec) do |t|
59
+ t.rspec_opts = ["-c", "-f progress"]
60
+ t.rspec_opts << "-Ilib"
61
+ t.pattern = 'spec/{,cruby/}*_spec.rb'
62
+ t.verbose = true
63
+ end
64
+ end
65
+
66
+ CLEAN.include('lib/msgpack/msgpack.*')
67
+
68
+ task :default => [:spec, :build, :doc]
69
+
70
+
71
+ ###
72
+ ## Cross compile memo
73
+ ##
74
+ ## Ubuntu Ubuntu 10.04.1 LTS
75
+ ##
76
+ #
77
+ ### install mingw32 cross compiler with w64 support
78
+ # sudo apt-get install gcc-mingw32
79
+ # sudo apt-get install mingw-w64
80
+ #
81
+ ### install rbenv
82
+ # git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
83
+ # echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
84
+ # echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
85
+ # exec $SHELL -l
86
+ #
87
+ ### install cross-compiled ruby 2.0.0
88
+ # rbenv install 2.0.0-p247
89
+ # rbenv shell 2.0.0-p247
90
+ # gem update --system
91
+ # gem install rake-compiler
92
+ # rake-compiler cross-ruby VERSION=2.0.0-p247
93
+ #
94
+ ### install cross-compiled ruby 1.9.3
95
+ # rbenv install 1.9.3-p327
96
+ # rbenv shell 1.9.3-p327
97
+ # gem update --system
98
+ # gem install rake-compiler
99
+ # rake-compiler cross-ruby VERSION=1.9.3-p327
100
+ #
101
+ ### install cross-compiled ruby 1.8.7
102
+ # rbenv install 1.8.7-p374
103
+ # rbenv shell 1.8.7-p374
104
+ # gem update --system
105
+ # gem install rake-compiler
106
+ # rake-compiler cross-ruby VERSION=1.8.7-p374
107
+ #
108
+ ### build gem
109
+ # rbenv shell 1.8.7-p374
110
+ # gem install bundler
111
+ # bundle
112
+ # rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0
113
+ #
114
+
data/bench/pack.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'viiite'
2
+ require 'msgpack'
3
+
4
+ data = { 'hello' => 'world', 'nested' => ['structure', {value: 42}] }
5
+ data_sym = { hello: 'world', nested: ['structure', {value: 42}] }
6
+
7
+ data = MessagePack.pack(:hello => 'world', :nested => ['structure', {:value => 42}])
8
+
9
+ Viiite.bench do |b|
10
+ b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
11
+ b.report(:strings) do
12
+ runs.times do
13
+ MessagePack.pack(data)
14
+ end
15
+ end
16
+
17
+ b.report(:symbols) do
18
+ runs.times do
19
+ MessagePack.pack(data_sym)
20
+ end
21
+ end
22
+ end
23
+ end
data/bench/pack_log.rb ADDED
@@ -0,0 +1,33 @@
1
+ require 'viiite'
2
+ require 'msgpack'
3
+
4
+ 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)"' }
5
+ data_structure = {
6
+ 'remote_host' => '127.0.0.1',
7
+ 'remote_user' => '-',
8
+ 'date' => '10/Oct/2000:13:55:36 -0700',
9
+ 'request' => 'GET /apache_pb.gif HTTP/1.0',
10
+ 'method' => 'GET',
11
+ 'path' => '/apache_pb.gif',
12
+ 'protocol' => 'HTTP/1.0',
13
+ 'status' => 200,
14
+ 'bytes' => 2326,
15
+ 'referer' => 'http://www.example.com/start.html',
16
+ 'agent' => 'Mozilla/4.08 [en] (Win98; I ;Nav)',
17
+ }
18
+
19
+ Viiite.bench do |b|
20
+ b.range_over([10_000, 100_000, 1000_000], :runs) do |runs|
21
+ b.report(:plain) do
22
+ runs.times do
23
+ MessagePack.pack(data_plain)
24
+ end
25
+ end
26
+
27
+ b.report(:structure) do
28
+ runs.times do
29
+ MessagePack.pack(data_structure)
30
+ end
31
+ end
32
+ end
33
+ end