msgpack-jruby 1.3.0-java → 1.3.1-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/.rspec +2 -1
- data/.rvmrc +3 -1
- data/.travis.yml +11 -0
- data/Gemfile +9 -3
- data/Gemfile.lock +8 -0
- data/README.mdown +26 -0
- data/Rakefile +7 -0
- data/ext/java/org/msgpack/jruby/MessagePackLibrary.java +6 -2
- data/lib/msgpack/version.rb +1 -1
- data/spec/msgpack/unpacker_spec.rb +13 -4
- data/spec/msgpack_spec.rb +7 -1
- data/spec/spec_helper.rb +9 -2
- metadata +12 -8
- data/lib/ext/msgpack_jruby.jar +0 -0
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.rvmrc
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
|
3
|
+
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
gem 'rake'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'jruby-openssl'
|
7
9
|
gem 'viiite'
|
8
10
|
gem 'ffi-ncurses'
|
9
11
|
gem 'bson'
|
@@ -11,3 +13,7 @@ group :test do
|
|
11
13
|
gem 'json'
|
12
14
|
gem 'msgpack', :platforms => :mri
|
13
15
|
end
|
16
|
+
|
17
|
+
group :test do
|
18
|
+
gem 'rspec'
|
19
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
msgpack-jruby (1.3.1-java)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: http://rubygems.org/
|
3
8
|
specs:
|
@@ -24,6 +29,7 @@ GEM
|
|
24
29
|
msgpack (0.4.6)
|
25
30
|
myrrha (1.2.1)
|
26
31
|
quickl (0.4.1)
|
32
|
+
rake (10.0.2)
|
27
33
|
rspec (2.6.0)
|
28
34
|
rspec-core (~> 2.6.0)
|
29
35
|
rspec-expectations (~> 2.6.0)
|
@@ -48,5 +54,7 @@ DEPENDENCIES
|
|
48
54
|
jruby-openssl
|
49
55
|
json
|
50
56
|
msgpack
|
57
|
+
msgpack-jruby!
|
58
|
+
rake
|
51
59
|
rspec
|
52
60
|
viiite
|
data/README.mdown
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# MessagePack for JRuby
|
2
|
+
|
3
|
+
A MessagePack implementation for JRuby, built on top of the MessagePack Java libraries. Faster and easier to use than using the C MessagePack gem in JRuby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install msgpack-jruby
|
8
|
+
|
9
|
+
or with Bundler
|
10
|
+
|
11
|
+
gem 'msgpack-jruby', :require => 'msgpack'
|
12
|
+
|
13
|
+
## Extra features
|
14
|
+
|
15
|
+
* Decode keys as symbols by passing `:symbolize_keys => true` to `#unpack`.
|
16
|
+
* Decode strings with their right encoding by passing `:encoding => Encoding::UTF_8` to `#unpack`.
|
17
|
+
|
18
|
+
## Copyright
|
19
|
+
|
20
|
+
Copyright 2012 Theo Hultberg
|
21
|
+
|
22
|
+
_Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License You may obtain a copy of the License at_
|
23
|
+
|
24
|
+
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
|
25
|
+
|
26
|
+
_Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License._
|
data/Rakefile
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
$: << 'lib'
|
2
2
|
|
3
3
|
require 'bundler/setup'
|
4
|
+
require 'rspec/core/rake_task'
|
4
5
|
require 'msgpack/version'
|
5
6
|
|
6
7
|
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec)
|
11
|
+
|
12
|
+
task :spec => :package
|
13
|
+
|
7
14
|
task :clean do
|
8
15
|
rm Dir['ext/java/**/*.class']
|
9
16
|
end
|
@@ -89,6 +89,7 @@ public class MessagePackLibrary implements Library {
|
|
89
89
|
private RubyObjectUnpacker rubyObjectUnpacker;
|
90
90
|
private MessagePackBufferUnpacker bufferUnpacker;
|
91
91
|
private MessagePackUnpacker streamUnpacker;
|
92
|
+
private UnpackerIterator unpackerIterator;
|
92
93
|
private IRubyObject stream;
|
93
94
|
private IRubyObject data;
|
94
95
|
private RubyObjectUnpacker.CompiledOptions options;
|
@@ -165,6 +166,7 @@ public class MessagePackLibrary implements Library {
|
|
165
166
|
byte[] bytes = data.asString().getBytes();
|
166
167
|
if (bufferUnpacker == null) {
|
167
168
|
bufferUnpacker = new MessagePackBufferUnpacker(msgPack);
|
169
|
+
unpackerIterator = bufferUnpacker.iterator();
|
168
170
|
}
|
169
171
|
bufferUnpacker.feed(bytes);
|
170
172
|
return ctx.getRuntime().getNil();
|
@@ -188,7 +190,8 @@ public class MessagePackLibrary implements Library {
|
|
188
190
|
return ctx.getRuntime().getNil();
|
189
191
|
}
|
190
192
|
if (block.isGiven()) {
|
191
|
-
|
193
|
+
while (unpackerIterator.hasNext()) {
|
194
|
+
Value value = unpackerIterator.next();
|
192
195
|
IRubyObject rubyObject = rubyObjectUnpacker.valueToRubyObject(ctx.getRuntime(), value, options);
|
193
196
|
block.yield(ctx, rubyObject);
|
194
197
|
}
|
@@ -235,7 +238,8 @@ public class MessagePackLibrary implements Library {
|
|
235
238
|
} else {
|
236
239
|
streamUnpacker = new MessagePackUnpacker(msgPack, new IOInputStream(stream));
|
237
240
|
}
|
241
|
+
unpackerIterator = streamUnpacker.iterator();
|
238
242
|
return getStream(ctx);
|
239
243
|
}
|
240
244
|
}
|
241
|
-
}
|
245
|
+
}
|
data/lib/msgpack/version.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# encoding: ascii-8bit
|
2
2
|
|
3
|
-
require_relative '../spec_helper'
|
4
3
|
require 'stringio'
|
5
4
|
require 'tempfile'
|
5
|
+
require 'spec_helper'
|
6
6
|
|
7
7
|
|
8
8
|
describe ::MessagePack::Unpacker do
|
@@ -130,6 +130,17 @@ describe ::MessagePack::Unpacker do
|
|
130
130
|
end
|
131
131
|
objects.should == [{'foo' => 'bar'}, {'hello' => {'world' => [1, 2, 3]}}, {'x' => 'y'}]
|
132
132
|
end
|
133
|
+
|
134
|
+
it 'handles chunked data' do
|
135
|
+
objects = []
|
136
|
+
buffer = buffer1 + buffer2 + buffer3
|
137
|
+
buffer.chars.each do |ch|
|
138
|
+
subject.feed_each(ch) do |obj|
|
139
|
+
objects << obj
|
140
|
+
end
|
141
|
+
end
|
142
|
+
objects.should == [{'foo' => 'bar'}, {'hello' => {'world' => [1, 2, 3]}}, {'x' => 'y'}]
|
143
|
+
end
|
133
144
|
end
|
134
145
|
|
135
146
|
describe '#fill' do
|
@@ -190,8 +201,7 @@ describe ::MessagePack::Unpacker do
|
|
190
201
|
end
|
191
202
|
end
|
192
203
|
|
193
|
-
context 'encoding' do
|
194
|
-
|
204
|
+
context 'encoding', :encodings do
|
195
205
|
def flatten(struct, results = [])
|
196
206
|
case struct
|
197
207
|
when Array
|
@@ -240,6 +250,5 @@ describe ::MessagePack::Unpacker do
|
|
240
250
|
strings.map(&:encoding).uniq.should == [Encoding::UTF_8]
|
241
251
|
end
|
242
252
|
end
|
243
|
-
|
244
253
|
end
|
245
254
|
end
|
data/spec/msgpack_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: ascii-8bit
|
2
2
|
|
3
|
-
|
3
|
+
require 'spec_helper'
|
4
4
|
|
5
5
|
|
6
6
|
describe MessagePack do
|
@@ -85,5 +85,11 @@ describe MessagePack do
|
|
85
85
|
unpacked = MessagePack.unpack(packed, :symbolize_keys => true)
|
86
86
|
unpacked.should == {:hello => 'world', :nested => ['object', {:structure => true}]}
|
87
87
|
end
|
88
|
+
|
89
|
+
it 'can unpack strings with a specified encoding', :encodings do
|
90
|
+
packed = MessagePack.pack({'hello' => 'world'})
|
91
|
+
unpacked = MessagePack.unpack(packed, :encoding => Encoding::UTF_8)
|
92
|
+
unpacked['hello'].encoding.should == Encoding::UTF_8
|
93
|
+
end
|
88
94
|
end
|
89
95
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
-
|
1
|
+
# encoding: utf-8
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'msgpack'
|
5
|
+
|
6
|
+
|
7
|
+
RSpec.configure do |c|
|
8
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
9
|
+
c.filter_run_excluding :encodings => !(defined? Encoding)
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: msgpack-jruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: JRuby compatible MessagePack implementation that does not use FFI
|
15
15
|
email:
|
@@ -18,11 +18,13 @@ executables: []
|
|
18
18
|
extensions: []
|
19
19
|
extra_rdoc_files: []
|
20
20
|
files:
|
21
|
-
- .gitignore
|
22
|
-
- .rspec
|
23
|
-
- .rvmrc
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rvmrc"
|
24
|
+
- ".travis.yml"
|
24
25
|
- Gemfile
|
25
26
|
- Gemfile.lock
|
27
|
+
- README.mdown
|
26
28
|
- Rakefile
|
27
29
|
- ext/.gitignore
|
28
30
|
- ext/java/MsgpackJrubyService.java
|
@@ -31,7 +33,6 @@ files:
|
|
31
33
|
- ext/java/org/msgpack/jruby/RubyObjectUnpacker.java
|
32
34
|
- lib/ext/javassist-3.15.0-GA.jar
|
33
35
|
- lib/ext/msgpack-0.6.6.jar
|
34
|
-
- lib/ext/msgpack_jruby.jar
|
35
36
|
- lib/msgpack.rb
|
36
37
|
- lib/msgpack/version.rb
|
37
38
|
- msgpack-jruby.gemspec
|
@@ -48,7 +49,7 @@ require_paths:
|
|
48
49
|
- lib
|
49
50
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
51
|
requirements:
|
51
|
-
- -
|
52
|
+
- - ">="
|
52
53
|
- !ruby/object:Gem::Version
|
53
54
|
segments:
|
54
55
|
- 0
|
@@ -58,10 +59,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
59
|
none: false
|
59
60
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
61
|
requirements:
|
61
|
-
- -
|
62
|
+
- - ">="
|
62
63
|
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
63
66
|
version: !binary |-
|
64
67
|
MA==
|
68
|
+
hash: 2
|
65
69
|
none: false
|
66
70
|
requirements: []
|
67
71
|
rubyforge_project: msgpack-jruby
|
data/lib/ext/msgpack_jruby.jar
DELETED
Binary file
|