Module: GoobyConfiguration

Included in:
GoobyGoogleKmlGenerator, GoobyGoogleMapGenerator, GoobyProcess
Defined in:
lib/gooby_configuration.rb

Overview

Gooby = Google APIs + Ruby. Copyright 2009 by Chris Joakim. Gooby is available under GNU General Public License (GPL) license.

Instance Method Summary collapse

Instance Method Details

#gooby_homeObject



10
11
12
# File 'lib/gooby_configuration.rb', line 10

def gooby_home
  ENV['GOOBY_HOME']
end

#read_configuration(additional_config_file) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/gooby_configuration.rb', line 14

def read_configuration(additional_config_file)
  
  # First load the base config file into @configuration
  base_config_file = "#{gooby_home}/config/gooby_config.yaml"
  if File.exist?(base_config_file)
    puts "loading base configuration file #{base_config_file}"
    File.open(base_config_file) { | f | @configuration = YAML::load(f) }
  else
    puts "ERROR: the base configuration file does not exist - #{base_config_file}"
  end
  
  # Optionally load a second map-specific config file and overlay any
  # values in the base configuration.
  if (additional_config_file) && (File.exist?(additional_config_file))
    puts "loading additional configuration file #{additional_config_file}"      
    File.open(additional_config_file) { | f | @additional_config = YAML::load(f) }
    @additional_config.keys.each { | key |
      value = @additional_config[key]
      @configuration[key] = value
      # puts "'#{key}' overlaid with '#{value}'"
    }
  else
    puts "ERROR: the additional configuration file does not exist - #{additional_config_file}"
  end
  GoobyBaseObject.set_config(@configuration)
end