Sha256: ed7a790c378970e153cff0a6310772094c2e3c12e155167ff6c4aac59a437946
Contents?: true
Size: 1.03 KB
Versions: 1
Compression:
Stored size: 1.03 KB
Contents
require 'erb' module Kryo module Generators # The base class for all generators to inherit from. # # @author Matthew A. Johnston (warmwaffles) class Base # Creates a file based off of the template provided. # # @param [String] src the source of the template file # @param [String] destination the destination of where the generated file will go # @param [Hash] options # @option options [String] :name The name of the template to be written as # @return [Boolean] def self.create src, destination, options={}, &block paths = File.split(src) template_name = paths.last template_path = paths.first path = File.join(File.dirname(__FILE__), template_path, "#{template_name}.erb") yield if block erb = ERB.new(File.read(path)) output = File.join(destination, options[:name] || template_name) file = File.open(output, 'w+') file.write(erb.result(binding)) file.close true end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
kryo-0.0.2 | lib/kryo/generators/base.rb |