Module: Flak::Template::MergeEngine

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.flatten_yaml_file(settings, file) ⇒ Object

substutute environment variables in yaml file and faltten out the os and configuration keys.



16
17
18
19
20
21
22
23
24
# File 'lib/flak/rake/templates/merge_engine.rb', line 16

def self.flatten_yaml_file(settings, file)
  if File.exists? file
    content = File.open(file, "rb").read.substitute_env_vars
    yml = YAML::load(content)  || {}
    yml.flak_flatten(settings[:configuration], settings[:os])   
  else
    {}
  end
end

Instance Method Details

#flatten_yaml(settings) ⇒ Object

open the yaml file associated with the current module and flatten it



28
29
30
31
# File 'lib/flak/rake/templates/merge_engine.rb', line 28

def flatten_yaml settings
  file = settings[:root] + '/config/'+self.name.split("::")[2].underscoreize+'.yml' 
  Flak::Template::MergeEngine.flatten_yaml_file(settings,file)
end

#infuse(target) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/flak/rake/templates/merge_engine.rb', line 5

def infuse target
  settings = target.settings
  flat = flatten_yaml settings
  settings = settings.flak_merge(flat)
  module_mods = settings_modifications(settings)
  target.settings = settings.flak_merge(module_mods)
end

#settings_modifications(settings) ⇒ Object

fallback modifications method for #Flak::Template::MergeEngine.selfself.name



36
37
38
# File 'lib/flak/rake/templates/merge_engine.rb', line 36

def settings_modifications settings
  {}
end