aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/evented_file_update_checker.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/evented_file_update_checker.rb')
-rw-r--r--activesupport/lib/active_support/evented_file_update_checker.rb108
1 files changed, 54 insertions, 54 deletions
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb
index a2dcf31132..f54f88eb0a 100644
--- a/activesupport/lib/active_support/evented_file_update_checker.rb
+++ b/activesupport/lib/active_support/evented_file_update_checker.rb
@@ -1,6 +1,6 @@
-require 'set'
-require 'pathname'
-require 'concurrent/atomic/atomic_boolean'
+require "set"
+require "pathname"
+require "concurrent/atomic/atomic_boolean"
module ActiveSupport
# Allows you to "listen" to changes in a file system.
@@ -52,7 +52,7 @@ module ActiveSupport
# to our test suite. Thus, we lazy load it and disable warnings locally.
silence_warnings do
begin
- require 'listen'
+ require "listen"
rescue LoadError => e
raise LoadError, "Could not load the 'listen' gem. Add `gem 'listen'` to the development group of your Gemfile", e.backtrace
end
@@ -124,71 +124,71 @@ module ActiveSupport
@ph.filter_out_descendants(dtw)
end
- class PathHelper
- def xpath(path)
- Pathname.new(path).expand_path
- end
+ class PathHelper
+ def xpath(path)
+ Pathname.new(path).expand_path
+ end
- def normalize_extension(ext)
- ext.to_s.sub(/\A\./, '')
- end
+ def normalize_extension(ext)
+ ext.to_s.sub(/\A\./, "")
+ end
- # Given a collection of Pathname objects returns the longest subpath
- # common to all of them, or +nil+ if there is none.
- def longest_common_subpath(paths)
- return if paths.empty?
-
- lcsp = Pathname.new(paths[0])
-
- paths[1..-1].each do |path|
- until ascendant_of?(lcsp, path)
- if lcsp.root?
- # If we get here a root directory is not an ascendant of path.
- # This may happen if there are paths in different drives on
- # Windows.
- return
- else
- lcsp = lcsp.parent
+ # Given a collection of Pathname objects returns the longest subpath
+ # common to all of them, or +nil+ if there is none.
+ def longest_common_subpath(paths)
+ return if paths.empty?
+
+ lcsp = Pathname.new(paths[0])
+
+ paths[1..-1].each do |path|
+ until ascendant_of?(lcsp, path)
+ if lcsp.root?
+ # If we get here a root directory is not an ascendant of path.
+ # This may happen if there are paths in different drives on
+ # Windows.
+ return
+ else
+ lcsp = lcsp.parent
+ end
end
end
- end
- lcsp
- end
+ lcsp
+ end
- # Returns the deepest existing ascendant, which could be the argument itself.
- def existing_parent(dir)
- dir.ascend do |ascendant|
- break ascendant if ascendant.directory?
+ # Returns the deepest existing ascendant, which could be the argument itself.
+ def existing_parent(dir)
+ dir.ascend do |ascendant|
+ break ascendant if ascendant.directory?
+ end
end
- end
- # Filters out directories which are descendants of others in the collection (stable).
- def filter_out_descendants(dirs)
- return dirs if dirs.length < 2
+ # Filters out directories which are descendants of others in the collection (stable).
+ def filter_out_descendants(dirs)
+ return dirs if dirs.length < 2
- dirs_sorted_by_nparts = dirs.sort_by { |dir| dir.each_filename.to_a.length }
- descendants = []
+ dirs_sorted_by_nparts = dirs.sort_by { |dir| dir.each_filename.to_a.length }
+ descendants = []
- until dirs_sorted_by_nparts.empty?
- dir = dirs_sorted_by_nparts.shift
+ until dirs_sorted_by_nparts.empty?
+ dir = dirs_sorted_by_nparts.shift
- dirs_sorted_by_nparts.reject! do |possible_descendant|
- ascendant_of?(dir, possible_descendant) && descendants << possible_descendant
+ dirs_sorted_by_nparts.reject! do |possible_descendant|
+ ascendant_of?(dir, possible_descendant) && descendants << possible_descendant
+ end
end
- end
- # Array#- preserves order.
- dirs - descendants
- end
+ # Array#- preserves order.
+ dirs - descendants
+ end
- private
+ private
- def ascendant_of?(base, other)
- base != other && other.ascend do |ascendant|
- break true if base == ascendant
+ def ascendant_of?(base, other)
+ base != other && other.ascend do |ascendant|
+ break true if base == ascendant
+ end
end
- end
- end
+ end
end
end