secret_env 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7b7fd45045664cce3ef970f014b7b6e9e69bb1d3
4
- data.tar.gz: f5b28f4de7822f8906eaef22620924003fb9b508
3
+ metadata.gz: b1e1505edb2746b3c514bcfc4d63a55932bac752
4
+ data.tar.gz: 8caaa36d3a22b33d9d7765298239da62df506724
5
5
  SHA512:
6
- metadata.gz: 4a48dad04748521ae7a1fd9dd3b6f051b12f88c7304ba6c7f94d4f9149bb413e982332448639dd1e71954ad131381e16a7c0b8e8ba93af73bf8c32c0e352d6f2
7
- data.tar.gz: e774b89c3334d001aa32830dbf5d5195874569511d44af88882b2f83108d2c087490f5c492e319531518546288522a110fe8758ffc5f7029fd1ae299a852cab6
6
+ metadata.gz: f7875732f6642c3da35395258b837ff955368002094eefce272ce3acd06b945bb47689ec661604e4962aa4551333dd8f68406e17eb833f551ee9ebab81d43fad
7
+ data.tar.gz: 7b99d06bea62e93ba190d134c0fedfd86ffebdf9c0930dc0b683e1090c4b2f7d17e1c4e27f8373ec979272ccef38d60198d5cd36cf562e81f68685da813fe988
@@ -1,3 +1,3 @@
1
1
  module SecretEnv
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/secret_env.rb CHANGED
@@ -37,20 +37,24 @@ module SecretEnv
37
37
  scanner = StringScanner.new(@raw_value)
38
38
  parts = []
39
39
  while part = scanner.scan_until(/#\{(.*?)\}/)
40
- secret_key = scanner.matched[2..-2] # Extract "secret" from "\#{secret}"
40
+ secret_keys = scanner.matched[2..-2] # Extract "secret" from "\#{secret}"
41
41
 
42
+ secret = nil
43
+ secret_keys.split("||").map(&:strip).each do |secret_key|
44
+ secret = case
45
+ when ENV.has_key?(secret_key)
46
+ ENV[secret_key]
47
+ when @dependency.has_key?(secret_key)
48
+ # FIXME this code may cause infinite loop
49
+ @dependency[secret_key].value
50
+ else
51
+ @storage.retrieve(secret_key)
52
+ end
42
53
 
43
- secret = case
44
- when ENV.has_key?(secret_key)
45
- ENV[secret_key]
46
- when @dependency.has_key?(secret_key)
47
- # FIXME this code may cause infinite loop
48
- @dependency[secret_key].value
49
- else
50
- @storage.retrieve(secret_key)
51
- end
54
+ break if secret
55
+ end
52
56
 
53
- raise SecretEnv::KeyNotFound, secret_key unless secret
57
+ raise SecretEnv::KeyNotFound, secret_keys unless secret
54
58
  parts << part.gsub(scanner.matched, secret)
55
59
  end
56
60
  parts << scanner.rest
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secret_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - adorechic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-07 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.6.4
112
+ rubygems_version: 2.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: SecretEnv retrieves secrets and export to ENV