lib/vault-tools/config.rb in vault-tools-0.4.3 vs lib/vault-tools/config.rb in vault-tools-0.4.4

- old
+ new

@@ -131,11 +131,11 @@ # @param name [String] The name of the environment variable to fetch a # Fixnum for. # @return [Fixnum] The number or nil if the value couldn't be coerced to a # Fixnum. def self.int(name) - self[name] ? self[name].to_i : nil + self[name] && self[name].to_i end # Comma-separated words converted to an array. # # @param name [String] The name of the environment variable to fetch an @@ -153,11 +153,22 @@ # @return [bool] True if the value is `true`, otherwise false. def self.bool?(name) self[name] == 'true' end + # An environment variable converted to a time. + # + # @param name [String|Symbol] The name of the environment variable to fetch a + # boolean for. + # @return [Time] Time if the value is parseable, otherwise false. def self.time(name) - Time.parse(self[name]) + if self[name] + Time.parse(self[name]) rescue Time.utc(*self[name].split('-')) + end + end + + def self.uri(name) + self[name] && URI.parse(self[name]) end # The number of threads to use in Sidekiq workers. # # @return [Fixnum] The number of threads from the `SIDEKIQ_CONCURRENCY`