king_konf 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/king_konf/config.rb +8 -5
- data/lib/king_konf/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: 79a1662b16c52209c5cdf929117c793010c6a2bd
|
4
|
+
data.tar.gz: 0cc7fa9c7cff3248513bd864f29cb3846dfee210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 04bbcae68698e1580ad31056ee67612fdfb978d0306836317abfb026e1ed40b827538fd5b11fdb1c2e993cf5e70054768bb0e827b3d00993bca0009a913b8786
|
7
|
+
data.tar.gz: 76b6918917d47f8fdc10dc4286f510c552d39a38c3672a607bb83dd242dd8f78ef50c23d50b0cd32e4a59599e7d78682471d738aaa271b4060b08d5196f74dec
|
data/lib/king_konf/config.rb
CHANGED
@@ -132,10 +132,10 @@ module KingKonf
|
|
132
132
|
|
133
133
|
def load_env(env)
|
134
134
|
loaded_keys = []
|
135
|
-
prefix = self.class.prefix
|
135
|
+
prefix = self.class.prefix ? "#{self.class.prefix.upcase}_" : ""
|
136
136
|
|
137
137
|
self.class.variables.each do |variable|
|
138
|
-
key =
|
138
|
+
key = prefix + variable.name.upcase.to_s
|
139
139
|
|
140
140
|
if string = env[key]
|
141
141
|
value = variable.decode(string)
|
@@ -144,9 +144,12 @@ module KingKonf
|
|
144
144
|
end
|
145
145
|
end
|
146
146
|
|
147
|
-
|
148
|
-
|
149
|
-
|
147
|
+
# Only complain about unknown ENV vars if there's a prefix defined.
|
148
|
+
if self.class.prefix
|
149
|
+
env.keys.grep(/^#{prefix}/).each do |key|
|
150
|
+
unless loaded_keys.include?(key)
|
151
|
+
raise ConfigError, "unknown environment variable #{key}"
|
152
|
+
end
|
150
153
|
end
|
151
154
|
end
|
152
155
|
end
|
data/lib/king_konf/version.rb
CHANGED