Sha256: 148d29db251337d42ef4de1c6eff3853f3e6b449fc39a6334f0cb8d7647970ad

Contents?: true

Size: 631 Bytes

Versions: 2

Compression:

Stored size: 631 Bytes

Contents

# encoding: UTF-8

require "erb"

module Gjp
  # operates on files in template/
  class TemplateManager
    include Logger

    attr_reader :template_path

    def initialize
      @template_path = File.join(File.dirname(__FILE__), "..", "template")
    end

    def copy(template_name, destination_dir)
      FileUtils.cp_r(File.join(template_path, template_name), destination_dir)
    end

    def generate(template_name, object_binding, destination_path)
      erb = ERB.new File.read(File.join(template_path, template_name))
      File.open(destination_path, "w") { |io| io.write erb.result(object_binding) }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gjp-0.14.1 lib/gjp/template_manager.rb
gjp-0.13.1 lib/gjp/template_manager.rb