aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/core_ext/object/blank.rb2
-rw-r--r--activesupport/lib/active_support/evented_file_update_checker.rb22
-rw-r--r--activesupport/test/file_update_checker_shared_tests.rb12
3 files changed, 18 insertions, 18 deletions
diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb
index d6bad98376..b08321aeeb 100644
--- a/activesupport/lib/active_support/core_ext/object/blank.rb
+++ b/activesupport/lib/active_support/core_ext/object/blank.rb
@@ -115,7 +115,7 @@ class String
# fallback. Penalty for the rest of strings is marginal.
#
# Double negation in the second operand is also a performance tweak, it is
- # faster than the positive \A[[:space:]]*\z due to lack of backtracking.
+ # faster than the positive \A[[:space:]]*\z.
empty? || !(/[[:^space:]]/ === self)
end
end
diff --git a/activesupport/lib/active_support/evented_file_update_checker.rb b/activesupport/lib/active_support/evented_file_update_checker.rb
index 6a02a838b7..21fdf7bb80 100644
--- a/activesupport/lib/active_support/evented_file_update_checker.rb
+++ b/activesupport/lib/active_support/evented_file_update_checker.rb
@@ -86,16 +86,6 @@ module ActiveSupport
end
class PathHelper
- using Module.new {
- refine Pathname do
- def ascendant_of?(other)
- self != other && other.ascend do |ascendant|
- break true if self == ascendant
- end
- end
- end
- }
-
def xpath(path)
Pathname.new(path).expand_path
end
@@ -112,7 +102,7 @@ module ActiveSupport
lcsp = Pathname.new(paths[0])
paths[1..-1].each do |path|
- until lcsp.ascendant_of?(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
@@ -145,13 +135,21 @@ module ActiveSupport
dir = dirs_sorted_by_nparts.shift
dirs_sorted_by_nparts.reject! do |possible_descendant|
- dir.ascendant_of?(possible_descendant) && descendants << possible_descendant
+ ascendant_of?(dir, possible_descendant) && descendants << possible_descendant
end
end
# Array#- preserves order.
dirs - descendants
end
+
+ private
+
+ def ascendant_of?(base, other)
+ base != other && other.ascend do |ascendant|
+ break true if base == ascendant
+ end
+ end
end
end
end
diff --git a/activesupport/test/file_update_checker_shared_tests.rb b/activesupport/test/file_update_checker_shared_tests.rb
index 12e67a1e9f..40ae0c7617 100644
--- a/activesupport/test/file_update_checker_shared_tests.rb
+++ b/activesupport/test/file_update_checker_shared_tests.rb
@@ -9,7 +9,7 @@ module FileUpdateCheckerSharedTests
end
def tmpfile(name)
- "#{tmpdir}/#{name}"
+ File.join(tmpdir, name)
end
def tmpfiles
@@ -17,7 +17,9 @@ module FileUpdateCheckerSharedTests
end
def run(*args)
- Dir.mktmpdir(nil, __dir__) { |dir| @tmpdir = dir; super }
+ capture_exceptions do
+ Dir.mktmpdir(nil, __dir__) { |dir| @tmpdir = dir; super }
+ end
end
test 'should not execute the block if no paths are given' do
@@ -225,7 +227,7 @@ module FileUpdateCheckerSharedTests
assert !checker.execute_if_updated
assert_equal 0, i
- touch("#{subdir}/nested.rb")
+ touch(File.join(subdir, "nested.rb"))
assert checker.execute_if_updated
assert_equal 1, i
@@ -245,12 +247,12 @@ module FileUpdateCheckerSharedTests
assert_equal 0, i
# subdir does not look for Ruby files, but its parent tmpdir does.
- touch("#{subdir}/nested.rb")
+ touch(File.join(subdir, "nested.rb"))
assert checker.execute_if_updated
assert_equal 1, i
- touch("#{subdir}/nested.txt")
+ touch(File.join(subdir, "nested.txt"))
assert checker.execute_if_updated
assert_equal 2, i