1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/test/lib/fixture_template.rb
2009-09-03 11:40:03 -07:00

24 lines
No EOL
605 B
Ruby

module ActionView #:nodoc:
class FixtureResolver < PathResolver
def initialize(hash = {}, options = {})
super(options)
@hash = hash
end
private
def query(path, exts)
query = Regexp.escape(path)
exts.each do |ext|
query << '(?:' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')'
end
templates = []
@hash.select { |k,v| k =~ /^#{query}$/ }.each do |path, source|
templates << Template.new(source, path, *path_to_details(path))
end
templates.sort_by {|t| -t.details.values.compact.size }
end
end
end