aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2014-05-10 11:52:13 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2014-05-10 11:53:02 -0700
commitc40df470556646a90a9070a077f19f8e520304f4 (patch)
tree87dda16296d8ed076f1eea17cb12966877705753 /actionpack
parent03e016f22aaebf09dc11a44f46598b4357b30de3 (diff)
downloadrails-c40df470556646a90a9070a077f19f8e520304f4.tar.gz
rails-c40df470556646a90a9070a077f19f8e520304f4.tar.bz2
rails-c40df470556646a90a9070a077f19f8e520304f4.zip
feature detect for FNM_EXTGLOB for older Ruby. Fixes #15053
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_view/template/resolver.rb26
1 files changed, 21 insertions, 5 deletions
diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb
index 51dd07a02f..27d11ab6fb 100644
--- a/actionpack/lib/action_view/template/resolver.rb
+++ b/actionpack/lib/action_view/template/resolver.rb
@@ -120,11 +120,7 @@ module ActionView
def query(path, details, formats)
query = build_query(path, details)
- template_paths = Dir[query].reject { |filename|
- File.directory?(filename) ||
- # deals with case-insensitive file systems.
- !File.fnmatch(query, filename, File::FNM_EXTGLOB)
- }
+ template_paths = find_template_paths query
template_paths.map { |template|
handler, format = extract_handler_and_format(template, formats)
@@ -137,6 +133,26 @@ module ActionView
}
end
+ if File.const_defined? :FNM_EXTGLOB
+ def find_template_paths(query)
+ Dir[query].reject { |filename|
+ File.directory?(filename) ||
+ # deals with case-insensitive file systems.
+ !File.fnmatch(query, filename, File::FNM_EXTGLOB)
+ }
+ end
+ else
+ def find_template_paths(query)
+ # deals with case-insensitive file systems.
+ sanitizer = Hash.new { |h,dir| h[dir] = Dir["#{dir}/*"] }
+
+ Dir[query].reject { |filename|
+ File.directory?(filename) ||
+ !sanitizer[File.dirname(filename)].include?(filename)
+ }
+ end
+ end
+
# Helper for building query glob string based on resolver's pattern.
def build_query(path, details)
query = @pattern.dup