vault-tools 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vault-tools/config.rb +10 -0
- data/lib/vault-tools/version.rb +1 -1
- data/test/config_test.rb +15 -0
- 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: 4d226cca85b7c115c9c1772f3f0988b4b40c24c8
|
4
|
+
data.tar.gz: 8907e6552c36ef93e7400451e08db8d2209aa38c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 648335f4ea9acc7f3a7e13b5de8d9e56dc6e39ce801583ec1693cd47f2d22a95d8b297f13bc545a3663be166bd6feda8de1e1ba13f6e0042a760af025b911b6f
|
7
|
+
data.tar.gz: c0f6a9a8cd99aa0886dd79c1b0dafe9002ea25b4f951d88bf9dcefc5d5f8a8630c0a85f72db0155ccd2a5d5a3563db2b8441253f545317c7adfc40b0de1cf726
|
data/lib/vault-tools/config.rb
CHANGED
@@ -199,5 +199,15 @@ module Vault
|
|
199
199
|
def self.sidekiq_concurrency
|
200
200
|
int('SIDEKIQ_CONCURRENCY') || 25
|
201
201
|
end
|
202
|
+
|
203
|
+
# Return a fallback value if a given Config var is not set
|
204
|
+
#
|
205
|
+
# @param name [String] The name of the environment variable.
|
206
|
+
# @param fallback [String] The value to return if there is no value for the
|
207
|
+
# name param.
|
208
|
+
# @return [String] Either the set Config var value or the fallback value
|
209
|
+
def self.fetch(name, fallback)
|
210
|
+
self[name].nil? ? fallback : self[name]
|
211
|
+
end
|
202
212
|
end
|
203
213
|
end
|
data/lib/vault-tools/version.rb
CHANGED
data/test/config_test.rb
CHANGED
@@ -219,4 +219,19 @@ class ConfigTest < Vault::TestCase
|
|
219
219
|
set_env 'SIDEKIQ_CONCURRENCY', '10'
|
220
220
|
assert_equal(10, Config.sidekiq_concurrency)
|
221
221
|
end
|
222
|
+
|
223
|
+
# Confg.fetch(:some_var, 'whatever') will fallback to 'whatever' if SOME_VAR
|
224
|
+
# is not defined.
|
225
|
+
def test_fetch_allows_fallback_value
|
226
|
+
assert_equal('bar', Config.fetch(:some_var, 'bar'))
|
227
|
+
set_env 'SOME_VAR', 'foo'
|
228
|
+
assert_equal('foo', Config.fetch(:some_var, 'bar'))
|
229
|
+
end
|
230
|
+
|
231
|
+
# Confg.fetch(:some_var, 'whatever') will allow SOME_VAR to be false
|
232
|
+
def test_fetch_allows_value_to_be_false
|
233
|
+
assert_equal('bar', Config.fetch(:some_var, 'bar'))
|
234
|
+
set_env 'SOME_VAR', 'false'
|
235
|
+
assert_equal('false', Config.fetch(:some_var, 'bar'))
|
236
|
+
end
|
222
237
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vault-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Continanza
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-
|
12
|
+
date: 2018-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: scrolls
|