Module: ConfigTemplate

Defined in:
lib/docker-sync/config_template.rb

Class Method Summary collapse

Class Method Details

.interpolate_config_file(config_path) ⇒ Object



12
13
14
15
16
# File 'lib/docker-sync/config_template.rb', line 12

def self.interpolate_config_file(config_path)
    # assuming the checks that file exist have already been performed
    config_string = File.read(config_path)
    self.interpolate_config_string(config_string)
end

.interpolate_config_string(config_string) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/docker-sync/config_template.rb', line 5

def self.interpolate_config_string(config_string)
    env_hash = {}
    ENV.each {|k,v| env_hash[k.to_sym] = v }
    config_string.gsub!('${', '%{')
    config_string = config_string % env_hash
    return YAML.load(config_string)
end