Class: Lono::Configset::Strategy::Erb
- Includes:
- Helpers
- Defined in:
- lib/lono/configset/strategy/erb.rb,
lib/lono/configset/strategy/erb/helpers.rb
Defined Under Namespace
Modules: Helpers
Instance Method Summary collapse
Methods included from Helpers
Methods inherited from Base
#build, #copy_instance_variables, #initialize, #load_blueprint_predefined_variables, #load_configset_helpers, #load_project_predefined_variables
Methods included from EvaluateFile
Constructor Details
This class inherits a constructor from Lono::Configset::Strategy::Base
Instance Method Details
#find_evaluation_path ⇒ Object
7 8 9 10 |
# File 'lib/lono/configset/strategy/erb.rb', line 7 def find_evaluation_path paths = %w[configset.yml configset.json].map { |p| "#{@root}/lib/#{p}" } paths.find { |p| File.exist?(p) } end |
#load ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/lono/configset/strategy/erb.rb', line 12 def load content = RenderMePretty.result(@evaluation_path, context: self) if File.extname(@evaluation_path) == ".yml" load_yaml(content) else JSON.load(content) end end |
#load_yaml(content) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/lono/configset/strategy/erb.rb', line 21 def load_yaml(content) # Write to file so can use Yamler::Validator path = "/tmp/lono/configset.yml" FileUtils.mkdir_p(File.dirname(path)) IO.write(path, content) Lono::Yamler::Validator.new(path).validate! Lono::Yamler::Loader.new(content).load end |