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