Class: TemplateParser
- Inherits:
-
Object
- Object
- TemplateParser
- Defined in:
- lib/core/template_parser.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#deprecated_variables ⇒ Object
readonly
Returns the value of attribute deprecated_variables.
Instance Method Summary collapse
-
#initialize(config) ⇒ TemplateParser
constructor
A new instance of TemplateParser.
- #parse(filenames) ⇒ Object
- #template_dir ⇒ Object
- #template_filename(name) ⇒ Object
Constructor Details
#initialize(config) ⇒ TemplateParser
Returns a new instance of TemplateParser.
6 7 8 |
# File 'lib/core/template_parser.rb', line 6 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
4 5 6 |
# File 'lib/core/template_parser.rb', line 4 def config @config end |
#deprecated_variables ⇒ Object (readonly)
Returns the value of attribute deprecated_variables.
4 5 6 |
# File 'lib/core/template_parser.rb', line 4 def deprecated_variables @deprecated_variables end |
Instance Method Details
#parse(filenames) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/core/template_parser.rb', line 18 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_dir ⇒ Object
10 11 12 |
# File 'lib/core/template_parser.rb', line 10 def template_dir "#{config.app_cpln_dir}/templates" end |
#template_filename(name) ⇒ Object
14 15 16 |
# File 'lib/core/template_parser.rb', line 14 def template_filename(name) "#{template_dir}/#{name}.yml" end |