msgpack-ably 0.5.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/.travis.yml +26 -0
  4. data/ChangeLog +101 -0
  5. data/README.rdoc +129 -0
  6. data/Rakefile +110 -0
  7. data/doclib/msgpack.rb +77 -0
  8. data/doclib/msgpack/buffer.rb +193 -0
  9. data/doclib/msgpack/core_ext.rb +101 -0
  10. data/doclib/msgpack/error.rb +14 -0
  11. data/doclib/msgpack/packer.rb +134 -0
  12. data/doclib/msgpack/unpacker.rb +146 -0
  13. data/ext/msgpack/buffer.c +678 -0
  14. data/ext/msgpack/buffer.h +441 -0
  15. data/ext/msgpack/buffer_class.c +507 -0
  16. data/ext/msgpack/buffer_class.h +32 -0
  17. data/ext/msgpack/compat.h +113 -0
  18. data/ext/msgpack/core_ext.c +129 -0
  19. data/ext/msgpack/core_ext.h +26 -0
  20. data/ext/msgpack/extconf.rb +28 -0
  21. data/ext/msgpack/packer.c +168 -0
  22. data/ext/msgpack/packer.h +429 -0
  23. data/ext/msgpack/packer_class.c +302 -0
  24. data/ext/msgpack/packer_class.h +30 -0
  25. data/ext/msgpack/rbinit.c +33 -0
  26. data/ext/msgpack/rmem.c +94 -0
  27. data/ext/msgpack/rmem.h +109 -0
  28. data/ext/msgpack/sysdep.h +115 -0
  29. data/ext/msgpack/sysdep_endian.h +50 -0
  30. data/ext/msgpack/sysdep_types.h +46 -0
  31. data/ext/msgpack/unpacker.c +781 -0
  32. data/ext/msgpack/unpacker.h +122 -0
  33. data/ext/msgpack/unpacker_class.c +405 -0
  34. data/ext/msgpack/unpacker_class.h +32 -0
  35. data/lib/msgpack.rb +6 -0
  36. data/lib/msgpack/version.rb +3 -0
  37. data/msgpack.gemspec +26 -0
  38. data/msgpack.org.md +49 -0
  39. data/spec/cases.json +1 -0
  40. data/spec/cases.msg +0 -0
  41. data/spec/cases_compact.msg +0 -0
  42. data/spec/cases_spec.rb +39 -0
  43. data/spec/cruby/buffer_io_spec.rb +256 -0
  44. data/spec/cruby/buffer_packer.rb +29 -0
  45. data/spec/cruby/buffer_spec.rb +572 -0
  46. data/spec/cruby/buffer_unpacker.rb +19 -0
  47. data/spec/format_spec.rb +256 -0
  48. data/spec/packer_spec.rb +120 -0
  49. data/spec/random_compat.rb +24 -0
  50. data/spec/spec_helper.rb +21 -0
  51. data/spec/unpacker_spec.rb +305 -0
  52. metadata +195 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25779f5d6fba3f3521e69aaead8c8a23196d844c
4
+ data.tar.gz: 1c94181cb24c426cffb3e194a54858478777dcf2
5
+ SHA512:
6
+ metadata.gz: da81668f188e1a707e3e91b172553f69e066a1a0fb862523528644d523d3c3a7fe12e2c1917d90265af19f01b72a969bbec18537fff3fac26ef9f5055f647b64
7
+ data.tar.gz: 75b807f5eda25952e1c1383522164eff4c173c6c38ec7e56c0e1a0e3a0295763051420067277c44f87b95c51465ce177241833e07766acc41c3feb72639085da
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.o
2
+ *.so
3
+ *.bundle
4
+ *.gem
5
+ *.class
6
+ doc
7
+ .yardoc
8
+ .bundle
9
+ Gemfile*
10
+ pkg
11
+ test/debug.log
12
+ *~
13
+ /rdoc
14
+ tmp
15
+ .classpath
16
+ .project
17
+ .settings
18
+ /nbproject/private/
19
+ ext/java/build
20
+ ext/java/msgpack.jar
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 ADDED
@@ -0,0 +1,101 @@
1
+
2
+ 2014-10-05 version 0.5.9:
3
+
4
+ * Fixed Unpacker#read_map_header and #read_array_header
5
+ * Added support for Symbol GC added since MRI 2.2.0
6
+
7
+
8
+ 2013-12-14 version 0.5.8:
9
+
10
+ * Fixed compatibility with Ruby 2.1.0
11
+ * Added :symbolize_keys option to MessagePack.load and Unpacker#initialize
12
+
13
+
14
+ 2013-10-12 version 0.5.7:
15
+
16
+ * Added deserialization support for the new MessagePack spec
17
+
18
+
19
+ 2013-09-23 version 0.5.6:
20
+
21
+ * Fixed "can't modify frozen String" exception in Unpacker with ruby 2.1.0-dev
22
+ * Getting work with Ruby v2.0 on Windows (Thank you @thegreendroid)
23
+ * Fixed EOFError handling in Unpacker
24
+
25
+
26
+ 2013-05-12 version 0.5.5:
27
+
28
+ * Fixed SEGV problem in to_msgpack
29
+ * Fixed a possible race condition in MessagePack.load when it loads data from IO
30
+ * mingw32 package includes binary for ruby-2.0.0
31
+
32
+
33
+ 2013-03-15 version 0.5.4:
34
+
35
+ * Added missing MessagePack::Unpacker#reset method
36
+
37
+
38
+ 2013-02-14 version 0.5.3:
39
+
40
+ * Fixed segfault problem on Buffer#clear (reuse rmem internal fragment optimization)
41
+ * Fixed segfault problem on Buffer (rmem free code)
42
+
43
+
44
+ 2013-02-07 version 0.5.2:
45
+
46
+ * Fixed invalid pack/unpack on 32bit architecture such as Win32
47
+ * Disable rmem on Rubinius because rmem is not thread safe
48
+
49
+
50
+ 2012-12-23 version 0.5.1:
51
+
52
+ * Fixed compile error with Rubinius 2.0.0-dev
53
+ * Optimized msgpack_packer_write_hash for Rubinius
54
+
55
+
56
+ 2012-12-20 version 0.5.0:
57
+
58
+ * Rewrote all code and improved performance significantly
59
+ * Added MessagePack::Buffer class
60
+ * Added MessagePack::Packer class
61
+ * Added Packer#buffer and Unpacker#buffer accessors which return MessagePack::Buffer
62
+ * Added Packer#write_{array,map}_header and Unpacker#read_{array,map}_header methods
63
+ * Added Packer#write_nil and Unpacker#skip_nil methods
64
+ * Added Packer#write -> #pack alias and Unpacker#read method
65
+ * Added exception classes - UnpackError, MalformedFormatError, StackError and TypeError
66
+ * Added MessagePack.dup -> .pack and MessagePack.load -> .unpack aliases
67
+ * Added Packer#empty?, #size and #clear methods
68
+ * Added Packer#write_to(io) method to flush serialized data to IO efficiently
69
+ * Added Unpacker#skip method to skip an object efficiently
70
+ * Removed obsoleted Unpacker#fill, #execute, #execute_limit, #finished? and #data methods
71
+ * Removed obsoleted Unapcker#stream and #stream= methods. Use unpacker.buffer.io instead
72
+
73
+
74
+ 2012-05-05 version 0.4.7:
75
+
76
+ * Fixed serialization of double values on ARM OABI architectures
77
+ * Fixed byteorder problem on big-endian platforms
78
+ * Don't use MRI internals in the Ruby extension for Rubinius
79
+ * Detect whether st.h is present and don't use RUBY_VM as the condition for
80
+ Rubinius
81
+
82
+ 2011-08-08 version 0.4.6:
83
+
84
+ * Fixed compile error problem on Mac OS X Lion
85
+
86
+ 2011-05-09 version 0.4.5:
87
+
88
+ * Improves compatibility with JRuby
89
+
90
+ 2010-11-28 version 0.4.4:
91
+
92
+ * Adds Unpacker#feed_each method
93
+ * Improves compatibility with Rubinius
94
+ * Improves compatibility with ruby-1.8.5
95
+ * Encodings of String instances to UTF-8 on Ruby 1.9
96
+
97
+ 2010-06-29 version 0.4.3:
98
+
99
+ * Adds MessagePack::VERSION constant
100
+ * Fixes SEGV problem caused by GC bug at MessagePack_Unpacker_mark
101
+
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,110 @@
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
+ 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
42
+ end
43
+
44
+ else
45
+ require 'rake/extensiontask'
46
+
47
+ Rake::ExtensionTask.new('msgpack', spec) do |ext|
48
+ ext.ext_dir = 'ext/msgpack'
49
+ ext.cross_compile = true
50
+ ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
51
+ #ext.cross_platform = 'i386-mswin32'
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
60
+ end
61
+
62
+ CLEAN.include('lib/msgpack/msgpack.*')
63
+
64
+ task :default => [:spec, :build, :doc]
65
+
66
+
67
+ ###
68
+ ## Cross compile memo
69
+ ##
70
+ ## Ubuntu Ubuntu 10.04.1 LTS
71
+ ##
72
+ #
73
+ ### install mingw32 cross compiler with w64 support
74
+ # sudo apt-get install gcc-mingw32
75
+ # sudo apt-get install mingw-w64
76
+ #
77
+ ### install rbenv
78
+ # git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
79
+ # echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
80
+ # echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
81
+ # exec $SHELL -l
82
+ #
83
+ ### install cross-compiled ruby 2.0.0
84
+ # rbenv install 2.0.0-p247
85
+ # rbenv shell 2.0.0-p247
86
+ # gem update --system
87
+ # gem install rake-compiler
88
+ # rake-compiler cross-ruby VERSION=2.0.0-p247
89
+ #
90
+ ### install cross-compiled ruby 1.9.3
91
+ # rbenv install 1.9.3-p327
92
+ # rbenv shell 1.9.3-p327
93
+ # gem update --system
94
+ # gem install rake-compiler
95
+ # rake-compiler cross-ruby VERSION=1.9.3-p327
96
+ #
97
+ ### install cross-compiled ruby 1.8.7
98
+ # rbenv install 1.8.7-p374
99
+ # rbenv shell 1.8.7-p374
100
+ # gem update --system
101
+ # gem install rake-compiler
102
+ # rake-compiler cross-ruby VERSION=1.8.7-p374
103
+ #
104
+ ### build gem
105
+ # rbenv shell 1.8.7-p374
106
+ # gem install bundler
107
+ # bundle
108
+ # rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0
109
+ #
110
+
data/doclib/msgpack.rb ADDED
@@ -0,0 +1,77 @@
1
+
2
+ module MessagePack
3
+ #
4
+ # Serializes an object into an IO or String.
5
+ #
6
+ # @overload dump(obj, options={})
7
+ # @param obj [Object] object to be serialized
8
+ # @param options [Hash]
9
+ # @return [String] serialized data
10
+ #
11
+ # @overload dump(obj, io, options={})
12
+ # @param obj [Object] object to be serialized
13
+ # @param io [IO]
14
+ # @param options [Hash]
15
+ # @return [IO]
16
+ #
17
+ # See Packer#initialize for supported options.
18
+ #
19
+ def self.dump(obj)
20
+ end
21
+
22
+ #
23
+ # Serializes an object into an IO or String. Alias of dump.
24
+ #
25
+ # @overload pack(obj, options={})
26
+ # @param obj [Object] object to be serialized
27
+ # @param options [Hash]
28
+ # @return [String] serialized data
29
+ #
30
+ # @overload pack(obj, io, options={})
31
+ # @param obj [Object] object to be serialized
32
+ # @param io [IO]
33
+ # @param options [Hash]
34
+ # @return [IO]
35
+ #
36
+ # See Packer#initialize for supported options.
37
+ #
38
+ def self.pack(obj)
39
+ end
40
+
41
+ #
42
+ # Deserializes an object from an IO or String.
43
+ #
44
+ # @overload load(string, options={})
45
+ # @param string [String] data to deserialize
46
+ # @param options [Hash]
47
+ #
48
+ # @overload load(io, options={})
49
+ # @param io [IO]
50
+ # @param options [Hash]
51
+ #
52
+ # @return [Object] deserialized object
53
+ #
54
+ # See Unpacker#initialize for supported options.
55
+ #
56
+ def self.load(src, options={})
57
+ end
58
+
59
+ #
60
+ # Deserializes an object from an IO or String. Alias of load.
61
+ #
62
+ # @overload unpack(string, options={})
63
+ # @param string [String] data to deserialize
64
+ # @param options [Hash]
65
+ #
66
+ # @overload unpack(io, options={})
67
+ # @param io [IO]
68
+ # @param options [Hash]
69
+ #
70
+ # @return [Object] deserialized object
71
+ #
72
+ # See Unpacker#initialize for supported options.
73
+ #
74
+ def self.unpack(src, options={})
75
+ end
76
+ end
77
+