msgpack 0.6.0pre1-x86-mingw32 → 0.6.2-x86-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.
- checksums.yaml +4 -4
 - data/ChangeLog +22 -0
 - data/Dockerfile +42 -17
 - data/README.rdoc +12 -0
 - data/Rakefile +1 -48
 - data/doclib/msgpack/packer.rb +5 -1
 - data/ext/java/org/msgpack/jruby/Buffer.java +0 -4
 - data/ext/java/org/msgpack/jruby/Encoder.java +5 -3
 - data/ext/java/org/msgpack/jruby/Packer.java +6 -1
 - data/ext/msgpack/compat.h +1 -0
 - data/ext/msgpack/extconf.rb +3 -1
 - data/ext/msgpack/packer.h +18 -13
 - data/ext/msgpack/packer_class.c +19 -4
 - data/ext/msgpack/packer_class.h +2 -0
 - data/lib/msgpack/version.rb +1 -1
 - data/spec/cruby/packer_spec.rb +18 -0
 - data/spec/format_spec.rb +19 -0
 - data/spec/jruby/msgpack_spec.rb +21 -1
 - metadata +6 -6
 - data/cross-build.sh +0 -9
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5fd095586970361584978a13c2269d853d6a4b86
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 844b93498126a50c8e6cb83d0a9558723f59b42d
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 509af082162d7dd14f84dcf89ddc81753d55a09fbc3880ef655c4165c8a0fcd5f8f587207ce17fad3ac1d50f2dc45bb09f155375515555e74c4062c3819e6d14
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: fefba2952da3f9d658f0f665f89f65acacea62cfcb95873e5e9086e4c30286a9855c2eabaa3e5f776e9096812c05c30b53ce2300a092647c00224060bd30404c
         
     | 
    
        data/ChangeLog
    CHANGED
    
    | 
         @@ -1,3 +1,25 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            2015-07-22 version 0.6.2:
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Fix release workflow: Ruby 2.1 and 2.2 are supported for Windows (2.0 is omitted)
         
     | 
| 
      
 4 
     | 
    
         
            +
            * Fix to encode symbols along its encoding
         
     | 
| 
      
 5 
     | 
    
         
            +
            * Fix segmentation fault in minor case
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            2015-07-01 version 0.6.1:
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            * Added :compatibility_mode option to Packer#initialize. Default is false. If it
         
     | 
| 
      
 10 
     | 
    
         
            +
              is set to true, str8 format and bin format family will not be used.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            2015-05-26 version 0.6.0:
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            * Added support for Binary types
         
     | 
| 
      
 15 
     | 
    
         
            +
            * Fixed to encode/decode between Binary types and ASCII-8BIT Ruby String objects
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            2015-05-21 version 0.5.12:
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            * Added support for JRuby 9K.
         
     | 
| 
      
 20 
     | 
    
         
            +
            * Added a benchmarking suite.
         
     | 
| 
      
 21 
     | 
    
         
            +
            * Fixed a bug in the handling of options given to MessagePack.unpack in JRuby.
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
       1 
23 
     | 
    
         | 
| 
       2 
24 
     | 
    
         
             
            2015-02-04 version 0.5.11:
         
     | 
| 
       3 
25 
     | 
    
         | 
    
        data/Dockerfile
    CHANGED
    
    | 
         @@ -2,23 +2,48 @@ FROM ubuntu:14.04 
     | 
|
| 
       2 
2 
     | 
    
         
             
            MAINTAINER TAGOMORI Satoshi <tagomoris@gmail.com>
         
     | 
| 
       3 
3 
     | 
    
         
             
            LABEL Description="Host image to cross-compile msgpack.gem for mingw32" Vendor="MessagePack Organization" Version="1.0"
         
     | 
| 
       4 
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 
     | 
    
         
            +
             
     | 
| 
       5 
27 
     | 
    
         
             
            USER ubuntu
         
     | 
| 
       6 
28 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
            RUN git clone https://github.com/ 
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            RUN  
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
            RUN  
     | 
| 
       16 
     | 
    
         
            -
            RUN  
     | 
| 
       17 
     | 
    
         
            -
            RUN  
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            RUN  
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 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.1.5 /home/ubuntu/local/ruby-2.1
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
            ENV PATH /home/ubuntu/local/ruby-2.1/bin:$PATH
         
     | 
| 
      
 37 
     | 
    
         
            +
            RUN gem install rake-compiler
         
     | 
| 
      
 38 
     | 
    
         
            +
            RUN rake-compiler cross-ruby VERSION=2.1.5 HOST=i686-w64-mingw32 EXTS=--without-extensions
         
     | 
| 
      
 39 
     | 
    
         
            +
            RUN rake-compiler cross-ruby VERSION=2.1.5 HOST=x86_64-w64-mingw32 EXTS=--without-extensions
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            RUN /home/ubuntu/xbuild/ruby-install 2.2.2 /home/ubuntu/local/ruby-2.2
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            ENV PATH /home/ubuntu/local/ruby-2.2/bin:$PATH
         
     | 
| 
      
 44 
     | 
    
         
            +
            RUN gem install rake-compiler
         
     | 
| 
      
 45 
     | 
    
         
            +
            RUN rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 EXTS=--without-extensions
         
     | 
| 
      
 46 
     | 
    
         
            +
            RUN rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 EXTS=--without-extensions
         
     | 
| 
       22 
47 
     | 
    
         | 
| 
       23 
48 
     | 
    
         
             
            WORKDIR /home/ubuntu/msgpack-ruby
         
     | 
| 
       24 
49 
     | 
    
         | 
| 
         @@ -26,5 +51,5 @@ ENV MSGPACK_REPO https://github.com/msgpack/msgpack-ruby.git 
     | 
|
| 
       26 
51 
     | 
    
         
             
            ENV BUILD_BRANCH master
         
     | 
| 
       27 
52 
     | 
    
         
             
            ENV BUILD_POSITION HEAD
         
     | 
| 
       28 
53 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 54 
     | 
    
         
            +
            ### docker run -v `pwd`/pkg:/home/ubuntu/msgpack-ruby/pkg IMAGENAME
         
     | 
| 
      
 55 
     | 
    
         
            +
            CMD ["bash", "-c", "git remote add dockerbuild $MSGPACK_REPO && git fetch dockerbuild && git checkout $BUILD_BRANCH && git pull dockerbuild $BUILD_BRANCH && git reset --hard $BUILD_POSITION && bundle && rake clean && rake cross native gem RUBY_CC_VERSION=2.1.5:2.2.2"]
         
     | 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -121,6 +121,18 @@ Then, you can run the tasks as follows: 
     | 
|
| 
       121 
121 
     | 
    
         | 
| 
       122 
122 
     | 
    
         
             
                bundle exec rake doc
         
     | 
| 
       123 
123 
     | 
    
         | 
| 
      
 124 
     | 
    
         
            +
            == How to build -mingw32 rubygems
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
            MessagePack mingw32/64 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-crosscompile
         
     | 
| 
      
 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-crosscompile/
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
       124 
136 
     | 
    
         
             
            = Copyright
         
     | 
| 
       125 
137 
     | 
    
         | 
| 
       126 
138 
     | 
    
         
             
            Author::    Sadayuki Furuhashi <frsyuki@gmail.com>
         
     | 
    
        data/Rakefile
    CHANGED
    
    | 
         @@ -52,8 +52,7 @@ else 
     | 
|
| 
       52 
52 
     | 
    
         
             
                ext.ext_dir = 'ext/msgpack'
         
     | 
| 
       53 
53 
     | 
    
         
             
                ext.cross_compile = true
         
     | 
| 
       54 
54 
     | 
    
         
             
                ext.lib_dir = File.join(*['lib', 'msgpack', ENV['FAT_DIR']].compact)
         
     | 
| 
       55 
     | 
    
         
            -
                ext. 
     | 
| 
       56 
     | 
    
         
            -
                #ext.cross_platform = 'i386-mswin32'
         
     | 
| 
      
 55 
     | 
    
         
            +
                ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
         
     | 
| 
       57 
56 
     | 
    
         
             
              end
         
     | 
| 
       58 
57 
     | 
    
         | 
| 
       59 
58 
     | 
    
         
             
              RSpec::Core::RakeTask.new(:spec) do |t|
         
     | 
| 
         @@ -67,49 +66,3 @@ end 
     | 
|
| 
       67 
66 
     | 
    
         
             
            CLEAN.include('lib/msgpack/msgpack.*')
         
     | 
| 
       68 
67 
     | 
    
         | 
| 
       69 
68 
     | 
    
         
             
            task :default => [:spec, :build, :doc]
         
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
            ###
         
     | 
| 
       73 
     | 
    
         
            -
            ## Cross compile memo
         
     | 
| 
       74 
     | 
    
         
            -
            ##
         
     | 
| 
       75 
     | 
    
         
            -
            ## Ubuntu Ubuntu 10.04.1 LTS
         
     | 
| 
       76 
     | 
    
         
            -
            ##
         
     | 
| 
       77 
     | 
    
         
            -
            #
         
     | 
| 
       78 
     | 
    
         
            -
            ### install mingw32 cross compiler with w64 support
         
     | 
| 
       79 
     | 
    
         
            -
            # sudo apt-get install gcc-mingw32
         
     | 
| 
       80 
     | 
    
         
            -
            # sudo apt-get install mingw-w64
         
     | 
| 
       81 
     | 
    
         
            -
            #
         
     | 
| 
       82 
     | 
    
         
            -
            ### install rbenv
         
     | 
| 
       83 
     | 
    
         
            -
            # git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
         
     | 
| 
       84 
     | 
    
         
            -
            # echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
         
     | 
| 
       85 
     | 
    
         
            -
            # echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
         
     | 
| 
       86 
     | 
    
         
            -
            # exec $SHELL -l
         
     | 
| 
       87 
     | 
    
         
            -
            #
         
     | 
| 
       88 
     | 
    
         
            -
            ### install cross-compiled ruby 2.0.0
         
     | 
| 
       89 
     | 
    
         
            -
            # rbenv install 2.0.0-p247
         
     | 
| 
       90 
     | 
    
         
            -
            # rbenv shell 2.0.0-p247
         
     | 
| 
       91 
     | 
    
         
            -
            # gem update --system
         
     | 
| 
       92 
     | 
    
         
            -
            # gem install rake-compiler
         
     | 
| 
       93 
     | 
    
         
            -
            # rake-compiler cross-ruby VERSION=2.0.0-p247
         
     | 
| 
       94 
     | 
    
         
            -
            #
         
     | 
| 
       95 
     | 
    
         
            -
            ### install cross-compiled ruby 1.9.3
         
     | 
| 
       96 
     | 
    
         
            -
            # rbenv install 1.9.3-p327
         
     | 
| 
       97 
     | 
    
         
            -
            # rbenv shell 1.9.3-p327
         
     | 
| 
       98 
     | 
    
         
            -
            # gem update --system
         
     | 
| 
       99 
     | 
    
         
            -
            # gem install rake-compiler
         
     | 
| 
       100 
     | 
    
         
            -
            # rake-compiler cross-ruby VERSION=1.9.3-p327
         
     | 
| 
       101 
     | 
    
         
            -
            #
         
     | 
| 
       102 
     | 
    
         
            -
            ### install cross-compiled ruby 1.8.7
         
     | 
| 
       103 
     | 
    
         
            -
            # rbenv install 1.8.7-p374
         
     | 
| 
       104 
     | 
    
         
            -
            # rbenv shell 1.8.7-p374
         
     | 
| 
       105 
     | 
    
         
            -
            # gem update --system
         
     | 
| 
       106 
     | 
    
         
            -
            # gem install rake-compiler
         
     | 
| 
       107 
     | 
    
         
            -
            # rake-compiler cross-ruby VERSION=1.8.7-p374
         
     | 
| 
       108 
     | 
    
         
            -
            #
         
     | 
| 
       109 
     | 
    
         
            -
            ### build gem
         
     | 
| 
       110 
     | 
    
         
            -
            # rbenv shell 1.8.7-p374
         
     | 
| 
       111 
     | 
    
         
            -
            # gem install bundler
         
     | 
| 
       112 
     | 
    
         
            -
            # bundle
         
     | 
| 
       113 
     | 
    
         
            -
            # rake cross native gem RUBY_CC_VERSION=1.8.7:1.9.3:2.0.0
         
     | 
| 
       114 
     | 
    
         
            -
            #
         
     | 
| 
       115 
     | 
    
         
            -
             
     | 
    
        data/doclib/msgpack/packer.rb
    CHANGED
    
    | 
         @@ -17,7 +17,11 @@ module MessagePack 
     | 
|
| 
       17 
17 
     | 
    
         
             
                #   This packer writes serialzied objects into the IO when the internal buffer is filled.
         
     | 
| 
       18 
18 
     | 
    
         
             
                #   _io_ must respond to write(string) or append(string) method.
         
     | 
| 
       19 
19 
     | 
    
         
             
                #
         
     | 
| 
       20 
     | 
    
         
            -
                #  
     | 
| 
      
 20 
     | 
    
         
            +
                # Supported options:
         
     | 
| 
      
 21 
     | 
    
         
            +
                #
         
     | 
| 
      
 22 
     | 
    
         
            +
                # * *:compatibility_mode* serialize in older versions way, without str8 and bin types
         
     | 
| 
      
 23 
     | 
    
         
            +
                #
         
     | 
| 
      
 24 
     | 
    
         
            +
                # See also Buffer#initialize for other options.
         
     | 
| 
       21 
25 
     | 
    
         
             
                #
         
     | 
| 
       22 
26 
     | 
    
         
             
                def initialize(*args)
         
     | 
| 
       23 
27 
     | 
    
         
             
                end
         
     | 
| 
         @@ -21,7 +21,6 @@ import org.jcodings.Encoding; 
     | 
|
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
            @JRubyClass(name="MessagePack::Buffer")
         
     | 
| 
       23 
23 
     | 
    
         
             
            public class Buffer extends RubyObject {
         
     | 
| 
       24 
     | 
    
         
            -
              private RubyHash options;
         
     | 
| 
       25 
24 
     | 
    
         
             
              private IRubyObject io;
         
     | 
| 
       26 
25 
     | 
    
         
             
              private ByteBuffer buffer;
         
     | 
| 
       27 
26 
     | 
    
         
             
              private boolean writeMode;
         
     | 
| 
         @@ -46,9 +45,6 @@ public class Buffer extends RubyObject { 
     | 
|
| 
       46 
45 
     | 
    
         
             
                  if (args[0].respondsTo("read") && args[0].respondsTo("write")) {
         
     | 
| 
       47 
46 
     | 
    
         
             
                    this.io = args[0];
         
     | 
| 
       48 
47 
     | 
    
         
             
                  }
         
     | 
| 
       49 
     | 
    
         
            -
                  if (args[args.length - 1] instanceof RubyHash) {
         
     | 
| 
       50 
     | 
    
         
            -
                    this.options = (RubyHash) args[args.length - 1];
         
     | 
| 
       51 
     | 
    
         
            -
                  }
         
     | 
| 
       52 
48 
     | 
    
         
             
                }
         
     | 
| 
       53 
49 
     | 
    
         
             
                this.buffer = ByteBuffer.allocate(CACHE_LINE_SIZE - ARRAY_HEADER_SIZE);
         
     | 
| 
       54 
50 
     | 
    
         
             
                this.writeMode = true;
         
     | 
| 
         @@ -34,14 +34,16 @@ public class Encoder { 
     | 
|
| 
       34 
34 
     | 
    
         
             
              private final Ruby runtime;
         
     | 
| 
       35 
35 
     | 
    
         
             
              private final Encoding binaryEncoding;
         
     | 
| 
       36 
36 
     | 
    
         
             
              private final Encoding utf8Encoding;
         
     | 
| 
      
 37 
     | 
    
         
            +
              private final boolean compatibilityMode;
         
     | 
| 
       37 
38 
     | 
    
         | 
| 
       38 
39 
     | 
    
         
             
              private ByteBuffer buffer;
         
     | 
| 
       39 
40 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
              public Encoder(Ruby runtime) {
         
     | 
| 
      
 41 
     | 
    
         
            +
              public Encoder(Ruby runtime, boolean compatibilityMode) {
         
     | 
| 
       41 
42 
     | 
    
         
             
                this.runtime = runtime;
         
     | 
| 
       42 
43 
     | 
    
         
             
                this.buffer = ByteBuffer.allocate(CACHE_LINE_SIZE - ARRAY_HEADER_SIZE);
         
     | 
| 
       43 
44 
     | 
    
         
             
                this.binaryEncoding = runtime.getEncodingService().getAscii8bitEncoding();
         
     | 
| 
       44 
45 
     | 
    
         
             
                this.utf8Encoding = UTF8Encoding.INSTANCE;
         
     | 
| 
      
 46 
     | 
    
         
            +
                this.compatibilityMode = compatibilityMode;
         
     | 
| 
       45 
47 
     | 
    
         
             
              }
         
     | 
| 
       46 
48 
     | 
    
         | 
| 
       47 
49 
     | 
    
         
             
              private void ensureRemainingCapacity(int c) {
         
     | 
| 
         @@ -190,7 +192,7 @@ public class Encoder { 
     | 
|
| 
       190 
192 
     | 
    
         | 
| 
       191 
193 
     | 
    
         
             
              private void appendString(RubyString object) {
         
     | 
| 
       192 
194 
     | 
    
         
             
                Encoding encoding = object.getEncoding();
         
     | 
| 
       193 
     | 
    
         
            -
                boolean binary = encoding == binaryEncoding;
         
     | 
| 
      
 195 
     | 
    
         
            +
                boolean binary = !compatibilityMode && encoding == binaryEncoding;
         
     | 
| 
       194 
196 
     | 
    
         
             
                if (encoding != utf8Encoding && encoding != binaryEncoding) {
         
     | 
| 
       195 
197 
     | 
    
         
             
                  object = (RubyString) ((RubyString) object).encode(runtime.getCurrentContext(), runtime.getEncodingService().getEncoding(utf8Encoding));
         
     | 
| 
       196 
198 
     | 
    
         
             
                }
         
     | 
| 
         @@ -199,7 +201,7 @@ public class Encoder { 
     | 
|
| 
       199 
201 
     | 
    
         
             
                if (length < 32 && !binary) {
         
     | 
| 
       200 
202 
     | 
    
         
             
                  ensureRemainingCapacity(1 + length);
         
     | 
| 
       201 
203 
     | 
    
         
             
                  buffer.put((byte) (length | FIXSTR));
         
     | 
| 
       202 
     | 
    
         
            -
                } else if (length <= 0xff) {
         
     | 
| 
      
 204 
     | 
    
         
            +
                } else if (length <= 0xff && !compatibilityMode) {
         
     | 
| 
       203 
205 
     | 
    
         
             
                  ensureRemainingCapacity(2 + length);
         
     | 
| 
       204 
206 
     | 
    
         
             
                  buffer.put(binary ? BIN8 : STR8);
         
     | 
| 
       205 
207 
     | 
    
         
             
                  buffer.put((byte) length);
         
     | 
| 
         @@ -32,7 +32,12 @@ public class Packer extends RubyObject { 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
              @JRubyMethod(name = "initialize", optional = 2)
         
     | 
| 
       34 
34 
     | 
    
         
             
              public IRubyObject initialize(ThreadContext ctx, IRubyObject[] args) {
         
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
      
 35 
     | 
    
         
            +
                boolean compatibilityMode = false;
         
     | 
| 
      
 36 
     | 
    
         
            +
                if (args.length > 0 && args[args.length - 1] instanceof RubyHash) {
         
     | 
| 
      
 37 
     | 
    
         
            +
                  RubyHash options = (RubyHash) args[args.length - 1];
         
     | 
| 
      
 38 
     | 
    
         
            +
                  compatibilityMode = options.fastARef(ctx.getRuntime().newSymbol("compatibility_mode")).isTrue();
         
     | 
| 
      
 39 
     | 
    
         
            +
                }
         
     | 
| 
      
 40 
     | 
    
         
            +
                this.encoder = new Encoder(ctx.getRuntime(), compatibilityMode);
         
     | 
| 
       36 
41 
     | 
    
         
             
                this.buffer = new Buffer(ctx.getRuntime(), ctx.getRuntime().getModule("MessagePack").getClass("Buffer"));
         
     | 
| 
       37 
42 
     | 
    
         
             
                this.buffer.initialize(ctx, args);
         
     | 
| 
       38 
43 
     | 
    
         
             
                return this;
         
     | 
    
        data/ext/msgpack/compat.h
    CHANGED
    
    
    
        data/ext/msgpack/extconf.rb
    CHANGED
    
    | 
         @@ -7,7 +7,9 @@ have_func("rb_intern_str", ["ruby.h"]) 
     | 
|
| 
       7 
7 
     | 
    
         
             
            have_func("rb_sym2str", ["ruby.h"])
         
     | 
| 
       8 
8 
     | 
    
         
             
            have_func("rb_str_intern", ["ruby.h"])
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
      
 10 
     | 
    
         
            +
            unless RUBY_PLATFORM.include? 'mswin'
         
     | 
| 
      
 11 
     | 
    
         
            +
              $CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
         
     | 
| 
      
 12 
     | 
    
         
            +
            end
         
     | 
| 
       11 
13 
     | 
    
         
             
            #$CFLAGS << %[ -DDISABLE_RMEM]
         
     | 
| 
       12 
14 
     | 
    
         
             
            #$CFLAGS << %[ -DDISABLE_RMEM_REUSE_INTERNAL_FRAGMENT]
         
     | 
| 
       13 
15 
     | 
    
         
             
            #$CFLAGS << %[ -DDISABLE_BUFFER_READ_REFERENCE_OPTIMIZE]
         
     | 
    
        data/ext/msgpack/packer.h
    CHANGED
    
    | 
         @@ -32,11 +32,15 @@ struct msgpack_packer_t { 
     | 
|
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
                VALUE io;
         
     | 
| 
       34 
34 
     | 
    
         
             
                ID io_write_all_method;
         
     | 
| 
      
 35 
     | 
    
         
            +
                bool compatibility_mode;
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
       36 
37 
     | 
    
         
             
                ID to_msgpack_method;
         
     | 
| 
       37 
38 
     | 
    
         
             
                VALUE to_msgpack_arg;
         
     | 
| 
       38 
39 
     | 
    
         | 
| 
       39 
40 
     | 
    
         
             
                VALUE buffer_ref;
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                /* options */
         
     | 
| 
      
 43 
     | 
    
         
            +
                bool comaptibility_mode;
         
     | 
| 
       40 
44 
     | 
    
         
             
            };
         
     | 
| 
       41 
45 
     | 
    
         | 
| 
       42 
46 
     | 
    
         
             
            #define PACKER_BUFFER_(pk) (&(pk)->buffer)
         
     | 
| 
         @@ -66,6 +70,11 @@ static inline void msgpack_packer_set_io(msgpack_packer_t* pk, VALUE io, ID io_w 
     | 
|
| 
       66 
70 
     | 
    
         | 
| 
       67 
71 
     | 
    
         
             
            void msgpack_packer_reset(msgpack_packer_t* pk);
         
     | 
| 
       68 
72 
     | 
    
         | 
| 
      
 73 
     | 
    
         
            +
            static inline void msgpack_packer_set_compat(msgpack_packer_t* pk, bool enable)
         
     | 
| 
      
 74 
     | 
    
         
            +
            {
         
     | 
| 
      
 75 
     | 
    
         
            +
                pk->compatibility_mode = enable;
         
     | 
| 
      
 76 
     | 
    
         
            +
            }
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
       69 
78 
     | 
    
         
             
            static inline void msgpack_packer_write_nil(msgpack_packer_t* pk)
         
     | 
| 
       70 
79 
     | 
    
         
             
            {
         
     | 
| 
       71 
80 
     | 
    
         
             
                msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 1);
         
     | 
| 
         @@ -270,7 +279,7 @@ static inline void msgpack_packer_write_raw_header(msgpack_packer_t* pk, unsigne 
     | 
|
| 
       270 
279 
     | 
    
         
             
                    msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 1);
         
     | 
| 
       271 
280 
     | 
    
         
             
                    unsigned char h = 0xa0 | (uint8_t) n;
         
     | 
| 
       272 
281 
     | 
    
         
             
                    msgpack_buffer_write_1(PACKER_BUFFER_(pk), h);
         
     | 
| 
       273 
     | 
    
         
            -
                } else if(n < 256) {
         
     | 
| 
      
 282 
     | 
    
         
            +
                } else if(n < 256 && !pk->compatibility_mode) {
         
     | 
| 
       274 
283 
     | 
    
         
             
                    msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 2);
         
     | 
| 
       275 
284 
     | 
    
         
             
                    unsigned char be = (uint8_t) n;
         
     | 
| 
       276 
285 
     | 
    
         
             
                    msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xd9, (const void*)&be, 1);
         
     | 
| 
         @@ -288,7 +297,7 @@ static inline void msgpack_packer_write_raw_header(msgpack_packer_t* pk, unsigne 
     | 
|
| 
       288 
297 
     | 
    
         
             
            static inline void msgpack_packer_write_bin_header(msgpack_packer_t* pk, unsigned int n)
         
     | 
| 
       289 
298 
     | 
    
         
             
            {
         
     | 
| 
       290 
299 
     | 
    
         
             
                if(n < 256) {
         
     | 
| 
       291 
     | 
    
         
            -
                    msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk),  
     | 
| 
      
 300 
     | 
    
         
            +
                    msgpack_buffer_ensure_writable(PACKER_BUFFER_(pk), 2);
         
     | 
| 
       292 
301 
     | 
    
         
             
                    unsigned char be = (uint8_t) n;
         
     | 
| 
       293 
302 
     | 
    
         
             
                    msgpack_buffer_write_byte_and_data(PACKER_BUFFER_(pk), 0xc4, (const void*)&be, 1);
         
     | 
| 
       294 
303 
     | 
    
         
             
                } else if(n < 65536) {
         
     | 
| 
         @@ -358,7 +367,6 @@ static inline bool msgpack_packer_is_utf8_compat_string(VALUE v, int encindex) 
     | 
|
| 
       358 
367 
     | 
    
         | 
| 
       359 
368 
     | 
    
         
             
            static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE v)
         
     | 
| 
       360 
369 
     | 
    
         
             
            {
         
     | 
| 
       361 
     | 
    
         
            -
                /* TODO encoding conversion? */
         
     | 
| 
       362 
370 
     | 
    
         
             
                /* actual return type of RSTRING_LEN is long */
         
     | 
| 
       363 
371 
     | 
    
         
             
                unsigned long len = RSTRING_LEN(v);
         
     | 
| 
       364 
372 
     | 
    
         
             
                if(len > 0xffffffffUL) {
         
     | 
| 
         @@ -368,13 +376,14 @@ static inline void msgpack_packer_write_string_value(msgpack_packer_t* pk, VALUE 
     | 
|
| 
       368 
376 
     | 
    
         | 
| 
       369 
377 
     | 
    
         
             
            #ifdef COMPAT_HAVE_ENCODING
         
     | 
| 
       370 
378 
     | 
    
         
             
                int encindex = ENCODING_GET(v);
         
     | 
| 
       371 
     | 
    
         
            -
                if(msgpack_packer_is_binary(v, encindex)) {
         
     | 
| 
      
 379 
     | 
    
         
            +
                if(msgpack_packer_is_binary(v, encindex) && !pk->compatibility_mode) {
         
     | 
| 
       372 
380 
     | 
    
         
             
                    /* write ASCII-8BIT string using Binary type */
         
     | 
| 
       373 
381 
     | 
    
         
             
                    msgpack_packer_write_bin_header(pk, (unsigned int)len);
         
     | 
| 
       374 
382 
     | 
    
         
             
                    msgpack_buffer_append_string(PACKER_BUFFER_(pk), v);
         
     | 
| 
       375 
383 
     | 
    
         
             
                } else {
         
     | 
| 
       376 
384 
     | 
    
         
             
                    /* write UTF-8, US-ASCII, or 7bit-safe ascii-compatible string using String type directly */
         
     | 
| 
       377 
     | 
    
         
            -
                     
     | 
| 
      
 385 
     | 
    
         
            +
                    /* in compatibility mode, packer packs String values as is */
         
     | 
| 
      
 386 
     | 
    
         
            +
                    if(!pk->compatibility_mode && !msgpack_packer_is_utf8_compat_string(v, encindex)) {
         
     | 
| 
       378 
387 
     | 
    
         
             
                        /* transcode other strings to UTF-8 and write using String type */
         
     | 
| 
       379 
388 
     | 
    
         
             
                        VALUE enc = rb_enc_from_encoding(rb_utf8_encoding()); /* rb_enc_from_encoding_index is not extern */
         
     | 
| 
       380 
389 
     | 
    
         
             
                        v = rb_str_encode(v, enc, 0, Qnil);
         
     | 
| 
         @@ -395,15 +404,11 @@ static inline void msgpack_packer_write_symbol_value(msgpack_packer_t* pk, VALUE 
     | 
|
| 
       395 
404 
     | 
    
         
             
                /* rb_sym2str is added since MRI 2.2.0 */
         
     | 
| 
       396 
405 
     | 
    
         
             
                msgpack_packer_write_string_value(pk, rb_sym2str(v));
         
     | 
| 
       397 
406 
     | 
    
         
             
            #else
         
     | 
| 
       398 
     | 
    
         
            -
                 
     | 
| 
       399 
     | 
    
         
            -
                 
     | 
| 
       400 
     | 
    
         
            -
             
     | 
| 
       401 
     | 
    
         
            -
                if(len > 0xffffffffUL) {
         
     | 
| 
       402 
     | 
    
         
            -
                    // TODO rb_eArgError?
         
     | 
| 
       403 
     | 
    
         
            -
                    rb_raise(rb_eArgError, "size of symbol is too long to pack: %lu bytes should be <= %lu", len, 0xffffffffUL);
         
     | 
| 
      
 407 
     | 
    
         
            +
                VALUE str = rb_id2str(SYM2ID(v));
         
     | 
| 
      
 408 
     | 
    
         
            +
                if (!str) {
         
     | 
| 
      
 409 
     | 
    
         
            +
                   rb_raise(rb_eRuntimeError, "could not convert a symbol to string");
         
     | 
| 
       404 
410 
     | 
    
         
             
                }
         
     | 
| 
       405 
     | 
    
         
            -
                 
     | 
| 
       406 
     | 
    
         
            -
                msgpack_buffer_append(PACKER_BUFFER_(pk), name, len);
         
     | 
| 
      
 411 
     | 
    
         
            +
                msgpack_packer_write_string_value(pk, str);
         
     | 
| 
       407 
412 
     | 
    
         
             
            #endif
         
     | 
| 
       408 
413 
     | 
    
         
             
            }
         
     | 
| 
       409 
414 
     | 
    
         | 
    
        data/ext/msgpack/packer_class.c
    CHANGED
    
    | 
         @@ -87,13 +87,24 @@ static VALUE Packer_initialize(int argc, VALUE* argv, VALUE self) 
     | 
|
| 
       87 
87 
     | 
    
         
             
                }
         
     | 
| 
       88 
88 
     | 
    
         | 
| 
       89 
89 
     | 
    
         
             
                PACKER(self, pk);
         
     | 
| 
       90 
     | 
    
         
            -
                MessagePack_Buffer_initialize(PACKER_BUFFER_(pk), io, options);
         
     | 
| 
       91 
90 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
                 
     | 
| 
      
 91 
     | 
    
         
            +
                MessagePack_Packer_initialize(pk, io, options);
         
     | 
| 
       93 
92 
     | 
    
         | 
| 
       94 
93 
     | 
    
         
             
                return self;
         
     | 
| 
       95 
94 
     | 
    
         
             
            }
         
     | 
| 
       96 
95 
     | 
    
         | 
| 
      
 96 
     | 
    
         
            +
            void MessagePack_Packer_initialize(msgpack_packer_t* pk, VALUE io, VALUE options)
         
     | 
| 
      
 97 
     | 
    
         
            +
            {
         
     | 
| 
      
 98 
     | 
    
         
            +
                MessagePack_Buffer_initialize(PACKER_BUFFER_(pk), io, options);
         
     | 
| 
      
 99 
     | 
    
         
            +
             
     | 
| 
      
 100 
     | 
    
         
            +
                if(options != Qnil) {
         
     | 
| 
      
 101 
     | 
    
         
            +
                    VALUE v;
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                    v = rb_hash_aref(options, ID2SYM(rb_intern("compatibility_mode")));
         
     | 
| 
      
 104 
     | 
    
         
            +
                    msgpack_packer_set_compat(pk, RTEST(v));
         
     | 
| 
      
 105 
     | 
    
         
            +
                }
         
     | 
| 
      
 106 
     | 
    
         
            +
            }
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
       97 
108 
     | 
    
         
             
            static VALUE Packer_buffer(VALUE self)
         
     | 
| 
       98 
109 
     | 
    
         
             
            {
         
     | 
| 
       99 
110 
     | 
    
         
             
                PACKER(self, pk);
         
     | 
| 
         @@ -221,11 +232,15 @@ VALUE MessagePack_pack(int argc, VALUE* argv) 
     | 
|
| 
       221 
232 
     | 
    
         | 
| 
       222 
233 
     | 
    
         
             
                VALUE self = Packer_alloc(cMessagePack_Packer);
         
     | 
| 
       223 
234 
     | 
    
         
             
                PACKER(self, pk);
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
      
 236 
     | 
    
         
            +
                if (options != Qnil) {
         
     | 
| 
      
 237 
     | 
    
         
            +
                  pk->compatibility_mode = RTEST(rb_hash_aref(options, ID2SYM(rb_intern("compatibility_mode"))));
         
     | 
| 
      
 238 
     | 
    
         
            +
                }
         
     | 
| 
      
 239 
     | 
    
         
            +
             
     | 
| 
       224 
240 
     | 
    
         
             
                //msgpack_packer_reset(s_packer);
         
     | 
| 
       225 
241 
     | 
    
         
             
                //msgpack_buffer_reset_io(PACKER_BUFFER_(s_packer));
         
     | 
| 
       226 
242 
     | 
    
         | 
| 
       227 
     | 
    
         
            -
                 
     | 
| 
       228 
     | 
    
         
            -
                // TODO MessagePack_Unpacker_initialize and options
         
     | 
| 
      
 243 
     | 
    
         
            +
                MessagePack_Packer_initialize(pk, io, options);
         
     | 
| 
       229 
244 
     | 
    
         | 
| 
       230 
245 
     | 
    
         
             
                msgpack_packer_write_value(pk, v);
         
     | 
| 
       231 
246 
     | 
    
         | 
    
        data/ext/msgpack/packer_class.h
    CHANGED
    
    
    
        data/lib/msgpack/version.rb
    CHANGED
    
    
    
        data/spec/cruby/packer_spec.rb
    CHANGED
    
    | 
         @@ -116,5 +116,23 @@ describe Packer do 
     | 
|
| 
       116 
116 
     | 
    
         
             
                CustomPack02.new.to_msgpack(s04)
         
     | 
| 
       117 
117 
     | 
    
         
             
                s04.string.should == [1,2].to_msgpack
         
     | 
| 
       118 
118 
     | 
    
         
             
              end
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
              context 'in compatibility mode' do
         
     | 
| 
      
 121 
     | 
    
         
            +
                it 'does not use the bin types' do
         
     | 
| 
      
 122 
     | 
    
         
            +
                  packed = MessagePack.pack('hello'.force_encoding(Encoding::BINARY), compatibility_mode: true)
         
     | 
| 
      
 123 
     | 
    
         
            +
                  packed.should eq("\xA5hello")
         
     | 
| 
      
 124 
     | 
    
         
            +
                  packed = MessagePack.pack(('hello' * 100).force_encoding(Encoding::BINARY), compatibility_mode: true)
         
     | 
| 
      
 125 
     | 
    
         
            +
                  packed.should start_with("\xDA\x01\xF4")
         
     | 
| 
      
 126 
     | 
    
         
            +
             
     | 
| 
      
 127 
     | 
    
         
            +
                  packer = MessagePack::Packer.new(compatibility_mode: 1)
         
     | 
| 
      
 128 
     | 
    
         
            +
                  packed = packer.pack(('hello' * 100).force_encoding(Encoding::BINARY))
         
     | 
| 
      
 129 
     | 
    
         
            +
                  packed.to_str.should start_with("\xDA\x01\xF4")
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                it 'does not use the str8 type' do
         
     | 
| 
      
 133 
     | 
    
         
            +
                  packed = MessagePack.pack('x' * 32, compatibility_mode: true)
         
     | 
| 
      
 134 
     | 
    
         
            +
                  packed.should start_with("\xDA\x00\x20")
         
     | 
| 
      
 135 
     | 
    
         
            +
                end
         
     | 
| 
      
 136 
     | 
    
         
            +
              end
         
     | 
| 
       119 
137 
     | 
    
         
             
            end
         
     | 
| 
       120 
138 
     | 
    
         | 
    
        data/spec/format_spec.rb
    CHANGED
    
    | 
         @@ -126,6 +126,25 @@ describe MessagePack do 
     | 
|
| 
       126 
126 
     | 
    
         
             
                v.should == "\xE3\x81\x82".force_encoding('UTF-8')
         
     | 
| 
       127 
127 
     | 
    
         
             
              end
         
     | 
| 
       128 
128 
     | 
    
         | 
| 
      
 129 
     | 
    
         
            +
              it "symbol to str" do
         
     | 
| 
      
 130 
     | 
    
         
            +
                v = pack_unpack(:a)
         
     | 
| 
      
 131 
     | 
    
         
            +
                v.should == "a".force_encoding('UTF-8')
         
     | 
| 
      
 132 
     | 
    
         
            +
              end
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
              it "symbol to str with encoding" do
         
     | 
| 
      
 135 
     | 
    
         
            +
                a = "\xE3\x81\x82".force_encoding('UTF-8')
         
     | 
| 
      
 136 
     | 
    
         
            +
                v = pack_unpack(a.encode('Shift_JIS').to_sym)
         
     | 
| 
      
 137 
     | 
    
         
            +
                v.encoding.should == Encoding::UTF_8
         
     | 
| 
      
 138 
     | 
    
         
            +
                v.should == a
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
              it "symbol to bin" do
         
     | 
| 
      
 142 
     | 
    
         
            +
                a = "\xE3\x81\x82".force_encoding('ASCII-8BIT')
         
     | 
| 
      
 143 
     | 
    
         
            +
                v = pack_unpack(a.to_sym)
         
     | 
| 
      
 144 
     | 
    
         
            +
                v.encoding.should == Encoding::ASCII_8BIT
         
     | 
| 
      
 145 
     | 
    
         
            +
                v.should == a
         
     | 
| 
      
 146 
     | 
    
         
            +
              end
         
     | 
| 
      
 147 
     | 
    
         
            +
             
     | 
| 
       129 
148 
     | 
    
         
             
              it "bin 8" do
         
     | 
| 
       130 
149 
     | 
    
         
             
                check_bin 2, (1<<8)-1
         
     | 
| 
       131 
150 
     | 
    
         
             
              end
         
     | 
    
        data/spec/jruby/msgpack_spec.rb
    CHANGED
    
    | 
         @@ -36,9 +36,15 @@ describe MessagePack do 
     | 
|
| 
       36 
36 
     | 
    
         
             
                  ['negative floats', -2.1, "\xCB\xC0\x00\xCC\xCC\xCC\xCC\xCC\xCD"]
         
     | 
| 
       37 
37 
     | 
    
         
             
                ],
         
     | 
| 
       38 
38 
     | 
    
         
             
                'strings' => [
         
     | 
| 
       39 
     | 
    
         
            -
                  ['strings', utf8enc('hello world'), "\xABhello world"],
         
     | 
| 
      
 39 
     | 
    
         
            +
                  ['tiny strings', utf8enc('hello world'), "\xABhello world"],
         
     | 
| 
      
 40 
     | 
    
         
            +
                  ['short strings', utf8enc('hello' * 5), "\xB9hellohellohellohellohello"],
         
     | 
| 
       40 
41 
     | 
    
         
             
                  ['empty strings', utf8enc(''), "\xA0"]
         
     | 
| 
       41 
42 
     | 
    
         
             
                ],
         
     | 
| 
      
 43 
     | 
    
         
            +
                'binary strings' => [
         
     | 
| 
      
 44 
     | 
    
         
            +
                  ['tiny strings', asciienc('hello world'), "\xC4\vhello world"],
         
     | 
| 
      
 45 
     | 
    
         
            +
                  ['short strings', asciienc('hello' * 5), "\xC4\x19hellohellohellohellohello"],
         
     | 
| 
      
 46 
     | 
    
         
            +
                  ['empty strings', asciienc(''), "\xC4\x00"]
         
     | 
| 
      
 47 
     | 
    
         
            +
                ],
         
     | 
| 
       42 
48 
     | 
    
         
             
                'arrays' => [
         
     | 
| 
       43 
49 
     | 
    
         
             
                  ['empty arrays', [], "\x90"],
         
     | 
| 
       44 
50 
     | 
    
         
             
                  ['arrays with strings', [utf8enc("hello"), utf8enc("world")], "\x92\xA5hello\xA5world"],
         
     | 
| 
         @@ -139,4 +145,18 @@ describe MessagePack do 
     | 
|
| 
       139 
145 
     | 
    
         
             
                  packed.index("w\xC3\xA5rld").should_not be_nil
         
     | 
| 
       140 
146 
     | 
    
         
             
                end
         
     | 
| 
       141 
147 
     | 
    
         
             
              end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
              context 'in compatibility mode' do
         
     | 
| 
      
 150 
     | 
    
         
            +
                it 'does not use the bin types' do
         
     | 
| 
      
 151 
     | 
    
         
            +
                  packed = MessagePack.pack('hello'.force_encoding(Encoding::BINARY), compatibility_mode: true)
         
     | 
| 
      
 152 
     | 
    
         
            +
                  packed.should eq("\xA5hello")
         
     | 
| 
      
 153 
     | 
    
         
            +
                  packed = MessagePack.pack(('hello' * 100).force_encoding(Encoding::BINARY), compatibility_mode: true)
         
     | 
| 
      
 154 
     | 
    
         
            +
                  packed.should start_with("\xDA\x01\xF4")
         
     | 
| 
      
 155 
     | 
    
         
            +
                end
         
     | 
| 
      
 156 
     | 
    
         
            +
             
     | 
| 
      
 157 
     | 
    
         
            +
                it 'does not use the str8 type' do
         
     | 
| 
      
 158 
     | 
    
         
            +
                  packed = MessagePack.pack('x' * 32, compatibility_mode: true)
         
     | 
| 
      
 159 
     | 
    
         
            +
                  packed.should start_with("\xDA\x00\x20")
         
     | 
| 
      
 160 
     | 
    
         
            +
                end
         
     | 
| 
      
 161 
     | 
    
         
            +
              end
         
     | 
| 
       142 
162 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: msgpack
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.6. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.6.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: x86-mingw32
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sadayuki Furuhashi
         
     | 
| 
         @@ -9,7 +9,7 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2015-07-22 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
       14 
14 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
15 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -121,7 +121,6 @@ files: 
     | 
|
| 
       121 
121 
     | 
    
         
             
            - bench/unpack.rb
         
     | 
| 
       122 
122 
     | 
    
         
             
            - bench/unpack_log.rb
         
     | 
| 
       123 
123 
     | 
    
         
             
            - bench/unpack_log_long.rb
         
     | 
| 
       124 
     | 
    
         
            -
            - cross-build.sh
         
     | 
| 
       125 
124 
     | 
    
         
             
            - doclib/msgpack.rb
         
     | 
| 
       126 
125 
     | 
    
         
             
            - doclib/msgpack/buffer.rb
         
     | 
| 
       127 
126 
     | 
    
         
             
            - doclib/msgpack/core_ext.rb
         
     | 
| 
         @@ -159,7 +158,8 @@ files: 
     | 
|
| 
       159 
158 
     | 
    
         
             
            - ext/msgpack/unpacker_class.c
         
     | 
| 
       160 
159 
     | 
    
         
             
            - ext/msgpack/unpacker_class.h
         
     | 
| 
       161 
160 
     | 
    
         
             
            - lib/msgpack.rb
         
     | 
| 
       162 
     | 
    
         
            -
            - lib/msgpack/msgpack.so
         
     | 
| 
      
 161 
     | 
    
         
            +
            - lib/msgpack/2.1/msgpack.so
         
     | 
| 
      
 162 
     | 
    
         
            +
            - lib/msgpack/2.2/msgpack.so
         
     | 
| 
       163 
163 
     | 
    
         
             
            - lib/msgpack/version.rb
         
     | 
| 
       164 
164 
     | 
    
         
             
            - msgpack.gemspec
         
     | 
| 
       165 
165 
     | 
    
         
             
            - msgpack.org.md
         
     | 
| 
         @@ -197,9 +197,9 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       197 
197 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       198 
198 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       199 
199 
     | 
    
         
             
              requirements:
         
     | 
| 
       200 
     | 
    
         
            -
              - - " 
     | 
| 
      
 200 
     | 
    
         
            +
              - - ">="
         
     | 
| 
       201 
201 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       202 
     | 
    
         
            -
                  version:  
     | 
| 
      
 202 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
       203 
203 
     | 
    
         
             
            requirements: []
         
     | 
| 
       204 
204 
     | 
    
         
             
            rubyforge_project: msgpack
         
     | 
| 
       205 
205 
     | 
    
         
             
            rubygems_version: 2.4.5
         
     |