msgpack 0.5.10-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.
@@ -0,0 +1,67 @@
1
+ # encoding: ascii-8bit
2
+ require 'spec_helper'
3
+
4
+ require 'stringio'
5
+ if defined?(Encoding)
6
+ Encoding.default_external = 'ASCII-8BIT'
7
+ end
8
+
9
+ describe MessagePack do
10
+ it 'to_msgpack returns String' do
11
+ nil.to_msgpack.class.should == String
12
+ true.to_msgpack.class.should == String
13
+ false.to_msgpack.class.should == String
14
+ 1.to_msgpack.class.should == String
15
+ 1.0.to_msgpack.class.should == String
16
+ "".to_msgpack.class.should == String
17
+ Hash.new.to_msgpack.class.should == String
18
+ Array.new.to_msgpack.class.should == String
19
+ end
20
+
21
+ class CustomPack01
22
+ def to_msgpack(pk=nil)
23
+ return MessagePack.pack(self, pk) unless pk.class == MessagePack::Packer
24
+ pk.write_array_header(2)
25
+ pk.write(1)
26
+ pk.write(2)
27
+ return pk
28
+ end
29
+ end
30
+
31
+ class CustomPack02
32
+ def to_msgpack(pk=nil)
33
+ [1,2].to_msgpack(pk)
34
+ end
35
+ end
36
+
37
+ it 'calls custom to_msgpack method' do
38
+ if /java/ =~ RUBY_PLATFORM
39
+ skip "custom to_msgpack fallback is not supported yet in JRuby implementation"
40
+ end
41
+ MessagePack.pack(CustomPack01.new).should == [1,2].to_msgpack
42
+ MessagePack.pack(CustomPack02.new).should == [1,2].to_msgpack
43
+ CustomPack01.new.to_msgpack.should == [1,2].to_msgpack
44
+ CustomPack02.new.to_msgpack.should == [1,2].to_msgpack
45
+ end
46
+
47
+ it 'calls custom to_msgpack method with io' do
48
+ if /java/ =~ RUBY_PLATFORM
49
+ skip "custom to_msgpack fallback with io is not supported yet in JRuby implementation"
50
+ end
51
+ s01 = StringIO.new
52
+ MessagePack.pack(CustomPack01.new, s01)
53
+ s01.string.should == [1,2].to_msgpack
54
+
55
+ s02 = StringIO.new
56
+ MessagePack.pack(CustomPack02.new, s02)
57
+ s02.string.should == [1,2].to_msgpack
58
+
59
+ s03 = StringIO.new
60
+ CustomPack01.new.to_msgpack(s03)
61
+ s03.string.should == [1,2].to_msgpack
62
+
63
+ s04 = StringIO.new
64
+ CustomPack02.new.to_msgpack(s04)
65
+ s04.string.should == [1,2].to_msgpack
66
+ end
67
+ end
@@ -0,0 +1,24 @@
1
+
2
+ unless defined? Random
3
+ class Random
4
+ def initialize(seed=Time.now.to_i)
5
+ Kernel.srand(seed)
6
+ @seed = seed
7
+ end
8
+
9
+ attr_reader :seed
10
+
11
+ def rand(arg)
12
+ Kernel.rand(arg)
13
+ end
14
+
15
+ def bytes(n)
16
+ array = []
17
+ n.times do
18
+ array << rand(256)
19
+ end
20
+ array.pack('C*')
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,27 @@
1
+
2
+ if ENV['SIMPLE_COV']
3
+ require 'simplecov'
4
+ SimpleCov.start do
5
+ add_filter 'spec/'
6
+ add_filter 'pkg/'
7
+ add_filter 'vendor/'
8
+ end
9
+ end
10
+
11
+ if ENV['GC_STRESS']
12
+ puts "enable GC.stress"
13
+ GC.stress = true
14
+ end
15
+
16
+ require 'msgpack'
17
+
18
+ if /java/ =~ RUBY_PLATFORM
19
+ RSpec.configure do |c|
20
+ c.treat_symbols_as_metadata_keys_with_true_values = true
21
+ c.filter_run_excluding :encodings => !(defined? Encoding)
22
+ end
23
+ else
24
+ Packer = MessagePack::Packer
25
+ Unpacker = MessagePack::Unpacker
26
+ Buffer = MessagePack::Buffer
27
+ end
@@ -0,0 +1,72 @@
1
+ # encoding: ascii-8bit
2
+ require 'spec_helper'
3
+
4
+ require 'stringio'
5
+ if defined?(Encoding)
6
+ Encoding.default_external = 'ASCII-8BIT'
7
+ end
8
+
9
+ describe MessagePack do
10
+ it 'MessagePack.unpack symbolize_keys' do
11
+ symbolized_hash = {:a => 'b', :c => 'd'}
12
+ MessagePack.load(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
13
+ MessagePack.unpack(MessagePack.pack(symbolized_hash), :symbolize_keys => true).should == symbolized_hash
14
+ end
15
+
16
+ it 'Unpacker#unpack symbolize_keys' do
17
+ if /java/ =~ RUBY_PLATFORM
18
+ skip "Unpacker#unpack returns nil in JRuby (incompatible)"
19
+ end
20
+ unpacker = MessagePack::Unpacker.new(:symbolize_keys => true)
21
+ symbolized_hash = {:a => 'b', :c => 'd'}
22
+ unpacker.feed(MessagePack.pack(symbolized_hash)).read.should == symbolized_hash
23
+ end
24
+
25
+ it "msgpack str 8 type" do
26
+ if /java/ =~ RUBY_PLATFORM
27
+ skip "str 8 type is not supported in JRuby (incompatibility)"
28
+ end
29
+ MessagePack.unpack([0xd9, 0x00].pack('C*')).should == ""
30
+ MessagePack.unpack([0xd9, 0x01].pack('C*') + 'a').should == "a"
31
+ MessagePack.unpack([0xd9, 0x02].pack('C*') + 'aa').should == "aa"
32
+ end
33
+
34
+ it "msgpack str 16 type" do
35
+ MessagePack.unpack([0xda, 0x00, 0x00].pack('C*')).should == ""
36
+ MessagePack.unpack([0xda, 0x00, 0x01].pack('C*') + 'a').should == "a"
37
+ MessagePack.unpack([0xda, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
38
+ end
39
+
40
+ it "msgpack str 32 type" do
41
+ MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
42
+ MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
43
+ MessagePack.unpack([0xdb, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
44
+ end
45
+
46
+ it "msgpack bin 8 type" do
47
+ if /java/ =~ RUBY_PLATFORM
48
+ skip "bin 8 type is not supported in JRuby (incompatibility)"
49
+ end
50
+ MessagePack.unpack([0xc4, 0x00].pack('C*')).should == ""
51
+ MessagePack.unpack([0xc4, 0x01].pack('C*') + 'a').should == "a"
52
+ MessagePack.unpack([0xc4, 0x02].pack('C*') + 'aa').should == "aa"
53
+ end
54
+
55
+ it "msgpack bin 16 type" do
56
+ if /java/ =~ RUBY_PLATFORM
57
+ skip "bin 16 type is not supported in JRuby (incompatibility)"
58
+ end
59
+ MessagePack.unpack([0xc5, 0x00, 0x00].pack('C*')).should == ""
60
+ MessagePack.unpack([0xc5, 0x00, 0x01].pack('C*') + 'a').should == "a"
61
+ MessagePack.unpack([0xc5, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
62
+ end
63
+
64
+ it "msgpack bin 32 type" do
65
+ if /java/ =~ RUBY_PLATFORM
66
+ skip "bin 32 type is not supported in JRuby (incompatibility)"
67
+ end
68
+ MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x00].pack('C*')).should == ""
69
+ MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x01].pack('C*') + 'a').should == "a"
70
+ MessagePack.unpack([0xc6, 0x00, 0x00, 0x00, 0x02].pack('C*') + 'aa').should == "aa"
71
+ end
72
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: msgpack
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.10
5
+ platform: java
6
+ authors:
7
+ - Sadayuki Furuhashi
8
+ - Theo Hultberg
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-01-09 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.0'
21
+ requirement: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ version: '1.0'
26
+ prerelease: false
27
+ type: :development
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 0.9.2
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ~>
38
+ - !ruby/object:Gem::Version
39
+ version: 0.9.2
40
+ prerelease: false
41
+ type: :development
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake-compiler
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: 0.8.3
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.8.3
54
+ prerelease: false
55
+ type: :development
56
+ - !ruby/object:Gem::Dependency
57
+ name: rspec
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '2.11'
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ~>
66
+ - !ruby/object:Gem::Version
67
+ version: '2.11'
68
+ prerelease: false
69
+ type: :development
70
+ - !ruby/object:Gem::Dependency
71
+ name: json
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: '1.7'
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ~>
80
+ - !ruby/object:Gem::Version
81
+ version: '1.7'
82
+ prerelease: false
83
+ type: :development
84
+ - !ruby/object:Gem::Dependency
85
+ name: yard
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 0.8.2
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: 0.8.2
96
+ prerelease: false
97
+ type: :development
98
+ description: MessagePack is a binary-based efficient object serialization library. It enables to exchange structured objects between many languages like JSON. But unlike JSON, it is very fast and small.
99
+ email:
100
+ - frsyuki@gmail.com
101
+ - theo@iconara.net
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - lib/msgpack.rb
107
+ - lib/msgpack/version.rb
108
+ - lib/msgpack/msgpack.jar
109
+ - spec/cases.json
110
+ - spec/cases.msg
111
+ - spec/cases_compact.msg
112
+ - spec/cases_spec.rb
113
+ - spec/cruby/buffer_io_spec.rb
114
+ - spec/cruby/buffer_packer.rb
115
+ - spec/cruby/buffer_spec.rb
116
+ - spec/cruby/buffer_unpacker.rb
117
+ - spec/cruby/packer_spec.rb
118
+ - spec/cruby/unpacker_spec.rb
119
+ - spec/format_spec.rb
120
+ - spec/jruby/benchmarks/shootout_bm.rb
121
+ - spec/jruby/benchmarks/symbolize_keys_bm.rb
122
+ - spec/jruby/msgpack/unpacker_spec.rb
123
+ - spec/jruby/msgpack_spec.rb
124
+ - spec/pack_spec.rb
125
+ - spec/random_compat.rb
126
+ - spec/spec_helper.rb
127
+ - spec/unpack_spec.rb
128
+ homepage: http://msgpack.org/
129
+ licenses:
130
+ - Apache 2.0
131
+ metadata: {}
132
+ post_install_message:
133
+ rdoc_options: []
134
+ require_paths:
135
+ - lib
136
+ required_ruby_version: !ruby/object:Gem::Requirement
137
+ requirements:
138
+ - - '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ requirements: []
147
+ rubyforge_project: msgpack
148
+ rubygems_version: 2.1.9
149
+ signing_key:
150
+ specification_version: 4
151
+ summary: MessagePack, a binary-based efficient data interchange format.
152
+ test_files:
153
+ - spec/cases.json
154
+ - spec/cases.msg
155
+ - spec/cases_compact.msg
156
+ - spec/cases_spec.rb
157
+ - spec/cruby/buffer_io_spec.rb
158
+ - spec/cruby/buffer_packer.rb
159
+ - spec/cruby/buffer_spec.rb
160
+ - spec/cruby/buffer_unpacker.rb
161
+ - spec/cruby/packer_spec.rb
162
+ - spec/cruby/unpacker_spec.rb
163
+ - spec/format_spec.rb
164
+ - spec/jruby/benchmarks/shootout_bm.rb
165
+ - spec/jruby/benchmarks/symbolize_keys_bm.rb
166
+ - spec/jruby/msgpack/unpacker_spec.rb
167
+ - spec/jruby/msgpack_spec.rb
168
+ - spec/pack_spec.rb
169
+ - spec/random_compat.rb
170
+ - spec/spec_helper.rb
171
+ - spec/unpack_spec.rb
172
+ has_rdoc: false