Module: Shift::Generator::RubyTemplates

Defined in:
lib/shift-lang/generator/ruby_templates.rb

Constant Summary collapse

IMPORT_SINATRA_STATEMENT =
"require 'sinatra'"
IMPORT_MUSTACHE_STATEMENT =
"require 'mustache/sinatra'\n$mu_root = 'views/'"
IMPORT_DATAMAPPER_STATEMENT =
"require 'data_mapper'\n"
MODEL_NAME_TEMPLATE =
"class <%= model_name %>"
DATAMAPPER_INCLUDE_STATEMENT =
"include DataMapper::Resource"
DB_STRING_PROPERTY =
"Text"
DB_INTEGER_PROPERTY =
"Integer"
UTILITY_FUNCTIONS =
'
def read_file(file_name) 
	f = open($mu_root + file_name,"r")
	template = f.read()
	f.close()
	template
end

def read_template(file_name, template_values = nil)
	template = read_file(file_name)
	if (template_values == nil)
		template
	else
		Mustache.render(template, template_values)
	end
end'
CONFIGURE_BLOCK =
'
configure :development do
	DataMapper.setup(:default, (ENV["DATABASE_URL"] || "sqlite3://#{Dir.pwd}/test1.db"))
	DataMapper.finalize.auto_upgrade!
end'
WRITE_DATA_TEMPLATE =
"response_result = <%= write_data %>"
WRITE_RESPONSE_TEMPLATE =
'"#{response_result}"'
WRITE_FILE_TEMPLATE =
"read_template(<%= file_name %><% if template_values %>, <%= template_values %><% end %>)"
REDIRECT_STATEMENT_TEMPLATE =
"redirect(<%= url %>)"