require 'erb' module Bivouac module Template def createDir( dirname ) puts "\tcreate #{dirname}" FileUtils::mkdir_p( "#{dirname}" ) end def createFile( filename, chmod_x = false, &block ) puts "\tcreate #{filename}" open( "#{filename}", "w" ) { |io| yield( io ) } FileUtils::chmod 0755, filename if chmod_x end def copyTemplate( file, dest ) puts "\tcreate #{dest}" src = File.dirname(__FILE__) + "/template/" + file FileUtils::cp( src, dest ) end def template( template_name, b = nil ) template_file = File.dirname(__FILE__) + "/template/" + template_name + ".rb" result = if b.nil? ERB.new(File.readlines(template_file).join, nil, '-').result( ) else ERB.new(File.readlines(template_file).join, nil, '-').result( b ) end return( result ) end end end