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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a5bd6ea2a108d0d0d30297286bb3d8b85a45fdd7
4
- data.tar.gz: 55b75196433b27313d41a7785d01198fe8de0c17
3
+ metadata.gz: 4d226cca85b7c115c9c1772f3f0988b4b40c24c8
4
+ data.tar.gz: 8907e6552c36ef93e7400451e08db8d2209aa38c
5
5
  SHA512:
6
- metadata.gz: 63f50339236da9d90a798d2ad9803a82c2db1483e1d349a9d4ee1e865b810bcc2f140735e484fb7f2254f2dfdd2ca3d926b83587d0eaee473875ded6749fee60
7
- data.tar.gz: ac0fa2c4dde4fa761b831b36c2be3af6b2d728481793ecb341a0e2d7a4f326bce152cfc38a7768784055d2ee13e3b78d90b5414ac58d0b6f728cdcc3ab798d00
6
+ metadata.gz: 648335f4ea9acc7f3a7e13b5de8d9e56dc6e39ce801583ec1693cd47f2d22a95d8b297f13bc545a3663be166bd6feda8de1e1ba13f6e0042a760af025b911b6f
7
+ data.tar.gz: c0f6a9a8cd99aa0886dd79c1b0dafe9002ea25b4f951d88bf9dcefc5d5f8a8630c0a85f72db0155ccd2a5d5a3563db2b8441253f545317c7adfc40b0de1cf726
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Vault
2
2
  module Tools
3
- VERSION = '0.6.5'
3
+ VERSION = '0.7.0'
4
4
  end
5
5
  end
@@ -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.6.5
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-05-10 00:00:00.000000000 Z
12
+ date: 2018-06-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: scrolls