Class: ResolveTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/apollo_commons_ruby/ResolveTemplate.rb

Instance Method Summary collapse

Instance Method Details

#resolveEnv(data_template, configuration, tenant_id, project_id) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/apollo_commons_ruby/ResolveTemplate.rb', line 6

def resolveEnv(data_template, configuration, tenant_id, project_id)
  envFilePath = configuration.env_file_path(tenant_id, project_id)
  if(file_exists?(envFilePath))
    envData = read_data_from_file_path(envFilePath)
    envData = JSON.parse(envData)
    data_template = data_template.force_encoding("UTF-8")
    envData.each do |key, value|
      substring_key = "{{" + key + "}}"
      if data_template.include? substring_key
        puts "Replacing " + substring_key
        data_template.gsub! substring_key, value
      end
    end
  end
  return data_template
end

#resolveLang(data_template, configuration, language) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/apollo_commons_ruby/ResolveTemplate.rb', line 23

def resolveLang(data_template, configuration, language)
  langFilePath = configuration.language_file_path_for_template(language)
  if(file_exists?(langFilePath))
    langData = read_res_data_from_file_path(langFilePath)
    langData = JSON.parse(langData)
    data_template = data_template.force_encoding("UTF-8")
    langData.each do |key, value|
      substring_key = "<<" + key + ">>"
      if data_template.include? substring_key
        puts "Replacing " + substring_key
        data_template.gsub! substring_key, value
      end
    end
  end
  return data_template
end