fake_consul 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/fake_consul.rb +1 -53
- data/lib/fake_consul/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: aec9fecb3e908f1f6368c526b299a5e91477a27e
|
4
|
+
data.tar.gz: d675d00b4a11fa6da15652b7bded3eace8df83d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0157f6022d00f42615d8879fb6beac6af0e1dfe2c652a1bd5b024405534e0fe6b098740bc7b1f8732d94e296dbc1e01382af8b6ebfa3334aedd1538964a37d
|
7
|
+
data.tar.gz: c6640f6d9f06ba00ec67a6b6befd84721d112b3e262d93ad80c0b80bc7ed870abb1d9e09823c99cef47fb0419ba172f932f8d3a0574c7a3c663aeda67a7f2a60
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [v0.0.3] - 2015-11-27
|
6
|
+
- Fix double implementation of server
|
7
|
+
|
5
8
|
## [v0.0.2] - 2015-11-27
|
6
9
|
- More open dependency on activesupport
|
7
10
|
|
data/lib/fake_consul.rb
CHANGED
@@ -1,58 +1,6 @@
|
|
1
1
|
require "fake_consul/version"
|
2
|
+
require "fake_consul/server"
|
2
3
|
|
3
4
|
module FakeConsul
|
4
|
-
class Server < HashWithIndifferentAccess
|
5
5
|
|
6
|
-
# Fake get
|
7
|
-
#
|
8
|
-
# Performs no http requests but stores data in local hash
|
9
|
-
#
|
10
|
-
# @param key [String]
|
11
|
-
# @param options [Hash]
|
12
|
-
# @options recurse [Boolean] wether to list all keys starting with this prefix
|
13
|
-
# @param not_found [Symbol] unused/unimplemented
|
14
|
-
# @param found [Symbol] not unused/unimplemented
|
15
|
-
# @return [Array<Hash>] e.g. [{key: 'foo', value: 'bar'}]
|
16
|
-
def get(key, options = nil, not_found = :reject, found = :return)
|
17
|
-
if options[:recurse]
|
18
|
-
find_keys_recursive(key)
|
19
|
-
else
|
20
|
-
consul_export_format(key)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Fake put
|
25
|
-
#
|
26
|
-
# Performs no http requests but retrieves data from local hash
|
27
|
-
#
|
28
|
-
# @param key [String]
|
29
|
-
# @param options [Hash] unused/unimplemented
|
30
|
-
# @return [Boolean] true :trollface:
|
31
|
-
def kv_put(key, value, options = nil)
|
32
|
-
self[key] = value
|
33
|
-
true
|
34
|
-
end
|
35
|
-
|
36
|
-
private
|
37
|
-
|
38
|
-
# Returns the keys in the following format:
|
39
|
-
# [{key: `key`, value: 'bar'}]
|
40
|
-
# @return [Array<Hash>]
|
41
|
-
def consul_export_format(keys)
|
42
|
-
Array(keys).map do
|
43
|
-
{'key' => key, 'value' => self[key]}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# Returns all keys that begin with the supplied `key`.
|
48
|
-
#
|
49
|
-
# @return [Array<Hash>] e.g. [{key: 'foo', value: 'bar'}]
|
50
|
-
def find_keys_recursive(key)
|
51
|
-
keys.select? do |_key|
|
52
|
-
_key.to_s.start_with?(key.to_s)
|
53
|
-
end.map do |_key|
|
54
|
-
consul_export_format(_key)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
6
|
end
|
data/lib/fake_consul/version.rb
CHANGED