Module: ERBProcess

Defined in:
lib/erb-process.rb,
lib/erbprocess/version.rb

Constant Summary collapse

VERSION =
'0.2.2'

Class Method Summary collapse

Class Method Details

.gethostnameObject



30
31
32
# File 'lib/erb-process.rb', line 30

def ERBProcess.gethostname
  return Socket.gethostname.first
end

.process(variables, template, env = "DEV") ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/erb-process.rb', line 8

def ERBProcess.process variables, template, env = "DEV"
  @variables =  variables
  @template = template
  env = env.chomp
  
  yml = YAML.load_file(@variables)
  #puts @template
  #puts yml.inspect
  config = {}
  yml.each_key do |key|
    if yml[key].has_key?(env.downcase)
      config[key] = yml[key][env.downcase]
    else
      warn "WARNING: "<< @variables<<" does not have a "<<key<<" for environment "<<env
    end
  end
  
  content = File.read(File.expand_path(@template))
  t = ERB.new(content)
  return t.result(binding)
end