Class: Shards::Config

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

Constant Summary collapse

ENV_VARS =
%w(ENGINEERING_ROOT_PATH CONFIG_FILE PROXY_SUBDOMAIN DOMAIN CONFIG_FILES_ROOT_PATH ) +
%w(SHARDS_FILE_NAME SITES_FILE_NAME CONFIG_DIR_SUFFIX DNS_ZONE_CODE REMOTE_SERVER_CURRENT_PATH) +
%w(PATH_TO_ENGINEERING_YAML)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(settings_file = 'settings.env', origin_file = nil) ⇒ Config

Returns a new instance of Config.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/shards/config.rb', line 16

def initialize settings_file='settings.env', origin_file=nil

  @settings_file=settings_file

  Dotenv.load(settings_file)

  ENV_VARS.each { |variable| validate variable }

  @repo=Shards::Repo.new

  @locations={}

  data=YAML.load_file(origin_file || File.join(repo.root,config_file) )

  add_locations data

end

Instance Attribute Details

#locationsObject

Returns the value of attribute locations.



14
15
16
# File 'lib/shards/config.rb', line 14

def locations
  @locations
end

#repoObject

Returns the value of attribute repo.



14
15
16
# File 'lib/shards/config.rb', line 14

def repo
  @repo
end

#settings_fileObject

Returns the value of attribute settings_file.



14
15
16
# File 'lib/shards/config.rb', line 14

def settings_file
  @settings_file
end

Instance Method Details

#add_locations(data) ⇒ Object



34
35
36
37
38
# File 'lib/shards/config.rb', line 34

def add_locations data
  data['Locations'].each_pair do |name,location_data|
    @locations[name.downcase]=Location.new( name, location_data)
  end
end