Sha256: e9da237e0d57d16a87bfde46959307614cf3cd759c765c010db67d5220908ea3

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

require 'rubygems'
require 'activesupport'
require 'erb'

module Taza
  module Generators
    class Base
      def file(template_file_name,output_file)
        write_file(output_file,render_template(template_file_name))
      end

      def render_template(template_file_name)
        template = ERB.new(read_template(template_file_name))
        template.result(binding)
      end

      def folder(path)
        underscored_path = Inflector.underscore(path)
        Dir.mkdir(underscored_path) unless File.directory?(underscored_path)
      end

      def write_file(output_file,contents)
        File.open(Inflector.underscore(output_file),"w") do |out|
          out << contents
        end
      end

      def read_template(template_file_name)
        File.read(File.join(File.dirname(__FILE__),"templates",template_file_name))
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
taza-0.5.0 lib/taza/generators/base.rb