Sha256: 4075f8d16339fb534f9e0150c804fe34e6358089701bea1bad8641127dbbaf5d

Contents?: true

Size: 524 Bytes

Versions: 17

Compression:

Stored size: 524 Bytes

Contents

require 'mustache'
require 'yaml'

module Shipitron
  class MustacheYamlParser
    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

    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
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
shipitron-1.3.1 lib/shipitron/mustache_yaml_parser.rb
shipitron-1.3.0 lib/shipitron/mustache_yaml_parser.rb
shipitron-1.2.1 lib/shipitron/mustache_yaml_parser.rb
shipitron-1.2.0 lib/shipitron/mustache_yaml_parser.rb
shipitron-1.1.0 lib/shipitron/mustache_yaml_parser.rb
shipitron-1.0.1 lib/shipitron/mustache_yaml_parser.rb
shipitron-1.0.0 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.4.1 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.4.0 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.3.5 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.3.4 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.3.3 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.3.1 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.3.0 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.2.2 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.2.1 lib/shipitron/mustache_yaml_parser.rb
shipitron-0.2.0 lib/shipitron/mustache_yaml_parser.rb