class ActionView::DependencyTracker::ERBTracker
:nodoc:
:nodoc:
def self.call(name, template, view_paths = nil)
def self.call(name, template, view_paths = nil) new(name, template, view_paths).dependencies end
def self.supports_view_paths? # :nodoc:
def self.supports_view_paths? # :nodoc: true end
def add_dependencies(render_dependencies, arguments, pattern)
def add_dependencies(render_dependencies, arguments, pattern) arguments.scan(pattern) do match = Regexp.last_match add_dynamic_dependency(render_dependencies, match[:dynamic]) add_static_dependency(render_dependencies, match[:static], match[:quote]) end end
def add_dynamic_dependency(dependencies, dependency)
def add_dynamic_dependency(dependencies, dependency) if dependency dependencies << "#{dependency.pluralize}/#{dependency.singularize}" end end
def add_static_dependency(dependencies, dependency, quote_type)
def add_static_dependency(dependencies, dependency, quote_type) if quote_type == '"' # Ignore if there is interpolation return if dependency.include?('#{') end if dependency if dependency.include?("/") dependencies << dependency else dependencies << "#{directory}/#{dependency}" end end end
def dependencies
def dependencies render_dependencies + explicit_dependencies end
def directory
def directory name.split("/")[0..-2].join("/") end
def explicit_dependencies
def explicit_dependencies dependencies = source.scan(EXPLICIT_DEPENDENCY).flatten.uniq wildcards, explicits = dependencies.partition { |dependency| dependency.end_with?("/*") } (explicits + resolve_directories(wildcards)).uniq end
def initialize(name, template, view_paths = nil)
def initialize(name, template, view_paths = nil) @name, @template, @view_paths = name, template, view_paths end
def render_dependencies
def render_dependencies render_dependencies = [] render_calls = source.split(/\brender\b/).drop(1) render_calls.each do |arguments| add_dependencies(render_dependencies, arguments, LAYOUT_DEPENDENCY) add_dependencies(render_dependencies, arguments, RENDER_ARGUMENTS) end render_dependencies.uniq end
def resolve_directories(wildcard_dependencies)
def resolve_directories(wildcard_dependencies) return [] unless @view_paths return [] if wildcard_dependencies.empty? # Remove trailing "/*" prefixes = wildcard_dependencies.map { |query| query[0..-3] } @view_paths.flat_map(&:all_template_paths).uniq.filter_map { |path| path.to_s if prefixes.include?(path.prefix) }.sort end
def source
def source template.source end