java_bin 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/README.rdoc +0 -1
- data/VERSION +1 -1
- data/ext/java_bin/ext/parser.c +11 -9
- data/ext/java_bin/ext/parser.h +10 -0
- data/how_to_release.txt +14 -0
- data/java_bin.gemspec +7 -6
- data/lib/java_bin/version.rb +1 -1
- data/test/test_java_bin_parser.rb +15 -3
- metadata +20 -7
data/CHANGELOG
CHANGED
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.5
|
data/ext/java_bin/ext/parser.c
CHANGED
@@ -8,6 +8,7 @@ static VALUE rb_mExt;
|
|
8
8
|
static VALUE rb_cParser;
|
9
9
|
|
10
10
|
static ID i_At; // Time#at用
|
11
|
+
static ID i_Utc; // Time#utc用
|
11
12
|
#ifdef HAVE_RUBY_ENCODING_H
|
12
13
|
static rb_encoding* rb_encUtf8;
|
13
14
|
#endif
|
@@ -183,21 +184,21 @@ static inline VALUE JavaBinParser_read_date(JAVA_BIN_PARSER* ptr) {
|
|
183
184
|
u_int64_t c;
|
184
185
|
_readnumeric(ptr, c);
|
185
186
|
c = _swap_64(c);
|
186
|
-
return rb_funcall(rb_cTime, i_At, 1, ULL2NUM(c / 1000));
|
187
|
+
return rb_funcall(rb_funcall(rb_cTime, i_At, 1, ULL2NUM(c / 1000)), i_Utc, 0);
|
187
188
|
}
|
188
189
|
|
189
190
|
static inline VALUE JavaBinParser_read_float(JAVA_BIN_PARSER* ptr) {
|
190
|
-
|
191
|
-
_readnumeric(ptr, c);
|
192
|
-
c = _swap_32(c);
|
193
|
-
return rb_float_new((double)
|
191
|
+
JAVA_BIN_FLOAT c;
|
192
|
+
_readnumeric(ptr, c.i_value);
|
193
|
+
c.i_value = _swap_32(c.i_value);
|
194
|
+
return rb_float_new((double)c.f_value);
|
194
195
|
}
|
195
196
|
|
196
197
|
static inline VALUE JavaBinParser_read_double(JAVA_BIN_PARSER* ptr) {
|
197
|
-
|
198
|
-
_readnumeric(ptr, c);
|
199
|
-
c = _swap_64(c);
|
200
|
-
return rb_float_new(
|
198
|
+
JAVA_BIN_DOUBLE c;
|
199
|
+
_readnumeric(ptr, c.i_value);
|
200
|
+
c.i_value = _swap_64(c.i_value);
|
201
|
+
return rb_float_new(c.d_value);
|
201
202
|
}
|
202
203
|
|
203
204
|
static inline VALUE JavaBinParser_read_byte_array(JAVA_BIN_PARSER* ptr) {
|
@@ -396,6 +397,7 @@ static VALUE JavaBinParser_alloc(VALUE klass) {
|
|
396
397
|
*/
|
397
398
|
void Init_parser(void) {
|
398
399
|
i_At = rb_intern("at");
|
400
|
+
i_Utc = rb_intern("utc");
|
399
401
|
#ifdef HAVE_RUBY_ENCODING_H
|
400
402
|
rb_encUtf8 = rb_utf8_encoding();
|
401
403
|
#endif
|
data/ext/java_bin/ext/parser.h
CHANGED
@@ -111,6 +111,16 @@ typedef struct java_bin_parser {
|
|
111
111
|
typedef unsigned __int64 u_int64_t;
|
112
112
|
#endif
|
113
113
|
|
114
|
+
typedef union java_bin_float {
|
115
|
+
float f_value;
|
116
|
+
u_int32_t i_value;
|
117
|
+
} JAVA_BIN_FLOAT;
|
118
|
+
|
119
|
+
typedef union java_bin_double {
|
120
|
+
double d_value;
|
121
|
+
u_int64_t i_value;
|
122
|
+
} JAVA_BIN_DOUBLE;
|
123
|
+
|
114
124
|
static VALUE JavaBinParser_read_val(JAVA_BIN_PARSER* ptr);
|
115
125
|
|
116
126
|
static void JavaBinParser_free(JAVA_BIN_PARSER* ptr);
|
data/how_to_release.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
* rake
|
2
|
+
* JavaBin=pure rake
|
3
|
+
* vim CHANGELOG
|
4
|
+
* vim README.rdoc
|
5
|
+
* vim lib/java_bin/version.rb
|
6
|
+
* rake version:bump:patch
|
7
|
+
* rake gemspec
|
8
|
+
* git commit -a -m "release x.x.x"
|
9
|
+
* git tag vx.x.x
|
10
|
+
* git push
|
11
|
+
* git push --tags
|
12
|
+
* rake gemcutter:release
|
13
|
+
|
14
|
+
|
data/java_bin.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{java_bin}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["kennyj"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-22}
|
13
13
|
s.description = %q{Apache Solr JavaBin format (binary format) implementation for Ruby.}
|
14
14
|
s.email = %q{kennyj@gmail.com}
|
15
15
|
s.extensions = ["ext/java_bin/ext/extconf.rb"]
|
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
|
|
35
35
|
"fixtures/json2.dat",
|
36
36
|
"fixtures/ruby.dat",
|
37
37
|
"fixtures/ruby2.dat",
|
38
|
+
"how_to_release.txt",
|
38
39
|
"java_bin.gemspec",
|
39
40
|
"lib/java_bin.rb",
|
40
41
|
"lib/java_bin/ext.rb",
|
@@ -51,19 +52,19 @@ Gem::Specification.new do |s|
|
|
51
52
|
s.homepage = %q{http://github.com/kennyj/java_bin}
|
52
53
|
s.rdoc_options = ["--charset=UTF-8"]
|
53
54
|
s.require_paths = ["lib", "ext"]
|
54
|
-
s.rubygems_version = %q{1.3.
|
55
|
+
s.rubygems_version = %q{1.3.7}
|
55
56
|
s.summary = %q{Apache Solr JavaBin format implementation for Ruby.}
|
56
57
|
s.test_files = [
|
57
|
-
"test/
|
58
|
+
"test/helper.rb",
|
58
59
|
"test/xxx_performance.rb",
|
59
|
-
"test/
|
60
|
+
"test/test_java_bin_parser.rb"
|
60
61
|
]
|
61
62
|
|
62
63
|
if s.respond_to? :specification_version then
|
63
64
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
64
65
|
s.specification_version = 3
|
65
66
|
|
66
|
-
if Gem::Version.new(Gem::
|
67
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
67
68
|
else
|
68
69
|
end
|
69
70
|
else
|
data/lib/java_bin/version.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'stringio'
|
4
4
|
require 'helper'
|
5
|
+
require 'time'
|
5
6
|
|
6
7
|
case ENV['JavaBin']
|
7
8
|
when 'pure'
|
@@ -67,7 +68,9 @@ class TestJavaBinParser < Test::Unit::TestCase
|
|
67
68
|
result = @parser.parse(open("fixtures/javabin.dat", READ_ASCII).read)
|
68
69
|
assert result['response']['docs'][0]['features'].include?('eaiou with umlauts: ëäïöü')
|
69
70
|
assert_equal result['response']['docs'][1]['incubationdate_dt'], Time.local(2006, 1, 17, 9, 0, 0)
|
70
|
-
|
71
|
+
assert_in_delta result['response']['maxScore'], 0.6288448, 0.0001
|
72
|
+
assert_in_delta result['response']['docs'][0]['score'], 0.628844797611237, 0.0001
|
73
|
+
assert_in_delta result['response']['docs'][1]['score'], 0.5030758380889893, 0.0001
|
71
74
|
end
|
72
75
|
|
73
76
|
def test_javabin2_dat
|
@@ -75,7 +78,12 @@ class TestJavaBinParser < Test::Unit::TestCase
|
|
75
78
|
assert_equal 19, result['response']['docs'].size
|
76
79
|
end
|
77
80
|
|
78
|
-
|
81
|
+
def test_javabin_parse_and_ruby_eval_with_time
|
82
|
+
r = eval(open("fixtures/ruby.dat", READ_UTF8).read)
|
83
|
+
jb = @parser.parse(open("fixtures/javabin.dat", READ_ASCII).read)
|
84
|
+
assert_equal Time.xmlschema(r['response']['docs'][1]['incubationdate_dt']), jb['response']['docs'][1]['incubationdate_dt']
|
85
|
+
end
|
86
|
+
|
79
87
|
TIMES = 5000
|
80
88
|
def test_javabin_parse_and_ruby_eval
|
81
89
|
r = open("fixtures/ruby.dat", READ_UTF8).read
|
@@ -135,6 +143,8 @@ class TestJavaBinParser < Test::Unit::TestCase
|
|
135
143
|
|
136
144
|
def test_double
|
137
145
|
assert_equal -1.0, @parser.parse([1, 5, -1.0].pack("C2G"))
|
146
|
+
assert_equal 1.0, @parser.parse([1, 5, 1.0].pack("C2G"))
|
147
|
+
assert_equal 0.0, @parser.parse([1, 5, 0.0].pack("C2G"))
|
138
148
|
end
|
139
149
|
|
140
150
|
def test_int
|
@@ -152,8 +162,10 @@ class TestJavaBinParser < Test::Unit::TestCase
|
|
152
162
|
end
|
153
163
|
|
154
164
|
def test_float
|
165
|
+
assert_equal 0.0, @parser.parse([1, 8, 0.0].pack("C2g"))
|
166
|
+
assert_equal 1.0, @parser.parse([1, 8, 1.0].pack("C2g"))
|
155
167
|
assert_equal -1.0, @parser.parse([1, 8, -1.0].pack("C2g"))
|
156
|
-
|
168
|
+
end
|
157
169
|
|
158
170
|
def test_date
|
159
171
|
t = Time.now
|
metadata
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: java_bin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
- 5
|
10
|
+
version: 0.3.5
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
13
|
- kennyj
|
@@ -9,7 +15,7 @@ autorequire:
|
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-05-22 00:00:00 +09:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -40,6 +46,7 @@ files:
|
|
40
46
|
- fixtures/json2.dat
|
41
47
|
- fixtures/ruby.dat
|
42
48
|
- fixtures/ruby2.dat
|
49
|
+
- how_to_release.txt
|
43
50
|
- java_bin.gemspec
|
44
51
|
- lib/java_bin.rb
|
45
52
|
- lib/java_bin/ext.rb
|
@@ -63,25 +70,31 @@ require_paths:
|
|
63
70
|
- lib
|
64
71
|
- ext
|
65
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
66
74
|
requirements:
|
67
75
|
- - ">="
|
68
76
|
- !ruby/object:Gem::Version
|
77
|
+
hash: 3
|
78
|
+
segments:
|
79
|
+
- 0
|
69
80
|
version: "0"
|
70
|
-
version:
|
71
81
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
72
83
|
requirements:
|
73
84
|
- - ">="
|
74
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
75
89
|
version: "0"
|
76
|
-
version:
|
77
90
|
requirements: []
|
78
91
|
|
79
92
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.3.
|
93
|
+
rubygems_version: 1.3.7
|
81
94
|
signing_key:
|
82
95
|
specification_version: 3
|
83
96
|
summary: Apache Solr JavaBin format implementation for Ruby.
|
84
97
|
test_files:
|
85
|
-
- test/test_java_bin_parser.rb
|
86
|
-
- test/xxx_performance.rb
|
87
98
|
- test/helper.rb
|
99
|
+
- test/xxx_performance.rb
|
100
|
+
- test/test_java_bin_parser.rb
|