msgpack 1.3.3-java → 1.4.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/msgpack.rb +1 -5
- data/lib/msgpack/msgpack.jar +0 -0
- data/lib/msgpack/version.rb +4 -8
- data/spec/spec_helper.rb +17 -0
- data/spec/unpacker_spec.rb +96 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df3b24e93761eeee9892ce39650e1d78ef3b10690c17175ff1fdf89fb2430e79
|
4
|
+
data.tar.gz: 0aca3d762180d301e52bd89f303ff593487f3ceb468bf792e378ee4b5a56af11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18a3f11686786575886117fdc5f0886c8c3bdd796a79f92bac63437771c885235f80e05f87abf65ad427ca9343931adb79f2a8ba3ba00c73ae3d078f86c12883
|
7
|
+
data.tar.gz: 8462fa5a43f395a56bb01223c0513b06a9761d2608436b1675b036e0d94a393f896f0779e68e416d8d0c2e779cce50debab7dcc03e6ed816b7739d1a667ddf3f
|
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,10 +1,6 @@
|
|
1
1
|
module MessagePack
|
2
|
-
VERSION = "1.
|
3
|
-
|
4
|
-
#
|
5
|
-
#
|
6
|
-
# * versions/supports of rake-compiler & rake-compiler-dock
|
7
|
-
# https://github.com/rake-compiler/rake-compiler-dock/blob/master/History.md
|
8
|
-
# * update RUBY_CC_VERSION in Rakefile
|
9
|
-
# * check Ruby dependency of released mswin gem details
|
2
|
+
VERSION = "1.4.0"
|
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.
|
10
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')
|
@@ -651,6 +664,88 @@ describe MessagePack::Unpacker do
|
|
651
664
|
end
|
652
665
|
end
|
653
666
|
|
667
|
+
context 'freeze' do
|
668
|
+
let :struct do
|
669
|
+
{'hello' => 'world', 'nested' => ['object', {'structure' => true}]}
|
670
|
+
end
|
671
|
+
|
672
|
+
let :buffer do
|
673
|
+
MessagePack.pack(struct)
|
674
|
+
end
|
675
|
+
|
676
|
+
let :unpacker do
|
677
|
+
described_class.new(:freeze => true)
|
678
|
+
end
|
679
|
+
|
680
|
+
it 'can freeze objects when using .unpack' do
|
681
|
+
parsed_struct = MessagePack.unpack(buffer, freeze: true)
|
682
|
+
parsed_struct.should == struct
|
683
|
+
|
684
|
+
parsed_struct.should be_frozen
|
685
|
+
parsed_struct['hello'].should be_frozen
|
686
|
+
parsed_struct['nested'].should be_frozen
|
687
|
+
parsed_struct['nested'][0].should be_frozen
|
688
|
+
parsed_struct['nested'][1].should be_frozen
|
689
|
+
|
690
|
+
if string_deduplication?
|
691
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
692
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
693
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
694
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
695
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
696
|
+
end
|
697
|
+
end
|
698
|
+
|
699
|
+
it 'can freeze objects when using #each' do
|
700
|
+
objs = []
|
701
|
+
unpacker.feed(buffer)
|
702
|
+
unpacker.each do |obj|
|
703
|
+
objs << obj
|
704
|
+
end
|
705
|
+
|
706
|
+
parsed_struct = objs.first
|
707
|
+
parsed_struct.should == struct
|
708
|
+
|
709
|
+
parsed_struct.should be_frozen
|
710
|
+
parsed_struct['hello'].should be_frozen
|
711
|
+
parsed_struct['nested'].should be_frozen
|
712
|
+
parsed_struct['nested'][0].should be_frozen
|
713
|
+
parsed_struct['nested'][1].should be_frozen
|
714
|
+
|
715
|
+
if string_deduplication?
|
716
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
717
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
718
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
719
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
720
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
it 'can freeze objects when using #feed_each' do
|
725
|
+
objs = []
|
726
|
+
unpacker.feed_each(buffer) do |obj|
|
727
|
+
objs << obj
|
728
|
+
end
|
729
|
+
|
730
|
+
parsed_struct = objs.first
|
731
|
+
parsed_struct.should == struct
|
732
|
+
|
733
|
+
parsed_struct.should be_frozen
|
734
|
+
parsed_struct['hello'].should be_frozen
|
735
|
+
parsed_struct['nested'].should be_frozen
|
736
|
+
parsed_struct['nested'][0].should be_frozen
|
737
|
+
parsed_struct['nested'][1].should be_frozen
|
738
|
+
|
739
|
+
if string_deduplication?
|
740
|
+
parsed_struct.keys[0].should be_equal('hello'.freeze)
|
741
|
+
parsed_struct.keys[1].should be_equal('nested'.freeze)
|
742
|
+
parsed_struct.values[0].should be_equal('world'.freeze)
|
743
|
+
parsed_struct.values[1][0].should be_equal('object'.freeze)
|
744
|
+
parsed_struct.values[1][1].keys[0].should be_equal('structure'.freeze)
|
745
|
+
end
|
746
|
+
end
|
747
|
+
end
|
748
|
+
|
654
749
|
context 'binary encoding', :encodings do
|
655
750
|
let :buffer do
|
656
751
|
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.0
|
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-01-27 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:
|