Sha256: 278169e89538b06c1cb6d3b4ad633ecf50e06dbb14ffe78cc3bd8ef77e607a8b
Contents?: true
Size: 1.29 KB
Versions: 12
Compression:
Stored size: 1.29 KB
Contents
module Rabl # DependencyTracker for ActionView to support cache digest class Tracker # Matches: # extends "categories/show" EXTENDS_DEPENDENCY = / extends\s* # extends, followed by optional whitespace \(? # start an optional parenthesis for the extends call \s*["']([a-z_\/\.]+) # the template name itself /x # Matches: # partial "categories/show" PARTIAL_DEPENDENCY = / partial\s* # partial, followed by optional whitespace \(? # start an optional parenthesis for the partial call \s*["']([a-z_\/\.]+) # the template name itself /x def self.call(name, template) new(name, template).dependencies end def initialize(name, template) @name, @template = name, template end def dependencies (extends_dependencies + partial_dependencies).uniq end attr_reader :name, :template private :name, :template private def source template.source end def directory name.split("/")[0..-2].join("/") end def extends_dependencies source.scan(EXTENDS_DEPENDENCY).flatten end def partial_dependencies source.scan(PARTIAL_DEPENDENCY).flatten end end end
Version data entries
12 entries across 12 versions & 1 rubygems