config_hub-client 0.1.2 → 0.1.3
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/Gemfile.lock +13 -1
- data/config_hub-client.gemspec +1 -0
- data/lib/config_hub/client.rb +33 -7
- data/lib/config_hub/client/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7c252299059e21380862e2362f882bf534b3cfc
|
4
|
+
data.tar.gz: 8585460a99d9e9b090d137b347833122aac5c55b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3de2d68106317031b77e41929f3e6f81da5498bec4e35a0fed9bdfa0d6c7d504f323ca361a541a685c9c8f9a0364d26bdc19499d1a1527188e35321ff55b4236
|
7
|
+
data.tar.gz: 82772946f080a175a98ec3a18116c77ed7e84f22c75a940b9f8c7ce6f3906e623443f43af6e0c42ca26fcec78e6b5b8ea77398fe87617394609d8a34699c4088
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
config_hub-client (0.1.
|
4
|
+
config_hub-client (0.1.2)
|
5
5
|
activerecord (>= 4.2.0)
|
6
6
|
faraday (>= 0.12.2)
|
7
7
|
|
@@ -19,15 +19,21 @@ GEM
|
|
19
19
|
i18n (~> 0.7)
|
20
20
|
minitest (~> 5.1)
|
21
21
|
tzinfo (~> 1.1)
|
22
|
+
addressable (2.5.2)
|
23
|
+
public_suffix (>= 2.0.2, < 4.0)
|
22
24
|
arel (8.0.0)
|
23
25
|
awesome_print (1.7.0)
|
24
26
|
concurrent-ruby (1.0.5)
|
27
|
+
crack (0.4.3)
|
28
|
+
safe_yaml (~> 1.0.0)
|
25
29
|
diff-lcs (1.3)
|
26
30
|
faraday (0.12.2)
|
27
31
|
multipart-post (>= 1.2, < 3)
|
32
|
+
hashdiff (0.3.6)
|
28
33
|
i18n (0.8.6)
|
29
34
|
minitest (5.10.3)
|
30
35
|
multipart-post (2.0.0)
|
36
|
+
public_suffix (3.0.0)
|
31
37
|
rake (10.4.2)
|
32
38
|
rspec (3.6.0)
|
33
39
|
rspec-core (~> 3.6.0)
|
@@ -42,9 +48,14 @@ GEM
|
|
42
48
|
diff-lcs (>= 1.2.0, < 2.0)
|
43
49
|
rspec-support (~> 3.6.0)
|
44
50
|
rspec-support (3.6.0)
|
51
|
+
safe_yaml (1.0.4)
|
45
52
|
thread_safe (0.3.6)
|
46
53
|
tzinfo (1.2.3)
|
47
54
|
thread_safe (~> 0.1)
|
55
|
+
webmock (3.0.1)
|
56
|
+
addressable (>= 2.3.6)
|
57
|
+
crack (>= 0.3.2)
|
58
|
+
hashdiff
|
48
59
|
|
49
60
|
PLATFORMS
|
50
61
|
ruby
|
@@ -55,6 +66,7 @@ DEPENDENCIES
|
|
55
66
|
config_hub-client!
|
56
67
|
rake (~> 10.0)
|
57
68
|
rspec (~> 3.0)
|
69
|
+
webmock
|
58
70
|
|
59
71
|
BUNDLED WITH
|
60
72
|
1.15.4
|
data/config_hub-client.gemspec
CHANGED
data/lib/config_hub/client.rb
CHANGED
@@ -23,15 +23,19 @@ module ConfigHub
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def fetch(key)
|
26
|
-
if
|
26
|
+
if has?(key)
|
27
27
|
item = @data['properties'][key.to_s]
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
cast item['val'], item['type']
|
29
|
+
elsif block_given?
|
30
|
+
yield
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def fetch_file(key)
|
35
|
+
if config_pulled? && @data['files'].present?
|
36
|
+
@data.dig('files', key, 'content')
|
33
37
|
else
|
34
|
-
|
38
|
+
retrieve_remote_file(key)
|
35
39
|
end
|
36
40
|
end
|
37
41
|
|
@@ -45,6 +49,15 @@ module ConfigHub
|
|
45
49
|
end
|
46
50
|
end
|
47
51
|
|
52
|
+
def has?(key)
|
53
|
+
if config_pulled?
|
54
|
+
props = @data['properties']
|
55
|
+
props && props.key?(key.to_s)
|
56
|
+
else
|
57
|
+
raise ConfigNotPulledError
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
48
61
|
private
|
49
62
|
|
50
63
|
def cast(val, type)
|
@@ -62,6 +75,19 @@ module ConfigHub
|
|
62
75
|
end
|
63
76
|
end
|
64
77
|
|
78
|
+
def retrieve_remote_file(key)
|
79
|
+
res = @conn.get('/rest/rawFile') do |req|
|
80
|
+
req.headers['File'] = key
|
81
|
+
end
|
82
|
+
if res.status == 200
|
83
|
+
res.body
|
84
|
+
elsif res.status == 204
|
85
|
+
nil
|
86
|
+
else
|
87
|
+
raise RequestError.new('Could not retrieve raw file', res)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
65
91
|
def retrieve_remote_config
|
66
92
|
res = @conn.get('/rest/pull')
|
67
93
|
if res.status == 200
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_hub-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Dunn
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
description:
|
98
112
|
email:
|
99
113
|
- jeremy.dunn@vineti.com
|