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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/confy/config.rb +24 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa2dccd72c8a354d13cb76db736a3295a1fb0a33
4
- data.tar.gz: 90319998a80cfd9fb81438dbcd83c899bc977231
3
+ metadata.gz: c6f724a4974e4991f69a7b2d4031cb94a358a317
4
+ data.tar.gz: dd73d3d67558336f925212e26d0290c7daf8113d
5
5
  SHA512:
6
- metadata.gz: e3470b9e5e4a876ec5e3be055ac4e3be1c0bea8a0da0eabb9857886d7604b1b61e8c219d38770db9493f28f9499d8b55a6888c828e3c881e245423f716e3d441
7
- data.tar.gz: 59ec58a9370f41bdb24f65b2e8fe86503b5dd84dcebe0026ec0f1347c954ba4ff5a81f78d175da0c283e6784c5ec06ffaee1c9494e7d254a8eec1982b4e6c9a0
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.new(url = {})
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.0.0
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-16 00:00:00.000000000 Z
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday