class TF::EnvTypeTest

Constants

MATCHER

Public Instance Methods

execute(test, _stdout, _stderr, _stdboth, _status, env) click to toggle source
# File lib/plugins/tf/env_type_test.rb, line 8
def execute test, _stdout, _stderr, _stdboth, _status, env
  test =~ TF::EnvTypeTest::MATCHER
  variable, sign, type = $1.strip, $2, $3
  var_type = variable_type( env[ variable ] )
  if ( sign == "=" ) ^ ( var_type == type )
    [ false, "failed: env? #{variable} #{sign} #{type} # was #{var_type}" ]
  else
    [ true, "passed: env? #{variable} #{sign} #{type}" ]
  end
end
matches?(test) click to toggle source
# File lib/plugins/tf/env_type_test.rb, line 4
def matches? test
  test =~ TF::EnvTypeTest::MATCHER
end
variable_type(value) click to toggle source
# File lib/plugins/tf/env_type_test.rb, line 19
def variable_type value
  value.nil? ? 'nil' :
    value.is_a?(Hash) ? 'array' : 'string'
end