diplomat 0.16.1 → 0.16.2
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.
- checksums.yaml +4 -4
- data/lib/diplomat/kv.rb +4 -0
- data/lib/diplomat/rest_client.rb +19 -12
- data/lib/diplomat/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0ba37ba0f0744c7b424c81b524cd86c6c14d3284
|
|
4
|
+
data.tar.gz: a61b033018328f55d8c4ce894c10fe675fbab896
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3155ef8a9a9eaad49cfacc57fc2beffc603f73213aa0212576a5b3d77fdc0c73a5722414939a6b82824b7210f06aa3cfa1c531895b2e5565f9c3b7a8811a5599
|
|
7
|
+
data.tar.gz: d0ec12eb626632ae3135cf795fed79317202820884f1064a74d6c15d065c5af402c31a7d2a8f1436d460b3532c7647c4df5eac7d1f4209f8f88d89561f16228e
|
data/lib/diplomat/kv.rb
CHANGED
|
@@ -17,6 +17,7 @@ module Diplomat
|
|
|
17
17
|
# @option options [String] :dc Target datacenter
|
|
18
18
|
# @option options [Boolean] :keys Only return key names.
|
|
19
19
|
# @option options [Boolean] :modify_index Only return ModifyIndex value.
|
|
20
|
+
# @option options [Boolean] :decode_values Return consul response with decoded values.
|
|
20
21
|
# @option options [String] :separator List only up to a given separator. Only applies when combined with :keys option.
|
|
21
22
|
# @option options [Boolean] :nil_values If to return keys/dirs with nil values
|
|
22
23
|
# @param not_found [Symbol] behaviour if the key doesn't exist;
|
|
@@ -75,6 +76,9 @@ module Diplomat
|
|
|
75
76
|
if @options and @options[:modify_index]
|
|
76
77
|
return @raw.first['ModifyIndex']
|
|
77
78
|
end
|
|
79
|
+
if @options and @options[:decode_values]
|
|
80
|
+
return decode_values
|
|
81
|
+
end
|
|
78
82
|
return return_value(return_nil_values)
|
|
79
83
|
when :wait
|
|
80
84
|
index = raw.headers["x-consul-index"]
|
data/lib/diplomat/rest_client.rb
CHANGED
|
@@ -74,21 +74,28 @@ module Diplomat
|
|
|
74
74
|
@raw = JSON.parse(@raw.body)
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
+
# Return @raw with Value fields decoded
|
|
78
|
+
def decode_values
|
|
79
|
+
return @raw if @raw.first.is_a? String
|
|
80
|
+
@raw.inject([]) do |acc, el|
|
|
81
|
+
new_el = el.dup
|
|
82
|
+
new_el["Value"] = (Base64.decode64(el["Value"]) rescue nil)
|
|
83
|
+
acc << new_el
|
|
84
|
+
acc
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
77
88
|
# Get the key/value(s) from the raw output
|
|
78
89
|
def return_value(nil_values=false)
|
|
79
|
-
|
|
80
|
-
if @
|
|
81
|
-
@value
|
|
82
|
-
|
|
90
|
+
@value = decode_values
|
|
91
|
+
if @value.first.is_a? String
|
|
92
|
+
return @value
|
|
93
|
+
elsif @value.count == 1
|
|
94
|
+
@value.first["Value"]
|
|
83
95
|
else
|
|
84
|
-
@value = @
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
:key => e["Key"],
|
|
88
|
-
:value => val
|
|
89
|
-
} if val or nil_values
|
|
90
|
-
acc
|
|
91
|
-
end
|
|
96
|
+
@value = @value.map do |el|
|
|
97
|
+
{ :key => el["Key"], :value => el["Value"] } if el["Value"] or nil_values
|
|
98
|
+
end.compact
|
|
92
99
|
end
|
|
93
100
|
end
|
|
94
101
|
|
data/lib/diplomat/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: diplomat
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.16.
|
|
4
|
+
version: 0.16.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Hamelink
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-04-
|
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -140,16 +140,16 @@ dependencies:
|
|
|
140
140
|
name: json
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
142
142
|
requirements:
|
|
143
|
-
- - "
|
|
143
|
+
- - ">="
|
|
144
144
|
- !ruby/object:Gem::Version
|
|
145
|
-
version: '
|
|
145
|
+
version: '0'
|
|
146
146
|
type: :runtime
|
|
147
147
|
prerelease: false
|
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
|
149
149
|
requirements:
|
|
150
|
-
- - "
|
|
150
|
+
- - ">="
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
|
-
version: '
|
|
152
|
+
version: '0'
|
|
153
153
|
- !ruby/object:Gem::Dependency
|
|
154
154
|
name: faraday
|
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|