Sha256: 15f0646ad78524c473578ba99928ed891d25f658ab80129e3d9ed78f30c9ce28
Contents?: true
Size: 838 Bytes
Versions: 1
Compression:
Stored size: 838 Bytes
Contents
# frozen_string_literal: true require 'liquid' require 'yaml' module Frise # Provides a static parse method for reading a config from a YAML file applying the required # transformations. module Parser class << self def parse(file, symbol_table = nil) return nil unless File.file? file YAML.safe_load(parse_as_text(file, symbol_table), aliases: true) || {} end def parse_as_text(file, symbol_table = nil) return nil unless File.file? file content = File.read(file) content = Liquid::Template.parse(content).render with_internal_vars(file, symbol_table) if symbol_table content end private def with_internal_vars(file, symbol_table) symbol_table.merge('_file_dir' => File.expand_path(File.dirname(file))) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
frise-0.5.1 | lib/frise/parser.rb |