Module: Aruba::Api::Environment

Included in:
Aruba::Api
Defined in:
lib/aruba/api/environment.rb

Overview

Environment methods of aruba

Instance Method Summary collapse

Instance Method Details

#append_environment_variable(name, value) ⇒ Object

Append environment variable

Parameters:

  • name (String)

    The name of the environment variable as string, e.g. 'HOME'

  • value (String)

    The value of the environment variable. Needs to be a string.



36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/aruba/api/environment.rb', line 36

def append_environment_variable(name, value)
  name = name.to_s
  value = value.to_s

  old_environment = aruba.environment.to_h
  aruba.environment.append name, value
  new_environment = aruba.environment.to_h

  aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => value })

  self
end

#delete_environment_variable(name) ⇒ Object

Remove existing environment variable

Parameters:

  • key (String)

    The name of the environment variable as string, e.g. 'HOME'

  • value (String)

    The value of the environment variable. Needs to be a string.



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/aruba/api/environment.rb', line 76

def delete_environment_variable(name)
  name = name.to_s

  old_environment = aruba.environment.to_h
  aruba.environment.delete name
  new_environment = aruba.environment.to_h

  aruba.event_bus.notify Events::DeletedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => '' })

  self
end

#prepend_environment_variable(name, value) ⇒ Object

Prepend environment variable

Parameters:

  • name (String)

    The name of the environment variable as string, e.g. 'HOME'

  • value (String)

    The value of the environment variable. Needs to be a string.



56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/aruba/api/environment.rb', line 56

def prepend_environment_variable(name, value)
  name = name.to_s
  value = value.to_s

  old_environment = aruba.environment.to_h
  aruba.environment.prepend name, value
  new_environment = aruba.environment.to_h

  aruba.event_bus.notify Events::ChangedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => value })

  self
end

#set_environment_variable(name, value) ⇒ Object

Set environment variable

Parameters:

  • name (String)

    The name of the environment variable as string, e.g. 'HOME'

  • value (String)

    The value of the environment variable. Needs to be a string.



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/aruba/api/environment.rb', line 16

def set_environment_variable(name, value)
  name = name.to_s
  value = value.to_s

  old_environment = aruba.environment.to_h
  aruba.environment[name] = value
  new_environment = aruba.environment.to_h

  aruba.event_bus.notify Events::AddedEnvironmentVariable.new(:old => old_environment, :new => new_environment, :changed => { :name => name, :value => value })

  self
end