class Aruba::Platforms::UnixEnvironmentVariables

Abstract environment variables

def self.hash_from_env

def self.hash_from_env
  ENV.to_hash
end

def [](name)

Parameters:
  • name (#to_s) --
def [](name)
  to_h[name.to_s]
end

def []=(name, value)

Parameters:
  • value (#to_s) --
  • name (#to_s) --
def []=(name, value)
  value = value.to_s
  actions << UpdateAction.new(name.to_s => value)
end

def append(name, value)

Parameters:
  • value (#to_s) --
  • name (#to_s) --
def append(name, value)
  name  = name.to_s
  value = self[name].to_s + value.to_s
  actions << UpdateAction.new(name => value)
  value
end

def clear

Reset environment
def clear
  value = to_h
  actions.clear
  value
end

def delete(name)

Parameters:
  • name (#to_s) --
def delete(name)
  # Rescue value, before it is deleted
  value = to_h[name.to_s]
  actions << RemoveAction.new(name.to_s)
  value
end

def fetch(name, default = UNDEFINED)

Parameters:
  • default (Object) --
  • name (#to_s) --
def fetch(name, default = UNDEFINED)
  if default == UNDEFINED
    to_h.fetch name.to_s
  else
    to_h.fetch name.to_s, default
  end
end

def hash_from_env

def hash_from_env
  self.class.hash_from_env
end

def initialize(env = ENV)

def initialize(env = ENV)
  @actions = []
  @env = env.to_h
end

def key?(name)

Parameters:
  • name (#to_s) --
def key?(name)
  to_h.key? name.to_s
end

def method_missing(name, *args, &block)

Pass on checks
def method_missing(name, *args, &block)
  super unless to_h.respond_to? name
  to_h.send name, *args, &block
end

def nest

def nest
  old_actions = @actions.dup
  yield(self)
ensure
  @actions = old_actions
end

def prepend(name, value)

Parameters:
  • value (#to_s) --
  • name (#to_s) --
def prepend(name, value)
  name  = name.to_s
  value = value.to_s + self[name].to_s
  actions << UpdateAction.new(name => value)
  value
end

def respond_to_missing?(name, _private)

Check for respond_to
def respond_to_missing?(name, _private)
  to_h.respond_to? name
end

def to_h

Returns:
  • (Hash) -
def to_h
  actions.inject(hash_from_env.merge(env)) { |a, e| e.call(a) }
end

def update(other_env)

Other tags:
    Yield: -

Parameters:
  • other_env (#to_hash, #to_h) --
def update(other_env)
  actions << UpdateAction.new(other_env)
  self
end