Class: LitleOnline::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/Configuration.rb

Class Attribute Summary collapse

Instance Method Summary collapse

Class Attribute Details

.loggerObject

External logger, if specified



34
35
36
# File 'lib/Configuration.rb', line 34

def logger
  @logger
end

Instance Method Details

#configObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/Configuration.rb', line 37

def config
  begin
    if !(ENV['LITLE_CONFIG_DIR'].nil?)
      config_file = ENV['LITLE_CONFIG_DIR'] + "/.litle_SDK_config.yml"
    else
      config_file = ENV['HOME'] + "/.litle_SDK_config.yml"        
    end
    #if Env variable exist, then just override the data from config file
     if (File.exists?(config_file))
      datas=YAML.load_file(config_file)  
     else         
      environments = EnvironmentVariables.new   
      datas={}
      environments.instance_variables.each {|var| datas[var.to_s.delete("@")] = environments.instance_variable_get(var) }          
     end
      datas.each {|key,value| setENV(key,datas)}                      
    return datas
  rescue   
    return {}
  end
  
end

#setENV(key, datas) ⇒ Object



59
60
61
62
63
# File 'lib/Configuration.rb', line 59

def setENV(key,datas)
  if !(ENV['litle_'+key].nil?)
   datas[key]=ENV['litle_'+key]
  end
end