diplomat 0.4.0 → 0.5.0
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 +19 -23
- data/lib/diplomat/rest_client.rb +8 -0
- data/lib/diplomat/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c7efb343599818bf0533dcb8695aa0283ab59aa
|
4
|
+
data.tar.gz: 000d4c18b30c36c3739ad0d1deda567eebe00cb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6aaea91e904df541b9f5a275e2450072411a488522c8748705a826f8d0725ac15c1c2d6d16cb9c037e963853801eb25ff4bf70363bf56dbf9d97069c0ac76b4
|
7
|
+
data.tar.gz: f2e2c8d09390bb45c9fbd4f3779516edefb8921962e3a7f01944c7fbd1037be738bde86d0bdef3d4262c79c52b7a46ad80ccca25ebe42d5ab66a2d8183a0b3f5
|
data/lib/diplomat/kv.rb
CHANGED
@@ -6,52 +6,48 @@ module Diplomat
|
|
6
6
|
|
7
7
|
attr_reader :key, :value, :raw
|
8
8
|
|
9
|
-
# Get a value by
|
9
|
+
# Get a value by its key
|
10
10
|
# @param key [String] the key
|
11
11
|
# @return [String] The base64-decoded value associated with the key
|
12
12
|
def get key
|
13
13
|
@key = key
|
14
|
-
|
15
|
-
|
16
|
-
@raw = @conn.get
|
14
|
+
url = ["/v1/kv/#{@key}"]
|
15
|
+
url += check_acl_token unless check_acl_token.nil?
|
16
|
+
@raw = @conn.get concat_url url
|
17
17
|
parse_body
|
18
18
|
return_value
|
19
19
|
end
|
20
20
|
|
21
|
-
#
|
21
|
+
# Associate a value with a key
|
22
22
|
# @param key [String] the key
|
23
23
|
# @param value [String] the value
|
24
24
|
# @param options [Hash] the query params
|
25
25
|
# @option options [Integer] :cas The modify index
|
26
|
-
# @return [
|
26
|
+
# @return [Bool] Success or failure of the write (can fail in c-a-s mode)
|
27
27
|
def put key, value, options=nil
|
28
|
-
qs = ""
|
29
28
|
@options = options
|
30
29
|
@raw = @conn.put do |req|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
req.url
|
30
|
+
url = ["/v1/kv/#{key}"]
|
31
|
+
url += check_acl_token unless check_acl_token.nil?
|
32
|
+
url += use_cas(@options) unless use_cas(@options).nil?
|
33
|
+
req.url concat_url url
|
35
34
|
req.body = value
|
36
35
|
end
|
37
|
-
if @raw.body == "true
|
36
|
+
if @raw.body == "true"
|
38
37
|
@key = key
|
39
38
|
@value = value
|
40
|
-
else
|
41
|
-
@raw.body
|
42
39
|
end
|
40
|
+
@raw.body == "true"
|
43
41
|
end
|
44
42
|
|
45
|
-
# Delete a value by
|
43
|
+
# Delete a value by its key
|
46
44
|
# @param key [String] the key
|
47
|
-
# @return [
|
45
|
+
# @return [OpenStruct]
|
48
46
|
def delete key
|
49
47
|
@key = key
|
50
|
-
|
51
|
-
|
52
|
-
@raw = @conn.delete
|
53
|
-
# return_key
|
54
|
-
# return_value
|
48
|
+
url = ["/v1/kv/#{@key}"]
|
49
|
+
url += check_acl_token unless check_acl_token.nil?
|
50
|
+
@raw = @conn.delete concat_url url
|
55
51
|
end
|
56
52
|
|
57
53
|
# @note This is sugar, see (#get)
|
@@ -88,11 +84,11 @@ module Diplomat
|
|
88
84
|
end
|
89
85
|
|
90
86
|
def check_acl_token
|
91
|
-
["
|
87
|
+
["token=#{Diplomat.configuration.acl_token}"] if Diplomat.configuration.acl_token
|
92
88
|
end
|
93
89
|
|
94
90
|
def use_cas(options)
|
95
|
-
["
|
91
|
+
["cas=#{options[:cas]}"] if options && options[:cas]
|
96
92
|
end
|
97
93
|
end
|
98
94
|
end
|
data/lib/diplomat/rest_client.rb
CHANGED
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.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Hamelink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|