Sha256: 3ba133e20040c269a8dabe5923c035af58d0a06cc13f1864b5c61bb822358f85

Contents?: true

Size: 501 Bytes

Versions: 4

Compression:

Stored size: 501 Bytes

Contents

require 'forwardable'

module ActiveMocker
  class TemplateCreator

    def initialize(erb_template:, file_out: nil, binding:)
      @erb_template = erb_template
      @binding      = binding
      @file_out     = file_out || Tempfile.new('TemplateModel')
    end

    def render
      template = ERB.new(erb_template.read, nil, '>')
      file_out.write template.result(binding).gsub(/\n{2,5}/, "\n\n")
      file_out
    end

    private

    attr_reader :erb_template, :binding, :file_out
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
active_mocker-2.0.0 lib/active_mocker/template_creator.rb
active_mocker-2.0.0.rc1 lib/active_mocker/template_creator.rb
active_mocker-2.0.0.pre1 lib/active_mocker/template_creator.rb
active_mocker-2.0.0.beta1 lib/active_mocker/template_creator.rb