Class: TemplateParser

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/core/template_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command) ⇒ TemplateParser

Returns a new instance of TemplateParser.



10
11
12
# File 'lib/core/template_parser.rb', line 10

def initialize(command)
  @command = command
end

Instance Attribute Details

#deprecated_variablesObject (readonly)

Returns the value of attribute deprecated_variables.



8
9
10
# File 'lib/core/template_parser.rb', line 8

def deprecated_variables
  @deprecated_variables
end

Instance Method Details

#parse(filenames) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/core/template_parser.rb', line 22

def parse(filenames)
  @deprecated_variables = {}

  filenames.each_with_object([]) do |filename, templates|
    yaml_file = File.read(filename)
    yaml_file = replace_variables(yaml_file)

    template_yamls = yaml_file.split(/^---\s*$/)
    template_yamls.each do |template_yaml|
      template = YAML.safe_load(template_yaml)
      templates.push(template)
    end
  end
end

#template_dirObject



14
15
16
# File 'lib/core/template_parser.rb', line 14

def template_dir
  "#{config.app_cpln_dir}/templates"
end

#template_filename(name) ⇒ Object



18
19
20
# File 'lib/core/template_parser.rb', line 18

def template_filename(name)
  "#{template_dir}/#{name}.yml"
end