Given a collection of Pathname objects
returns the longest subpath common to all of them, or nil if there
is none.
# File activesupport/lib/active_support/evented_file_update_checker.rb, line 149
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
lcsp
end