aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2015-11-11 06:15:54 +0100
committerXavier Noria <fxn@hashref.com>2015-11-11 06:24:34 +0100
commit40a1945d67869f660e7b07120a74106b0150ff23 (patch)
tree1f55def1701a5b992e37518d1be712669e300957 /activesupport
parent0eb6d198d3aaddb62b5241a707f6b1fcedfbedb8 (diff)
downloadrails-40a1945d67869f660e7b07120a74106b0150ff23.tar.gz
rails-40a1945d67869f660e7b07120a74106b0150ff23.tar.bz2
rails-40a1945d67869f660e7b07120a74106b0150ff23.zip
simplifies the implementation of #watching?
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/file_evented_update_checker.rb28
1 files changed, 12 insertions, 16 deletions
diff --git a/activesupport/lib/active_support/file_evented_update_checker.rb b/activesupport/lib/active_support/file_evented_update_checker.rb
index 8cb422ad36..6375de4a7d 100644
--- a/activesupport/lib/active_support/file_evented_update_checker.rb
+++ b/activesupport/lib/active_support/file_evented_update_checker.rb
@@ -50,23 +50,19 @@ module ActiveSupport
def watching?(file)
file = @ph.xpath(file)
- return true if @files.member?(file)
- return false if file.directory?
-
- ext = @ph.normalize_extension(file.extname)
- dir = file.dirname
-
- loop do
- if @dirs.fetch(dir, []).include?(ext)
- break true
- else
- if @lcsp
- break false if dir == @lcsp
- else
- break false if dir.root?
+ if @files.member?(file)
+ true
+ elsif file.directory?
+ false
+ else
+ ext = @ph.normalize_extension(file.extname)
+
+ file.dirname.ascend do |dir|
+ if @dirs.fetch(dir, []).include?(ext)
+ break true
+ elsif dir == @lcsp || dir.root?
+ break false
end
-
- dir = dir.parent
end
end
end