Module: Tap::Test::EnvVars
- Included in:
- FileTest, SubsetTest, SubsetTestClass
- Defined in:
- lib/tap/test/env_vars.rb
Overview
Provides for case-insensitive access to the ENV variables
Instance Method Summary collapse
-
#env(type) ⇒ Object
Access to the case-insensitive ENV variables.
-
#env_true?(var) ⇒ Boolean
Returns true if the env_var(var) is set and matches /^true$/i.
Instance Method Details
#env(type) ⇒ Object
Access to the case-insensitive ENV variables. Raises an error if multiple case-insensitive values are defined in ENV.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/tap/test/env_vars.rb', line 9 def env(type) type = type.downcase # ruby 1.9 returns a hash instead of an array selected = ENV.select {|key, value| key.downcase == type}.to_a case selected.length when 0 then nil when 1 then selected[0][1] else raise "Multiple env values for '#{type}'" end end |
#env_true?(var) ⇒ Boolean
Returns true if the env_var(var) is set and matches /^true$/i
24 25 26 |
# File 'lib/tap/test/env_vars.rb', line 24 def env_true?(var) (env(var) && env(var) =~ /^true$/i) ? true : false end |