Sha256: ad29d061ddae1701f99592102acb9f1ee33477c95492eb4c856c8ea8dc970f7d
Contents?: true
Size: 1.44 KB
Versions: 5
Compression:
Stored size: 1.44 KB
Contents
module RailsWizard class Template attr_reader :recipes def initialize(recipes) @recipes = recipes.map{|r| RailsWizard::Recipe.from_mongo(r)} end def self.template_root File.dirname(__FILE__) + '/../../templates' end def self.render(template_name, binding = nil) erb = ERB.new(File.open(template_root + '/' + template_name + '.erb').read) erb.result(binding) end def render(template_name, binding = nil); self.class.render(template_name, binding) end def resolve_recipes @resolve_recipes ||= recipes_with_dependencies.sort end def recipe_classes @recipe_classes ||= recipes.map{|r| RailsWizard::Recipe.from_mongo(r)} end def recipes_with_dependencies @recipes_with_dependencies ||= recipe_classes added_more = false for recipe in recipe_classes recipe.requires.each do |requirement| requirement = RailsWizard::Recipe.from_mongo(requirement) count = @recipes_with_dependencies.size (@recipes_with_dependencies << requirement).uniq! unless @recipes_with_dependencies.size == count added_more = true end end end added_more ? recipes_with_dependencies : @recipes_with_dependencies end def compile render 'layout', binding end def args recipes.map(&:args).uniq end def custom_code?; false end def custom_code; nil end end end
Version data entries
5 entries across 5 versions & 1 rubygems