Module: Config

Defined in:
lib/tabbyx/core/config.rb

Class Method Summary collapse

Class Method Details

.read_config(product, server, target) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/tabbyx/core/config.rb', line 13

def Config::read_config(product, server, target)

  users_yml = Base.read_yaml('users')
  hosts_yml = Base.read_yaml('hosts')
  server_yml = Base.read_yaml('server')
  password_yml = Base.read_yaml('passwords')
  app_yml = Base.read_yaml('app')
  device_yml = Base.read_yaml('devices')
  config = {
      :server => (Base.read_yaml('server')[server] if server_yml),
      :user => (Base.read_yaml('users')[product][server] if users_yml),
      :password => (Base.read_yaml('passwords')[server] if password_yml),
      :app => (Base.read_yaml('app')[product] if app_yml),
      :device => (Base.read_yaml('devices')[target] if device_yml),
      :host => (Base.read_yaml('hosts')[product][server] if hosts_yml),
  }

  # Make sure everything is strings
  config.each do |key, value|
    config[key] = value.stringify if value.respond_to?(:stringify)
  end
end