Sha256: b2bd34e875a26cafe59e24540171842b908f95666113850f087a8e64877a1037

Contents?: true

Size: 500 Bytes

Versions: 10

Compression:

Stored size: 500 Bytes

Contents

# frozen_string_literal: true

require 'erb'

module RakeSecrets
  class Template
    def self.from_file(path)
      new(File.read(path))
    end

    def initialize(contents)
      @contents = contents
    end

    def render(parameters = {})
      context = Object.new
      parameters.each do |key, value|
        context.instance_variable_set("@#{key}", value)
      end
      context_binding = context.instance_eval { binding }
      ERB.new(@contents).result(context_binding)
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rake_secrets-0.3.0.pre.2 lib/rake_secrets/template.rb
rake_secrets-0.3.0.pre.1 lib/rake_secrets/template.rb
rake_secrets-0.2.0 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.8 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.7 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.6 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.5 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.4 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.3 lib/rake_secrets/template.rb
rake_secrets-0.1.0.pre.2 lib/rake_secrets/template.rb