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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 53d62af2e149701f6286454279bc9a3c0926f8fe
4
- data.tar.gz: fddfe20acb8c854bce8978cf42f5a8454015ac2f
3
+ metadata.gz: e83acc597055a875d20c92d037fb992d0166273b
4
+ data.tar.gz: 0cb9e70c5cc7b9130f681e7cbbc3fb126f195304
5
5
  SHA512:
6
- metadata.gz: abd6b9d7abf264cc78177280166a03e6fa46b390a479d8eb33a73b4f6b249a87899d1b8479a0571dd529eef756789e4aa4ace209ab24c45aae11fcd02b679257
7
- data.tar.gz: 754a8d03f0cd1be7ab4bcc4a09960e503a530bb2617888bc0494313f0f28a28c68ffa3d63ad615357d3baffc774a36a02a1074aa30ab881b5f5df48e5e3fa024
6
+ metadata.gz: 5e11dac52b461cb60a837a9483adf82b5dcd5ef258bd1fd7f5e3100e3e338dde029c1225bdc8721a446aa488a2511ef91b32869cafe06c6c240e29cd5fc60c31
7
+ data.tar.gz: 9582f130e14f81ae57af645d0d317819afe0f522385b4972742dde16d2b9353a36c21b3b8aa263c313d7e60bfa4d384b34227bfdd563d8546fa91436065f2dce
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
 
3
3
  group :test do
4
4
  gem "shoulda"
@@ -1,35 +1,34 @@
1
1
  GEM
2
- remote: http://rubygems.org/
2
+ remote: https://rubygems.org/
3
3
  specs:
4
- activesupport (3.2.13)
5
- i18n (= 0.6.1)
6
- multi_json (~> 1.0)
7
- atomic (1.0.2)
8
- bourne (1.4.0)
9
- mocha (~> 0.13.2)
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.1)
12
- metaclass (0.0.1)
13
- mocha (0.13.3)
14
- metaclass (~> 0.0.1)
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 (>= 0.1.1)
20
+ sync_attr (>= 1.0)
22
21
  thread_safe (>= 0.1.0)
23
- shoulda (3.4.0)
22
+ shoulda (3.5.0)
24
23
  shoulda-context (~> 1.0, >= 1.0.1)
25
- shoulda-matchers (~> 1.0, >= 1.4.1)
26
- shoulda-context (1.1.0)
27
- shoulda-matchers (1.5.6)
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
- bourne (~> 1.3)
30
- sync_attr (0.1.1)
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
@@ -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 unless value
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))
@@ -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.walk(key) do |key, value, revision|
166
- block.call(relative_key(key), @deserializer.deserialize(value))
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 full key given a relative key
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, @deserializer.deserialize(node.value), node.rev)
318
+ changed(key, @deserializer.deserialize(node.value), node.rev)
314
319
  when 8
315
320
  deleted(key, node.rev)
316
321
  else
@@ -1,3 +1,3 @@
1
1
  module RubyDoozer #:nodoc
2
- VERSION = "0.7.1"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -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 15:10:58 -0400\",\"false\":\"false\",\"true\":\"true\",\"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 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.7.1
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-04-05 00:00:00.000000000 Z
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.2
141
+ rubygems_version: 2.0.3
142
142
  signing_key:
143
143
  specification_version: 4
144
144
  summary: Doozer Ruby Client