Sha256: 5e0560ce03e89fa8b63240b0da21131cdc6617b3231b6079a44e8031ac23bc8a

Contents?: true

Size: 546 Bytes

Versions: 1

Compression:

Stored size: 546 Bytes

Contents

# frozen_string_literal: true

module Specimen
  class ConfigParser
    class YmlERBError < StandardError; end

    def self.read!(file)
      new(file).yml_load!
    end

    def initialize(file)
      @file = file
    end

    def yml_load!
      YAML.safe_load(erb_content, aliases: true)
    end

    private

    def content
      File.read(@file)
    end

    def erb_content
      ERB.new(content, trim_mode: '%').result(binding)
    rescue StandardError
      raise YmlERBError, "#{@file} could not be parsed with ERB!"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
specimen-0.0.4.alpha lib/specimen/config_parser.rb