confyio 1.0.0 → 1.1.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/confy/config.rb +24 -2
- 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: c6f724a4974e4991f69a7b2d4031cb94a358a317
|
4
|
+
data.tar.gz: dd73d3d67558336f925212e26d0290c7daf8113d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ceaa02c29791fa58e44f7ad4089c19b554c1067fca93b3dd9eda8afb423eb6c54c751afefbda9028d3c30436885ed7212d10afbd1bd32b0e7771f6313602513
|
7
|
+
data.tar.gz: 1381ac188f25194bc602f822ceb0f61d173a899d94e6fab2dd5b99df59ec67620e156e5df451ed8bb2db9af554af4e5d1609bf31601d169c4d70ae16ec28d591
|
data/lib/confy/config.rb
CHANGED
@@ -2,8 +2,7 @@ module Confy
|
|
2
2
|
|
3
3
|
class Config
|
4
4
|
|
5
|
-
def self.
|
6
|
-
|
5
|
+
def self.load(url = {})
|
7
6
|
if url.is_a?(String)
|
8
7
|
regex = Regexp.new('(https?:\/\/)(.*):(.*)@(.*)\/orgs\/([a-z0-9]*)\/projects\/([a-z0-9]*)\/envs\/([a-z0-9]*)\/config', true)
|
9
8
|
matches = regex.match(url)
|
@@ -21,6 +20,29 @@ module Confy
|
|
21
20
|
client.config(url[:org], url[:project], url[:env]).retrieve().body
|
22
21
|
end
|
23
22
|
|
23
|
+
def self.env(url = {})
|
24
|
+
self.path(self.load(url))
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.path(config, str = '')
|
28
|
+
type = config.class
|
29
|
+
|
30
|
+
if type == Array
|
31
|
+
config.each_with_index do |value, key|
|
32
|
+
self.path(value, "#{str}_#{key}")
|
33
|
+
end
|
34
|
+
elsif type == Hash
|
35
|
+
config.each do |key, value|
|
36
|
+
self.path(value, "#{str}_#{key.upcase}")
|
37
|
+
end
|
38
|
+
elsif type == TrueClass
|
39
|
+
ENV[str.slice(1, str.length)] = '1'
|
40
|
+
elsif type == FalseClass
|
41
|
+
ENV[str.slice(1, str.length)] = '0'
|
42
|
+
else
|
43
|
+
ENV[str.slice(1, str.length)] = config.to_s
|
44
|
+
end
|
45
|
+
end
|
24
46
|
end
|
25
47
|
|
26
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: confyio
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavan Kumar Sunkara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|