msgpack 1.3.1-java → 1.4.2-java
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/lib/msgpack.rb +1 -5
- data/lib/msgpack/msgpack.jar +0 -0
- data/lib/msgpack/version.rb +4 -7
- data/spec/spec_helper.rb +17 -0
- data/spec/unpacker_spec.rb +104 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28c159245a02113dad1dfaf36a07a30950e00ecedd33b148eee8aed8e00b0b6f
|
4
|
+
data.tar.gz: 7318156b3b7d71165a0203f2c665fb7c28b245a6419b456c51121a3b6d6b5bbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 061c33efbd315663b330d246a925b44aed1c7c47651fe459f76aae5f94470415350f146119ab6983a72a40911df19d275026a3b4d660d946ea7fb025af40095b
|
7
|
+
data.tar.gz: b14c4efe89bbe77f4dab95b6d9d2e6e4a38a6d1a5e083d07c06a1b944b2e6a614b33ea5c1677e083be0406b65be7aaf70c3b4ee6d82c927b567306d509487764
|
data/lib/msgpack.rb
CHANGED
@@ -5,11 +5,7 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby" # This is same with `/java/ =
|
|
5
5
|
require "msgpack/msgpack.jar"
|
6
6
|
org.msgpack.jruby.MessagePackLibrary.new.load(JRuby.runtime, false)
|
7
7
|
else
|
8
|
-
|
9
|
-
require "msgpack/#{RUBY_VERSION[/\d+.\d+/]}/msgpack"
|
10
|
-
rescue LoadError
|
11
|
-
require "msgpack/msgpack"
|
12
|
-
end
|
8
|
+
require "msgpack/msgpack"
|
13
9
|
end
|
14
10
|
|
15
11
|
require "msgpack/packer"
|
data/lib/msgpack/msgpack.jar
CHANGED
Binary file
|
data/lib/msgpack/version.rb
CHANGED
@@ -1,9 +1,6 @@
|
|
1
1
|
module MessagePack
|
2
|
-
VERSION = "1.
|
3
|
-
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# * versions/supports of rake-compiler & rake-compiler-dock
|
7
|
-
# * update RUBY_CC_VERSION in Rakefile
|
8
|
-
# * check Ruby dependency of released mswin gem details
|
2
|
+
VERSION = "1.4.2"
|
3
|
+
# Note for maintainers:
|
4
|
+
# Don't miss building/releasing the JRuby version (rake buld:java)
|
5
|
+
# See "How to build -java rubygems" in README for more details.
|
9
6
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -19,6 +19,23 @@ def java?
|
|
19
19
|
/java/ =~ RUBY_PLATFORM
|
20
20
|
end
|
21
21
|
|
22
|
+
# checking if Hash#[]= (rb_hash_aset) dedupes string keys
|
23
|
+
def automatic_string_keys_deduplication?
|
24
|
+
h = {}
|
25
|
+
x = {}
|
26
|
+
r = rand.to_s
|
27
|
+
h[%W(#{r}).join('')] = :foo
|
28
|
+
x[%W(#{r}).join('')] = :foo
|
29
|
+
|
30
|
+
x.keys[0].equal?(h.keys[0])
|
31
|
+
end
|
32
|
+
|
33
|
+
def string_deduplication?
|
34
|
+
r1 = rand.to_s
|
35
|
+
r2 = r1.dup
|
36
|
+
(-r1).equal?(-r2)
|
37
|
+
end
|
38
|
+
|
22
39
|
if java?
|
23
40
|
RSpec.configure do |c|
|
24
41
|
c.treat_symbols_as_metadata_keys_with_true_values = true
|
data/spec/unpacker_spec.rb
CHANGED
@@ -18,13 +18,26 @@ describe MessagePack::Unpacker do
|
|
18
18
|
it 'gets options to specify how to unpack values' do
|
19
19
|
u1 = MessagePack::Unpacker.new
|
20
20
|
u1.symbolize_keys?.should == false
|
21
|
+
u1.freeze?.should == false
|
21
22
|
u1.allow_unknown_ext?.should == false
|
22
23
|
|
23
|
-
u2 = MessagePack::Unpacker.new(symbolize_keys: true, allow_unknown_ext: true)
|
24
|
+
u2 = MessagePack::Unpacker.new(symbolize_keys: true, freeze: true, allow_unknown_ext: true)
|
24
25
|
u2.symbolize_keys?.should == true
|
26
|
+
u2.freeze?.should == true
|
25
27
|
u2.allow_unknown_ext?.should == true
|
26
28
|
end
|
27
29
|
|
30
|
+
if automatic_string_keys_deduplication?
|
31
|
+
it 'ensure string hash keys are deduplicated' do
|
32
|
+
sample_data = [{"foo" => 1}, {"foo" => 2}]
|
33
|
+
sample_packed = MessagePack.pack(sample_data).force_encoding('ASCII-8BIT')
|
34
|
+
unpacker.feed(sample_packed)
|
35
|
+
hashes = nil
|
36
|
+
unpacker.each { |obj| hashes = obj }
|
37
|
+
expect(hashes[0].keys.first).to equal(hashes[1].keys.first)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
28
41
|
it 'gets IO or object which has #read to read data from it' do
|
29
42
|
sample_data = {"message" => "morning!", "num" => 1}
|
30
43
|
sample_packed = MessagePack.pack(sample_data).force_encoding('ASCII-8BIT')
|
@@ -621,6 +634,14 @@ describe MessagePack::Unpacker do
|
|
621
634
|
array = ['foo'] * 10_000
|
622
635
|
MessagePack.unpack(MessagePack.pack(array)).size.should == 10_000
|
623
636
|
end
|
637
|
+
|
638
|
+
it 'preserve string encoding (issue #200)' do
|
639
|
+
string = 'a'.force_encoding(Encoding::UTF_8)
|
640
|
+
MessagePack.unpack(MessagePack.pack(string)).encoding.should == string.encoding
|
641
|
+
|
642
|
+
string *= 256
|
643
|
+
MessagePack.unpack(MessagePack.pack(string)).encoding.should == string.encoding
|
644
|
+
end
|
624
645
|
end
|
625
646
|
|
626
647
|
context 'extensions' do
|
@@ -651,6 +672,88 @@ describe MessagePack::Unpacker do
|
|
651
672
|
end
|
652
673
|
end
|
653
674
|
|
675
|
+
context 'freeze' do
|
676
|
+
let :struct do
|
677
|
+
{'hello' => 'world', 'nested' => ['object', {'structure' => true}]}
|
678
|
+
end
|
679
|
+
|
680
|
+
let :buffer do
|
681
|
+
MessagePack.pack(struct)
|
682
|
+
end
|
683
|
+
|
684
|
+
let :unpacker do
|
685
|
+
described_class.new(:freeze => true)
|
686
|
+
end
|
687
|
+
|
688
|
+
it 'can freeze objects when using .unpack' do
|
689
|
+
parsed_struct = MessagePack.unpack(buffer, freeze: true)
|
690
|
+
parsed_struct.should == struct
|
691
|
+
|
692
|
+
parsed_struct.should be_frozen
|
693
|
+
parsed_struct['hello'].should be_frozen
|
694
|
+
parsed_struct['nested'].should be_frozen
|
695
|
+
parsed_struct['nested'][0].should be_frozen
|
696
|
+
parsed_struct['nested'][1].should be_frozen
|
697
|
+
|
698
|
+
if string_deduplication?
|
699
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
700
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
701
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
702
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
703
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
704
|
+
end
|
705
|
+
end
|
706
|
+
|
707
|
+
it 'can freeze objects when using #each' do
|
708
|
+
objs = []
|
709
|
+
unpacker.feed(buffer)
|
710
|
+
unpacker.each do |obj|
|
711
|
+
objs << obj
|
712
|
+
end
|
713
|
+
|
714
|
+
parsed_struct = objs.first
|
715
|
+
parsed_struct.should == struct
|
716
|
+
|
717
|
+
parsed_struct.should be_frozen
|
718
|
+
parsed_struct['hello'].should be_frozen
|
719
|
+
parsed_struct['nested'].should be_frozen
|
720
|
+
parsed_struct['nested'][0].should be_frozen
|
721
|
+
parsed_struct['nested'][1].should be_frozen
|
722
|
+
|
723
|
+
if string_deduplication?
|
724
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
725
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
726
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
727
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
728
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
729
|
+
end
|
730
|
+
end
|
731
|
+
|
732
|
+
it 'can freeze objects when using #feed_each' do
|
733
|
+
objs = []
|
734
|
+
unpacker.feed_each(buffer) do |obj|
|
735
|
+
objs << obj
|
736
|
+
end
|
737
|
+
|
738
|
+
parsed_struct = objs.first
|
739
|
+
parsed_struct.should == struct
|
740
|
+
|
741
|
+
parsed_struct.should be_frozen
|
742
|
+
parsed_struct['hello'].should be_frozen
|
743
|
+
parsed_struct['nested'].should be_frozen
|
744
|
+
parsed_struct['nested'][0].should be_frozen
|
745
|
+
parsed_struct['nested'][1].should be_frozen
|
746
|
+
|
747
|
+
if string_deduplication?
|
748
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
749
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
750
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
751
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
752
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
753
|
+
end
|
754
|
+
end
|
755
|
+
end
|
756
|
+
|
654
757
|
context 'binary encoding', :encodings do
|
655
758
|
let :buffer do
|
656
759
|
MessagePack.pack({'hello' => 'world', 'nested' => ['object', {'structure' => true}]})
|
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: 1.
|
4
|
+
version: 1.4.2
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-02-01 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -43,17 +43,17 @@ dependencies:
|
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '
|
48
|
+
version: '0'
|
49
49
|
name: rake-compiler
|
50
50
|
prerelease: false
|
51
51
|
type: :development
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- - "
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: '
|
56
|
+
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
@@ -153,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
153
153
|
requirements:
|
154
154
|
- - ">="
|
155
155
|
- !ruby/object:Gem::Version
|
156
|
-
version: '
|
156
|
+
version: '2.4'
|
157
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
158
|
requirements:
|
159
159
|
- - ">="
|