Sha256: c64fb75158e7e76473f228c6637b57be95b89302766a0af7fbc237c9e7077d66

Contents?: true

Size: 501 Bytes

Versions: 20

Compression:

Stored size: 501 Bytes

Contents

# frozen_string_literal: true

require 'erb'

module RakeGitCrypt
  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

20 entries across 20 versions & 1 rubygems

Version Path
rake_git_crypt-0.3.0.pre.2 lib/rake_git_crypt/template.rb
rake_git_crypt-0.3.0.pre.1 lib/rake_git_crypt/template.rb
rake_git_crypt-0.2.0 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.34 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.33 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.32 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.31 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.30 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.29 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.28 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.27 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.26 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.25 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.24 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.23 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.22 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.21 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.20 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.19 lib/rake_git_crypt/template.rb
rake_git_crypt-0.1.0.pre.18 lib/rake_git_crypt/template.rb