class Aruba::Platforms::UnixEnvironmentVariables
Abstract environment variables
def self.hash_from_env
def self.hash_from_env ENV.to_hash end
def [](name)
-
name
(#to_s
) --
def [](name) to_h[name.to_s] end
def []=(name, value)
-
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)
-
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
def clear value = to_h actions.clear value end
def delete(name)
-
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)
-
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)
-
name
(#to_s
) --
def key?(name) to_h.key? name.to_s end
def method_missing(name, *args, &block)
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)
-
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)
def respond_to_missing?(name, _private) to_h.respond_to? name end
def to_h
-
(Hash)
-
def to_h actions.inject(hash_from_env.merge(env)) { |a, e| e.call(a) } end
def update(other_env)
- Yield: -
Parameters:
-
other_env
(#to_hash, #to_h
) --
def update(other_env) actions << UpdateAction.new(other_env) self end