Module: Fig::Statement::EnvironmentVariable::ClassMethods

Defined in:
lib/fig/statement/environment_variable.rb

Instance Method Summary collapse

Instance Method Details

#base_v0_value_validation(variable, raw_value) ⇒ Object

TODO: Test coverage doesn’t appear to be running this.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fig/statement/environment_variable.rb', line 67

def base_v0_value_validation(variable, raw_value)
  if raw_value =~ /\s/
    yield %Q<The value of #{variable} (#{raw_value}) contains whitespace.>
    return
  end
  if raw_value =~ /'/
    yield %Q<The value of #{variable} (#{raw_value}) contains a single quote.>
    return
  end
  if raw_value =~ /"/
    yield %Q<The value of #{variable} (#{raw_value}) contains a double quote.>
    return
  end

  return
end

#seperate_name_and_value(combined, &error_block) ⇒ Object



50
51
52
53
54
55
56
57
58
59
# File 'lib/fig/statement/environment_variable.rb', line 50

def seperate_name_and_value(combined, &error_block)
  variable, raw_value = combined.split '=', 2
  if variable !~ Fig::Statement::ENVIRONMENT_VARIABLE_NAME_REGEX
    yield \
      %Q<"#{variable}" does not consist solely of alphanumerics and underscores.>
    return
  end

  return [variable, raw_value || '']
end

#tokenize_value(value, &error_block) ⇒ Object



61
62
63
64
# File 'lib/fig/statement/environment_variable.rb', line 61

def tokenize_value(value, &error_block)
  tokenizer = Fig::StringTokenizer.new TOKENIZING_SUBEXPRESSION_MATCHER, '@'
  return tokenizer.tokenize value, &error_block
end