Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions lib/pathname_builtin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,12 @@ class Pathname

# :stopdoc:

SAME_PATHS = if File::FNM_SYSCASE.nonzero?
if File::FNM_SYSCASE.nonzero?
# Avoid #zero? here because #casecmp can return nil.
proc {|a, b| a.casecmp(b) == 0}
private def same_paths?(a, b) a.casecmp(b) == 0 end
else
proc {|a, b| a == b}
private def same_paths?(a, b) a == b end
end
SAME_PATHS.freeze
private_constant :SAME_PATHS

attr_reader :path
protected :path
Expand Down Expand Up @@ -836,12 +834,12 @@ def relative_path_from(base_directory)
base_prefix, basename = r
base_names.unshift basename if basename != '.'
end
unless SAME_PATHS[dest_prefix, base_prefix]
unless same_paths?(dest_prefix, base_prefix)
raise ArgumentError, "different prefix: #{dest_prefix.inspect} and #{base_directory.inspect}"
end
while !dest_names.empty? &&
!base_names.empty? &&
SAME_PATHS[dest_names.first, base_names.first]
same_paths?(dest_names.first, base_names.first)
dest_names.shift
base_names.shift
end
Expand Down
5 changes: 5 additions & 0 deletions test/pathname/test_ractor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ class Ractor
x.join(Pathname("b"), Pathname("c"))
end
assert_equal(Pathname("a/b/c"), r.value)

r = Ractor.new Pathname("a") do |a|
Pathname("b").relative_path_from(a)
end
assert_equal(Pathname("../b"), r.value)
end;
end
end