Module: Aruba::Api::Environment

Included in:
Aruba::Api, Bundler
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)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/aruba/api/environment.rb', line 43

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

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

  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)


90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/aruba/api/environment.rb', line 90

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

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

  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)


68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/aruba/api/environment.rb', line 68

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

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

  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
30
31
32
# 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

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

  self
end