Class: Dtf::Session::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/dtf-session.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#start_envObject

Returns the value of attribute start_env.



17
18
19
# File 'lib/dtf-session.rb', line 17

def start_env
  @start_env
end

#stop_envObject

Returns the value of attribute stop_env.



18
19
20
# File 'lib/dtf-session.rb', line 18

def stop_env
  @stop_env
end

#test_shellObject

Returns the value of attribute test_shell.



16
17
18
# File 'lib/dtf-session.rb', line 16

def test_shell
  @test_shell
end

Instance Method Details

#env_to_hash(env_string) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/dtf-session.rb', line 30

def env_to_hash(env_string)
  lines = env_string.split("\n")
  key_value_pairs = lines.map { |line|
    key, value = *line.split("=", 2)
    [key.to_sym, value]
  }

  Hash[key_value_pairs]
end

#set_start_env(shell) ⇒ Object



20
21
22
23
# File 'lib/dtf-session.rb', line 20

def set_start_env(shell)
  env = shell.execute('printenv')
  @start_env = self.env_to_hash(env[0])
end

#set_stop_env(shell) ⇒ Object



25
26
27
28
# File 'lib/dtf-session.rb', line 25

def set_stop_env(shell)
  env = shell.execute('printenv')
  @stop_env = self.env_to_hash(env[0])
end