Module: Stackr::TemplateHelpers

Defined in:
lib/stackr/template_helpers.rb

Instance Method Summary collapse

Instance Method Details

#find_in_env(name) ⇒ Object



24
25
26
27
28
29
30
# File 'lib/stackr/template_helpers.rb', line 24

def find_in_env(name)
  if ENV['ENVIRONMENT'].nil?
    raise Stackr::EnvironmentMissingError, 'Please set ENVIRONMENT environment variable.'
  end
  map = load_environment_map()
  return map[ ENV['ENVIRONMENT'].to_sym ][name.to_sym]
end

#find_in_env_map(name) ⇒ Object

DEPRECATED: This is the old version of find_in_env() It fails when there are more than 64 attributes in the map. Use new find_in_env() instead



11
12
13
# File 'lib/stackr/template_helpers.rb', line 11

def find_in_env_map(name)
  find_in_map('EnvironmentMap', ref('Environment'), name)
end

#include_file(filepath, locals = {}) ⇒ Object



32
33
34
# File 'lib/stackr/template_helpers.rb', line 32

def include_file(filepath, locals={})
  interpolate(file(filepath), locals)
end

#load_environment_map(includes_path = 'includes') ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/stackr/template_helpers.rb', line 15

def load_environment_map(includes_path='includes')
  if @environment_map.nil?
    map_path = File.join(includes_path, 'environment_map.rb')
    mappings = eval(File.read(map_path))
    @environment_map = mappings['Mappings']['EnvironmentMap']
  end
  @environment_map
end