diplomat 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/diplomat/kv.rb +27 -11
- data/lib/diplomat/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69084b2a7f479ac63674df3d9886edeb576d6df6
|
4
|
+
data.tar.gz: b3d8de26ba454bf168fb02a6f1e197508e4501be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 405fa1f5d83f6b484257395ddc63d7df04a66a0651a5d74229bde9768cb12a9ef7cc40529bbc33d396bbf5ba92c5f9c36692b2fc683d02ee859c15adac89e7f7
|
7
|
+
data.tar.gz: 795ca3666bb1848dbff34671a5b2bc6f15b9c5d1263e48dd04c03c7509c5bab6224e58103999e41e737c046778730918001bf5cd2af4a0ff8295fb60139b28b4
|
data/Gemfile.lock
CHANGED
data/lib/diplomat/kv.rb
CHANGED
@@ -12,9 +12,8 @@ module Diplomat
|
|
12
12
|
def get key
|
13
13
|
@key = key
|
14
14
|
@raw = @conn.get "/v1/kv/#{@key}"
|
15
|
-
|
16
|
-
|
17
|
-
return @value
|
15
|
+
parse_body
|
16
|
+
return_value
|
18
17
|
end
|
19
18
|
|
20
19
|
# Get a value by it's key
|
@@ -22,15 +21,15 @@ module Diplomat
|
|
22
21
|
# @param value [String] the value
|
23
22
|
# @return [String] The base64-decoded value associated with the key
|
24
23
|
def put key, value
|
25
|
-
@key
|
26
|
-
@
|
24
|
+
@key = key
|
25
|
+
@value = value
|
26
|
+
@raw = @conn.put do |req|
|
27
27
|
req.url "/v1/kv/#{@key}"
|
28
28
|
req.body = @value
|
29
29
|
end
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
return @value
|
30
|
+
parse_body
|
31
|
+
return_key
|
32
|
+
return_value
|
34
33
|
end
|
35
34
|
|
36
35
|
# Delete a value by it's key
|
@@ -39,8 +38,8 @@ module Diplomat
|
|
39
38
|
def delete key
|
40
39
|
@key = key
|
41
40
|
@raw = @conn.delete "/v1/kv/#{@key}"
|
42
|
-
|
43
|
-
|
41
|
+
return_key
|
42
|
+
return_value
|
44
43
|
end
|
45
44
|
|
46
45
|
# @note This is sugar, see (#get)
|
@@ -58,6 +57,23 @@ module Diplomat
|
|
58
57
|
Diplomat::Kv.new.delete *args
|
59
58
|
end
|
60
59
|
|
60
|
+
private
|
61
|
+
|
62
|
+
# Parse the body, apply it to the raw attribute
|
63
|
+
def parse_body
|
64
|
+
@raw = JSON.parse(@raw.body).first
|
65
|
+
end
|
66
|
+
|
67
|
+
# Get the key from the raw output
|
68
|
+
def return_key
|
69
|
+
@key = @raw["Key"]
|
70
|
+
end
|
71
|
+
|
72
|
+
# Get the value from the raw output
|
73
|
+
def return_value
|
74
|
+
@value = @raw["Value"]
|
75
|
+
@value = Base64.decode64(@value) unless @value.nil?
|
76
|
+
end
|
61
77
|
|
62
78
|
end
|
63
79
|
end
|
data/lib/diplomat/version.rb
CHANGED