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) ⇒ self

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.

Returns:

  • (self)

40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/aruba/api/environment.rb', line 40

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) ⇒ self

Remove existing environment variable

Parameters:

  • name (String)

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

Returns:

  • (self)

81
82
83
84
85
86
87
88
89
90
91
# File 'lib/aruba/api/environment.rb', line 81

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) ⇒ self

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.

Returns:

  • (self)

62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/aruba/api/environment.rb', line 62

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) ⇒ self

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.

Returns:

  • (self)

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

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