zkruby 3.4.4.rc4 → 3.4.4.rc5
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.
- data/lib/zkruby/bindata.rb +21 -12
- data/lib/zkruby/client.rb +1 -1
- data/lib/zkruby/session.rb +1 -1
- data/lib/zkruby/version.rb +1 -1
- data/spec/bindata_spec.rb +42 -0
- data/spec/shared/basic.rb +19 -0
- data/zkruby.gemspec +1 -1
- metadata +8 -5
data/lib/zkruby/bindata.rb
CHANGED
|
@@ -2,22 +2,31 @@
|
|
|
2
2
|
require 'bindata'
|
|
3
3
|
module ZooKeeper
|
|
4
4
|
|
|
5
|
-
class ZKBuffer < BinData::
|
|
6
|
-
int32be :len, :value => lambda { data.nil? ? -1 : data.length }
|
|
7
|
-
string :data, :read_length => :len
|
|
5
|
+
class ZKBuffer < BinData::BasePrimitive
|
|
8
6
|
|
|
9
|
-
def
|
|
10
|
-
|
|
7
|
+
def value_to_binary_string(v)
|
|
8
|
+
vlen = v.nil? ? -1 : v.length
|
|
9
|
+
[ vlen, v ].pack("NA*")
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def read_and_return_value(io)
|
|
13
|
+
vlen = io.readbytes(4).unpack("i!>")[0]
|
|
14
|
+
vlen < 0 ? nil : io.readbytes(vlen)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def sensible_default
|
|
18
|
+
nil
|
|
19
|
+
end
|
|
11
20
|
end
|
|
12
21
|
|
|
13
|
-
class ZKString <
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
class ZKString < ZKBuffer
|
|
23
|
+
def read_and_return_value(io)
|
|
24
|
+
value = super
|
|
25
|
+
value.force_encoding('UTF-8') unless value.nil?
|
|
26
|
+
end
|
|
16
27
|
|
|
17
|
-
def
|
|
18
|
-
|
|
19
|
-
def snapshot
|
|
20
|
-
super.force_encoding('UTF-8')
|
|
28
|
+
def sensible_default
|
|
29
|
+
""
|
|
21
30
|
end
|
|
22
31
|
end
|
|
23
32
|
|
data/lib/zkruby/client.rb
CHANGED
|
@@ -333,7 +333,7 @@ module ZooKeeper
|
|
|
333
333
|
req = Proto::GetDataRequest.new(:path => path, :watch => watch)
|
|
334
334
|
|
|
335
335
|
queue_request(req,:get,4,Proto::GetDataResponse,:data,watch) do | response |
|
|
336
|
-
blk.call( response.stat, response.data.
|
|
336
|
+
blk.call( response.stat, response.data.value)
|
|
337
337
|
end
|
|
338
338
|
end
|
|
339
339
|
|
data/lib/zkruby/session.rb
CHANGED
|
@@ -329,7 +329,7 @@ module ZooKeeper
|
|
|
329
329
|
req = Proto::ConnectRequest.new( :timeout => timeout )
|
|
330
330
|
req.last_zxid_seen = @last_zxid_seen if @last_zxid_seen
|
|
331
331
|
req.session_id = @session_id if @session_id
|
|
332
|
-
req.passwd = @session_passwd
|
|
332
|
+
req.passwd = @session_passwd || ""
|
|
333
333
|
conn.send_records(req)
|
|
334
334
|
end
|
|
335
335
|
|
data/lib/zkruby/version.rb
CHANGED
data/spec/bindata_spec.rb
CHANGED
|
@@ -5,6 +5,48 @@ class ZKBTest < BinData::Record
|
|
|
5
5
|
zk_boolean :bool
|
|
6
6
|
end
|
|
7
7
|
|
|
8
|
+
class ZKBufferTest < BinData::Record
|
|
9
|
+
zk_buffer :buff
|
|
10
|
+
end
|
|
11
|
+
class ZKStringTest < BinData::Record
|
|
12
|
+
zk_string :str
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe ZK::ZKBuffer do
|
|
16
|
+
|
|
17
|
+
it "should read null values" do
|
|
18
|
+
hex = "ffffffff"
|
|
19
|
+
bin = [ hex ].pack("H*")
|
|
20
|
+
|
|
21
|
+
buffer = ZKBufferTest.read(bin)
|
|
22
|
+
|
|
23
|
+
buffer.buff.should == nil
|
|
24
|
+
buffer.buff.value.should be_nil
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should write null values" do
|
|
28
|
+
buffer = ZK::ZKBuffer.new(nil)
|
|
29
|
+
buffer.value.should be_nil
|
|
30
|
+
buffer.to_binary_s.should == [ "ffffffff" ].pack("H*")
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "should read non null values as binary strings"
|
|
34
|
+
it "should write non null values"
|
|
35
|
+
it "should write encoded calues as binary strings"
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe ZK::ZKString do
|
|
39
|
+
it "should produce UTF8 encoded strings" do
|
|
40
|
+
|
|
41
|
+
hex = "000000086162636465666768"
|
|
42
|
+
bin = [ hex ].pack("H*")
|
|
43
|
+
zk_string = ZKStringTest.read(bin)
|
|
44
|
+
zk_string.str.should == "abcdefgh"
|
|
45
|
+
zk_string.str.encoding.name.should == "UTF-8"
|
|
46
|
+
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
8
50
|
describe ZK::ZKBoolean do
|
|
9
51
|
|
|
10
52
|
it "should behave like 'false' after reading 00" do
|
data/spec/shared/basic.rb
CHANGED
|
@@ -37,6 +37,25 @@ shared_examples_for "basic integration" do
|
|
|
37
37
|
@zk.exists?("/zkruby/rspec").should be_false
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
+
it "should differentiate null data from empty strings" do
|
|
41
|
+
path = @zk.create("/zkruby/rspec",nil,ZK::ACL_OPEN_UNSAFE,:ephemeral)
|
|
42
|
+
stat,data = @zk.get(path)
|
|
43
|
+
data.should be_nil
|
|
44
|
+
# this isn't very helpful
|
|
45
|
+
stat.data_length.should == 0
|
|
46
|
+
|
|
47
|
+
@zk.set(path,"",-1)
|
|
48
|
+
stat,data = @zk.get(path)
|
|
49
|
+
data.should == ""
|
|
50
|
+
stat.data_length.should == 0
|
|
51
|
+
|
|
52
|
+
@zk.set(path,nil,-1)
|
|
53
|
+
stat,data = @zk.get(path)
|
|
54
|
+
data.should be_nil
|
|
55
|
+
# this isn't very helpful
|
|
56
|
+
stat.data_length.should == 0
|
|
57
|
+
end
|
|
58
|
+
|
|
40
59
|
it "should accept -1 to delete any version" do
|
|
41
60
|
path = @zk.create("/zkruby/rspec","someData",ZK::ACL_OPEN_UNSAFE,:ephemeral)
|
|
42
61
|
@zk.delete("/zkruby/rspec",-1)
|
data/zkruby.gemspec
CHANGED
|
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
|
|
|
21
21
|
# Yard options in .yardopts
|
|
22
22
|
|
|
23
23
|
s.add_dependency 'slf4r' , '~> 0.4.2'
|
|
24
|
-
s.add_dependency 'bindata', '~> 1.
|
|
24
|
+
s.add_dependency 'bindata', '~> 1.8.2'
|
|
25
25
|
|
|
26
26
|
s.add_development_dependency 'eventmachine', '>= 0.12.10'
|
|
27
27
|
s.add_development_dependency 'empathy', '>=0.1.0'
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: zkruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.4.4.
|
|
4
|
+
version: 3.4.4.rc5
|
|
5
5
|
prerelease: 6
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: slf4r
|
|
@@ -34,7 +34,7 @@ dependencies:
|
|
|
34
34
|
requirements:
|
|
35
35
|
- - ~>
|
|
36
36
|
- !ruby/object:Gem::Version
|
|
37
|
-
version: 1.
|
|
37
|
+
version: 1.8.2
|
|
38
38
|
type: :runtime
|
|
39
39
|
prerelease: false
|
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -42,7 +42,7 @@ dependencies:
|
|
|
42
42
|
requirements:
|
|
43
43
|
- - ~>
|
|
44
44
|
- !ruby/object:Gem::Version
|
|
45
|
-
version: 1.
|
|
45
|
+
version: 1.8.2
|
|
46
46
|
- !ruby/object:Gem::Dependency
|
|
47
47
|
name: eventmachine
|
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -253,6 +253,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
253
253
|
- - ! '>='
|
|
254
254
|
- !ruby/object:Gem::Version
|
|
255
255
|
version: '0'
|
|
256
|
+
segments:
|
|
257
|
+
- 0
|
|
258
|
+
hash: -2894475851857234874
|
|
256
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
260
|
none: false
|
|
258
261
|
requirements:
|
|
@@ -261,7 +264,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
261
264
|
version: 1.3.1
|
|
262
265
|
requirements: []
|
|
263
266
|
rubyforge_project:
|
|
264
|
-
rubygems_version: 1.8.
|
|
267
|
+
rubygems_version: 1.8.23
|
|
265
268
|
signing_key:
|
|
266
269
|
specification_version: 3
|
|
267
270
|
summary: Pure Ruby language binding for ZooKeeper
|