This method returns the maximum mtime of the files in paths, or
nil if the array is empty.
Files with a mtime in the future are ignored. Such abnormal situation can
happen for example if the user changes the clock by hand. It is healthy to
consider this edge case because with mtimes in the future reloading is not
triggered.
# File activesupport/lib/active_support/file_update_checker.rb, line 115
def max_mtime(paths)
time_now = Time.now
max_mtime = nil
# Time comparisons are performed with #compare_without_coercion because
# AS redefines these operators in a way that is much slower and does not
# bring any benefit in this particular code.
#
# Read t1.compare_without_coercion(t2) < 0 as t1 < t2.
paths.each do |path|
mtime = File.mtime(path)
next if time_now.compare_without_coercion(mtime) < 0
if max_mtime.nil? || max_mtime.compare_without_coercion(mtime) < 0
max_mtime = mtime
end
end
max_mtime
end