Class: RSpec::Pipeline::TemplateLoader
- Inherits:
-
Object
- Object
- RSpec::Pipeline::TemplateLoader
- Defined in:
- lib/rspec/pipeline/template_loader.rb
Overview
This class loads and validates templates from YAML files.
Instance Method Summary collapse
-
#initialize ⇒ TemplateLoader
constructor
A new instance of TemplateLoader.
-
#load(type, template, repo, parameters) ⇒ Object
rubocop:disable Metrics/MethodLength.
Constructor Details
#initialize ⇒ TemplateLoader
Returns a new instance of TemplateLoader.
11 12 13 |
# File 'lib/rspec/pipeline/template_loader.rb', line 11 def initialize @repo_stack = ['.'] end |
Instance Method Details
#load(type, template, repo, parameters) ⇒ Object
rubocop:disable Metrics/MethodLength
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/rspec/pipeline/template_loader.rb', line 15 def load(type, template, repo, parameters) # rubocop:disable Metrics/MethodLength template_content = load_template_file(repo, template) parameters&.each do |key, value| template_content = template_content.gsub("${{ parameters.#{key} }}", value) end yaml_template = YAML.safe_load(template_content) validate_parameters_not_found(parameters, yaml_template) validate_required_parameters_not_defined(parameters, yaml_template) yaml_template[type]&.map do |item| item['_meta'] = { 'repo' => repo } end yaml_template[type] end |