Class: Shipitron::MustacheYamlParser
- Inherits:
-
Object
- Object
- Shipitron::MustacheYamlParser
- Defined in:
- lib/shipitron/mustache_yaml_parser.rb
Instance Method Summary collapse
-
#initialize(context: nil, view: nil) ⇒ MustacheYamlParser
constructor
A new instance of MustacheYamlParser.
- #perform(file_path) ⇒ Object
Constructor Details
#initialize(context: nil, view: nil) ⇒ MustacheYamlParser
Returns a new instance of MustacheYamlParser.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/shipitron/mustache_yaml_parser.rb', line 6 def initialize(context:nil, view:nil) if (context.nil? && view.nil?) || (!context.nil? && !view.nil?) raise ArgumentError, 'Either context or view required' end @context = context @view = view @view ||= Mustache end |
Instance Method Details
#perform(file_path) ⇒ Object
17 18 19 20 |
# File 'lib/shipitron/mustache_yaml_parser.rb', line 17 def perform(file_path) file_path = file_path.is_a?(Pathname) ? file_path.to_s : file_path YAML.load(@view.render(File.read(file_path), @context)) end |