class ActionView::FileSystemResolver
Experimental RBS support (using type sampling data from the type_fusion
project).
# sig/action_view/template/resolver.rbs class ActionView::FileSystemResolver < ActionView::Resolver def _find_all: (String name, String prefix, bool partial, Hash details, ActionView::TemplateDetails::Requested key, (Array[] | Array[Symbol]) locals) -> (Array[ActionView::Template] | Array[]) def build_unbound_template: (String template) -> ActionView::UnboundTemplate def escape_entry: (String entry) -> String def filter_and_sort_by_details: ((Array[ActionView::UnboundTemplate] | Array[]) templates, ActionView::TemplateDetails::Requested requested_details) -> (Array[] | Array[ActionView::UnboundTemplate]) def template_glob: (String glob) -> (Array[String] | Array[]) def unbound_templates_from_path: (ActionView::TemplatePath path) -> (Array[] | Array[ActionView::UnboundTemplate]) end
A resolver that loads files from the filesystem.
def _find_all(name, prefix, partial, details, key, locals)
Experimental RBS support (using type sampling data from the type_fusion
project).
def _find_all: (String name, String prefix, bool partial, (locale | | formats | | variants | | handlers | Symbol | Symbol | Symbol | Symbol | Symbol | locale | | formats | Symbol | variants | | handlers | Symbol | Symbol | Symbol | Symbol | Symbol) details, ActionView::TemplateDetails::Requested key, ( | Symbol) locals) ->
This signature was generated using 16 samples from 1 application.
def _find_all(name, prefix, partial, details, key, locals) requested_details = key || TemplateDetails::Requested.new(**details) cache = key ? @unbound_templates : Concurrent::Map.new unbound_templates = cache.compute_if_absent(TemplatePath.virtual(name, prefix, partial)) do path = TemplatePath.build(name, prefix, partial) unbound_templates_from_path(path) end filter_and_sort_by_details(unbound_templates, requested_details).map do |unbound_template| unbound_template.bind_locals(locals) end end
def all_template_paths # :nodoc:
def all_template_paths # :nodoc: paths = template_glob("**/*") paths.map do |filename| filename.from(@path.size + 1).remove(/\.[^\/]*\z/) end.uniq.map do |filename| TemplatePath.parse(filename) end end
def build_unbound_template(template)
Experimental RBS support (using type sampling data from the type_fusion
project).
def build_unbound_template: (String template) -> ActionView::UnboundTemplate
This signature was generated using 2 samples from 1 application.
def build_unbound_template(template) parsed = @path_parser.parse(template.from(@path.size + 1)) details = parsed.details source = source_for_template(template) UnboundTemplate.new( source, template, details: details, virtual_path: parsed.path.virtual, ) end
def clear_cache
def clear_cache @unbound_templates.clear @path_parser = PathParser.new super end
def eql?(resolver)
def eql?(resolver) self.class.equal?(resolver.class) && to_path == resolver.to_path end
def escape_entry(entry)
Experimental RBS support (using type sampling data from the type_fusion
project).
def escape_entry: (String entry) -> String
This signature was generated using 12 samples from 1 application.
def escape_entry(entry) entry.gsub(/[*?{}\[\]]/, '\\\\\\&') end
def filter_and_sort_by_details(templates, requested_details)
Experimental RBS support (using type sampling data from the type_fusion
project).
def filter_and_sort_by_details: ( templates, ActionView::TemplateDetails::Requested requested_details) ->
This signature was generated using 29 samples from 2 applications.
def filter_and_sort_by_details(templates, requested_details) filtered_templates = templates.select do |template| template.details.matches?(requested_details) end if filtered_templates.count > 1 filtered_templates.sort_by! do |template| template.details.sort_key_for(requested_details) end end filtered_templates end
def initialize(path)
def initialize(path) raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver) @unbound_templates = Concurrent::Map.new @path_parser = PathParser.new @path = File.expand_path(path) super() end
def source_for_template(template)
def source_for_template(template) Template::Sources::File.new(template) end
def template_glob(glob)
Experimental RBS support (using type sampling data from the type_fusion
project).
def template_glob: (String glob) ->
This signature was generated using 4 samples from 2 applications.
def template_glob(glob) query = File.join(escape_entry(@path), glob) path_with_slash = File.join(@path, "") Dir.glob(query).filter_map do |filename| filename = File.expand_path(filename) next if File.directory?(filename) next unless filename.start_with?(path_with_slash) filename end end
def to_s
def to_s @path.to_s end
def unbound_templates_from_path(path)
Experimental RBS support (using type sampling data from the type_fusion
project).
def unbound_templates_from_path: (ActionView::TemplatePath path) ->
This signature was generated using 11 samples from 1 application.
def unbound_templates_from_path(path) if path.name.include?(".") return [] end # Instead of checking for every possible path, as our other globs would # do, scan the directory for files with the right prefix. paths = template_glob("#{escape_entry(path.to_s)}*") paths.map do |path| build_unbound_template(path) end.select do |template| # Select for exact virtual path match, including case sensitivity template.virtual_path == path.virtual end end