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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8655785e99227be773937bcb1eca589fb722fc2a
4
- data.tar.gz: 82dd206fd22e6eeb4448a6c3eabc735f78163454
3
+ metadata.gz: 69084b2a7f479ac63674df3d9886edeb576d6df6
4
+ data.tar.gz: b3d8de26ba454bf168fb02a6f1e197508e4501be
5
5
  SHA512:
6
- metadata.gz: cd220c071b7fe429c8f03e2a9e8dbc3d9b30a8c534e8d5605750dfe58e9d532a2cc86b01b176af60a85ec45333d63eb41f07359f09f9d1fd33a111fc0f1d271e
7
- data.tar.gz: e4800883b78bd0bba36993d2858cb322ec85cc25d3695cfb35a9b5ea33785285417a24995dd6df4866edb812962896b59ef6ca2134c9947da5391771aeb66fbc
6
+ metadata.gz: 405fa1f5d83f6b484257395ddc63d7df04a66a0651a5d74229bde9768cb12a9ef7cc40529bbc33d396bbf5ba92c5f9c36692b2fc683d02ee859c15adac89e7f7
7
+ data.tar.gz: 795ca3666bb1848dbff34671a5b2bc6f15b9c5d1263e48dd04c03c7509c5bab6224e58103999e41e737c046778730918001bf5cd2af4a0ff8295fb60139b28b4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- diplomat (0.1.3)
4
+ diplomat (0.1.6)
5
5
  faraday (~> 0.9)
6
6
 
7
7
  GEM
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
- @raw = JSON.parse(@raw.body).first
16
- @value = Base64.decode64(@raw["Value"])
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 = key
26
- @raw = @conn.put do |req|
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
- @raw = JSON.parse(@raw.body).first
31
- @key = @raw["Key"]
32
- @value = Base64.decode64(@raw["Value"])
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
- @key = nil
43
- @value = nil
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
@@ -1,3 +1,3 @@
1
1
  module Diplomat
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diplomat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Hamelink