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

24 lines
605 B
Ruby
Raw Normal View History

2009-03-23 18:45:01 -04:00
module ActionView #:nodoc:
2009-09-02 18:00:22 -04:00
class FixtureResolver < PathResolver
2009-04-27 21:21:26 -04:00
def initialize(hash = {}, options = {})
super(options)
@hash = hash
end
2009-04-27 21:21:26 -04:00
private
2009-09-02 18:00:22 -04:00
def query(path, exts)
query = Regexp.escape(path)
exts.each do |ext|
query << '(?:' << ext.map {|e| e && Regexp.escape(".#{e}") }.join('|') << ')'
2009-04-27 21:21:26 -04:00
end
2009-06-23 17:45:27 -04:00
2009-09-02 18:00:22 -04:00
templates = []
@hash.select { |k,v| k =~ /^#{query}$/ }.each do |path, source|
templates << Template.new(source, path, *path_to_details(path))
2009-04-27 21:21:26 -04:00
end
2009-09-02 18:00:22 -04:00
templates.sort_by {|t| -t.details.values.compact.size }
2009-03-23 18:45:01 -04:00
end
2009-09-02 18:00:22 -04:00
2009-03-23 18:45:01 -04:00
end
end