Sha256: c142bb06a410324487444567068abc4901f9375ead2881432ad4b744af319b34

Contents?: true

Size: 1.21 KB

Versions: 4

Compression:

Stored size: 1.21 KB

Contents

module Shift
	module Generator
		module RubyTemplates
			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 %>)"
		end
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
shift-lang-0.1.4 lib/shift-lang/generator/ruby_templates.rb
shift-lang-0.1.3 lib/shift-lang/generator/ruby_templates.rb
shift-lang-0.1.2 lib/shift-lang/generator/ruby_templates.rb
shift-lang-0.1.1 lib/shift-lang/generator/ruby_templates.rb