msgpack 1.3.0-java → 1.4.1-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 50acb5f580ca3bc5003de45dc2348d7461365b6f262bb39d5c06095b31889dd2
4
- data.tar.gz: 4071ce9a089de10c2a3f583c27aaa9f8ca952766d29a9a16fd6112154fa28752
3
+ metadata.gz: 0a1e0c3e6a1d54dac456be496442ebb62d3a2bc88f6ff3c5f42df18e83d73e09
4
+ data.tar.gz: e8a501a0ff742f0ec5dd052fa25eadc28ad948e81b61ea0bb71543b80b7e46fb
5
5
  SHA512:
6
- metadata.gz: 9d75669baa1bc0e075909195655dc4c06481ce659d7ad1368b07502279c4f5300e6e9c130ca1d3d1674aaecf2e5c3350b02a1dd5f04c66a374384030ba28680d
7
- data.tar.gz: 7bbaef49fe323be3f172eb961e184608333643a37202ca5ecda86deaa2b3ea01ab3618828e1b88dd617798a79953255bfc83c6cbcad4d347b027ee35825bc0ab
6
+ metadata.gz: '096faa72aa72aec2c6ec4f08f26eaa480b80ff67be74e51cf89aa1aed79853d2638d0bb432e49022a0882a36da85895b38d01a6b3d440ba15dbfe57474f36fd3'
7
+ data.tar.gz: e75482dec9daf1b0ccfe714297887718ba3a9a5acc3b6fc211eb489fee3935eed2a8184734f66af9bd4bc5dcdf493806a7e34b9319a5e1ed23c25ac8c85c0f9c
@@ -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
- begin
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"
Binary file
@@ -55,7 +55,7 @@ module MessagePack
55
55
  else
56
56
  # timestamp64 (nsec: uint30be, sec: uint34be)
57
57
  nsec30 = nsec << 2
58
- sec_high2 = sec << 32 # high 2 bits (`x & 0b11` is redandunt)
58
+ sec_high2 = sec >> 32 # high 2 bits (`x & 0b11` is redandunt)
59
59
  sec_low32 = sec & 0xffffffff # low 32 bits
60
60
  [nsec30 | sec_high2, sec_low32].pack('L>2')
61
61
  end
@@ -1,9 +1,6 @@
1
1
  module MessagePack
2
- VERSION = "1.3.0"
3
-
4
- # NOTE for msgpack-ruby maintainer:
5
- # Check these things to release new binaryes for new Ruby versions (especially for Windows):
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.1"
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
@@ -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
@@ -56,6 +56,10 @@ describe MessagePack::Timestamp do
56
56
  expect(packed).to start_with(prefix_ext8_with_12bytes_payload_and_type_id)
57
57
  expect(packed.size).to eq(15)
58
58
  end
59
+
60
+ it 'runs correctly (regression)' do
61
+ expect(factory.unpack(factory.pack(Time.utc(2200)))).to eq(Time.utc(2200))
62
+ end
59
63
  end
60
64
 
61
65
  describe 'register_type with MessagePack::Timestamp' do
@@ -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.3.0
4
+ version: 1.4.1
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: 2019-06-20 00:00:00.000000000 Z
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: '1.0'
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: '1.0'
56
+ version: '0'
57
57
  - !ruby/object:Gem::Dependency
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements: