Sha256: 09154b48165caa5b816270fd6b9ba88e13f23aee764e3346d1bb0a96b48f0bc9
Contents?: true
Size: 1.76 KB
Versions: 9
Compression:
Stored size: 1.76 KB
Contents
module AppScrollsScrolls class Template attr_reader :scrolls, :unknown_scroll_names def initialize(scrolls) @unknown_scroll_names = [] @scrolls = scrolls.inject([]) do |list, name| scroll = AppScrollsScrolls::Scroll.from_mongo(name) if scroll list << scroll else @unknown_scroll_names << name $stderr.puts "Unknown scroll '#{name}'. Skipping." end list end 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_scrolls @resolve_scrolls ||= scrolls_with_dependencies.sort.sort end def scroll_classes @scroll_classes ||= scrolls.map { |name| AppScrollsScrolls::Scroll.from_mongo(name) } end def scrolls_with_dependencies @scrolls_with_dependencies ||= scroll_classes added_more = false for scroll in scroll_classes scroll.requires.each do |requirement| requirement = AppScrollsScrolls::Scroll.from_mongo(requirement) count = @scrolls_with_dependencies.size (@scrolls_with_dependencies << requirement).uniq! unless @scrolls_with_dependencies.size == count added_more = true end end end added_more ? scrolls_with_dependencies : @scrolls_with_dependencies end def compile render 'layout', binding end def args scrolls.map(&:args).uniq end def custom_code?; false end def custom_code; nil end end end
Version data entries
9 entries across 9 versions & 1 rubygems