ruby_doozer 0.7.1 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +20 -21
- data/lib/ruby_doozer/client.rb +2 -1
- data/lib/ruby_doozer/json/deserializer.rb +1 -1
- data/lib/ruby_doozer/registry.rb +10 -5
- data/lib/ruby_doozer/version.rb +1 -1
- data/test/registry_test.rb +3 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e83acc597055a875d20c92d037fb992d0166273b
|
4
|
+
data.tar.gz: 0cb9e70c5cc7b9130f681e7cbbc3fb126f195304
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e11dac52b461cb60a837a9483adf82b5dcd5ef258bd1fd7f5e3100e3e338dde029c1225bdc8721a446aa488a2511ef91b32869cafe06c6c240e29cd5fc60c31
|
7
|
+
data.tar.gz: 9582f130e14f81ae57af645d0d317819afe0f522385b4972742dde16d2b9353a36c21b3b8aa263c313d7e60bfa4d384b34227bfdd563d8546fa91436065f2dce
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,35 +1,34 @@
|
|
1
1
|
GEM
|
2
|
-
remote:
|
2
|
+
remote: https://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (
|
5
|
-
i18n (
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
activesupport (4.0.0)
|
5
|
+
i18n (~> 0.6, >= 0.6.4)
|
6
|
+
minitest (~> 4.2)
|
7
|
+
multi_json (~> 1.3)
|
8
|
+
thread_safe (~> 0.1)
|
9
|
+
tzinfo (~> 0.3.37)
|
10
|
+
atomic (1.1.10)
|
10
11
|
gene_pool (1.3.0)
|
11
|
-
i18n (0.6.
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
multi_json (1.7.2)
|
16
|
-
rake (10.0.4)
|
12
|
+
i18n (0.6.4)
|
13
|
+
minitest (4.7.5)
|
14
|
+
multi_json (1.7.7)
|
15
|
+
rake (10.1.0)
|
17
16
|
resilient_socket (0.5.0)
|
18
17
|
semantic_logger (>= 2.1)
|
19
18
|
ruby_protobuf (0.4.11)
|
20
19
|
semantic_logger (2.1.0)
|
21
|
-
sync_attr (>=
|
20
|
+
sync_attr (>= 1.0)
|
22
21
|
thread_safe (>= 0.1.0)
|
23
|
-
shoulda (3.
|
22
|
+
shoulda (3.5.0)
|
24
23
|
shoulda-context (~> 1.0, >= 1.0.1)
|
25
|
-
shoulda-matchers (
|
26
|
-
shoulda-context (1.1.
|
27
|
-
shoulda-matchers (
|
24
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
25
|
+
shoulda-context (1.1.4)
|
26
|
+
shoulda-matchers (2.2.0)
|
28
27
|
activesupport (>= 3.0.0)
|
29
|
-
|
30
|
-
|
31
|
-
thread_safe (0.1.0)
|
28
|
+
sync_attr (1.0.0)
|
29
|
+
thread_safe (0.1.2)
|
32
30
|
atomic
|
31
|
+
tzinfo (0.3.37)
|
33
32
|
|
34
33
|
PLATFORMS
|
35
34
|
ruby
|
data/lib/ruby_doozer/client.rb
CHANGED
@@ -156,6 +156,7 @@ module RubyDoozer
|
|
156
156
|
walk('/ctl/node/*/addr') do |path, value, revision|
|
157
157
|
hosts << value unless hosts.include? value
|
158
158
|
end
|
159
|
+
hosts
|
159
160
|
end
|
160
161
|
|
161
162
|
# Wait for changes to the supplied path
|
@@ -229,4 +230,4 @@ module RubyDoozer
|
|
229
230
|
end
|
230
231
|
|
231
232
|
end
|
232
|
-
end
|
233
|
+
end
|
@@ -6,7 +6,7 @@ module RubyDoozer
|
|
6
6
|
# Deserialize from JSON entries in Doozer
|
7
7
|
module Deserializer
|
8
8
|
def self.deserialize(value)
|
9
|
-
return nil
|
9
|
+
return value if value.nil? || (value == '')
|
10
10
|
|
11
11
|
if value.strip.start_with?('{') || value.strip.start_with?('[{')
|
12
12
|
symbolize(MultiJson.load(value))
|
data/lib/ruby_doozer/registry.rb
CHANGED
@@ -83,7 +83,7 @@ module RubyDoozer
|
|
83
83
|
# Maximum size of the connection pool to doozer
|
84
84
|
# Default: 10
|
85
85
|
#
|
86
|
-
def initialize(params)
|
86
|
+
def initialize(params, &block)
|
87
87
|
params = params.dup
|
88
88
|
@root = params.delete(:root) || params.delete(:root_path)
|
89
89
|
raise "Missing mandatory parameter :root" unless @root
|
@@ -120,6 +120,10 @@ module RubyDoozer
|
|
120
120
|
RubyDoozer::Client.new(@doozer_config)
|
121
121
|
end
|
122
122
|
|
123
|
+
# Go through entire registry based on the supplied root path passing
|
124
|
+
# all the values to supplied block
|
125
|
+
each_pair(&block) if block
|
126
|
+
|
123
127
|
# Generate warning log entries for any unknown configuration options
|
124
128
|
params.each_pair {|k,v| logger.warn "Ignoring unknown configuration option: #{k}"}
|
125
129
|
end
|
@@ -162,8 +166,9 @@ module RubyDoozer
|
|
162
166
|
def each_pair(&block)
|
163
167
|
key = "#{@root}/**"
|
164
168
|
doozer_pool.with_connection do |doozer|
|
165
|
-
doozer.
|
166
|
-
|
169
|
+
current_revision = doozer.current_revision
|
170
|
+
doozer.walk(key, current_revision) do |key, value, revision|
|
171
|
+
block.call(relative_key(key), @deserializer.deserialize(value), revision)
|
167
172
|
end
|
168
173
|
end
|
169
174
|
end
|
@@ -250,7 +255,7 @@ module RubyDoozer
|
|
250
255
|
"#{@root}/#{relative_key}"
|
251
256
|
end
|
252
257
|
|
253
|
-
# Returns the
|
258
|
+
# Returns the relative key given a full key
|
254
259
|
def relative_key(full_key)
|
255
260
|
full_key.sub(@root_with_trail, '')
|
256
261
|
end
|
@@ -310,7 +315,7 @@ module RubyDoozer
|
|
310
315
|
|
311
316
|
case node.flags
|
312
317
|
when 4
|
313
|
-
changed(key,
|
318
|
+
changed(key, @deserializer.deserialize(node.value), node.rev)
|
314
319
|
when 8
|
315
320
|
deleted(key, node.rev)
|
316
321
|
else
|
data/lib/ruby_doozer/version.rb
CHANGED
data/test/registry_test.rb
CHANGED
@@ -18,7 +18,7 @@ class RegistryTest < Test::Unit::TestCase
|
|
18
18
|
context RubyDoozer::Registry do
|
19
19
|
setup do
|
20
20
|
@date = Date.parse('2013-04-04')
|
21
|
-
@time = Time.at(1365102658)
|
21
|
+
@time = Time.at(1365102658).utc
|
22
22
|
@test_data = {
|
23
23
|
'bar' => 'test',
|
24
24
|
'one' => 'one',
|
@@ -49,7 +49,7 @@ class RegistryTest < Test::Unit::TestCase
|
|
49
49
|
'false' => 'false',
|
50
50
|
'true' => 'true',
|
51
51
|
'child' => "{\":symbol_with_underscores\":\":and_a_value\",\":this\":\"is\",\":an\":[\"array\",\":symbol\",{\":smallest\":{\"a\":\"b\",\":c\":\":d\"}}]}",
|
52
|
-
'all_types' => "{\"bar\":\"test\",\"one\":\"one\",\"string_with_underscores\":\"and_a_value\",\"two\":\":two\",\"integer\":\"10\",\"float\":\"10.5\",\"date\":\"2013-04-04\",\"time\":\"2013-04-04
|
52
|
+
'all_types' => "{\"bar\":\"test\",\"one\":\"one\",\"string_with_underscores\":\"and_a_value\",\"two\":\":two\",\"integer\":\"10\",\"float\":\"10.5\",\"date\":\"2013-04-04\",\"time\":\"2013-04-04 19:10:58 UTC\",\"false\":\"false\",\"true\":\"true\",\"child\":{\":symbol_with_underscores\":\":and_a_value\",\":this\":\"is\",\":an\":[\"array\",\":symbol\",{\":smallest\":{\"a\":\"b\",\":c\":\":d\"}}]}}"
|
53
53
|
}
|
54
54
|
end
|
55
55
|
|
@@ -190,4 +190,4 @@ class RegistryTest < Test::Unit::TestCase
|
|
190
190
|
end
|
191
191
|
end
|
192
192
|
|
193
|
-
end
|
193
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_doozer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Reid Morrison
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: semantic_logger
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.0.
|
141
|
+
rubygems_version: 2.0.3
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: Doozer Ruby Client
|