Sha256: 32ea3ad2b03ab22f777380f96bda282a5672cad2cb317ee14235d951077bb2a1
Contents?: true
Size: 1.5 KB
Versions: 42
Compression:
Stored size: 1.5 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 @resolve_recipes ||= recipes_with_dependencies 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
42 entries across 42 versions & 2 rubygems