Module: Env
- Included in:
- Tap
- Defined in:
- lib/env.rb
Overview
utility functions to read environment variables
Instance Method Summary collapse
-
#env_bool(name, default: false) ⇒ Object
:reek:BooleanParameter :reek:DataClump :reek:NilCheck :reek:UtilityFunction.
-
#env_bool_false(name) ⇒ Object
:reek:UtilityFunction.
-
#env_int(name, default: 0) ⇒ Object
skip :reek:DataClump skip :reek:NilCheck skip :reek:UtilityFunction.
-
#env_str(name, default: '') ⇒ Object
skip :reek:DataClump skip :reek:NilCheck skip :reek:UtilityFunction.
Instance Method Details
#env_bool(name, default: false) ⇒ Object
:reek:BooleanParameter :reek:DataClump :reek:NilCheck :reek:UtilityFunction
12 13 14 15 16 17 |
# File 'lib/env.rb', line 12 def env_bool(name, default: false) return default if name.nil? || (val = ENV.fetch(name, nil)).nil? return false if val.empty? || val == '0' true end |
#env_bool_false(name) ⇒ Object
:reek:UtilityFunction
20 21 22 |
# File 'lib/env.rb', line 20 def env_bool_false(name) !(val = name && ENV.fetch(name, nil)).nil? && !(val.empty? || val == '0') end |
#env_int(name, default: 0) ⇒ Object
skip :reek:DataClump skip :reek:NilCheck skip :reek:UtilityFunction
27 28 29 30 31 32 |
# File 'lib/env.rb', line 27 def env_int(name, default: 0) return default if name.nil? || (val = ENV.fetch(name, nil)).nil? return default if val.empty? val.to_i end |
#env_str(name, default: '') ⇒ Object
skip :reek:DataClump skip :reek:NilCheck skip :reek:UtilityFunction
37 38 39 40 41 |
# File 'lib/env.rb', line 37 def env_str(name, default: '') return default if name.nil? || (val = ENV.fetch(name, nil)).nil? val || default end |