Sha256: bfa08580e751efb48c6b6bf09635178c250cc7106b66f676bc87eda854bec51d

Contents?: true

Size: 510 Bytes

Versions: 1

Compression:

Stored size: 510 Bytes

Contents

require "params_builder/version"
require "params_builder/configuration"
require "yaml"

module ParamsBuilder
  def self.root
    File.dirname __dir__
  end

  def self.build(file_name, variables = {})
    erb_context = Struct.new(*variables.keys) do
      def with_binding
        binding
      end
    end

    path = "#{config.file_path}/#{file_name}.yml.erb"

    YAML.load_stream(
      ERB.new(File.read(path)).result(
        erb_context.new(*variables.values).with_binding
      )
    ).first
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
params_builder-0.1.0 lib/params_builder.rb