From faaa622820deb067fa65d1207db119be950fad93 Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Wed, 11 Jun 2014 16:11:53 -0500 Subject: Deprecate Pathname#/ with non-string/non-pathname arguments Ruby 2.2 will define Pathname#/ as a simple alias of Pathname#+. In practice, this means that it will raise a TypeError unless the argument responds to to_path or to_str. Currently we blindly convert the argument to a string using to_s, so deprecate this in the interest of matching the upstream behavior. In the future we can replace this with alias_method :/, :+ unless method_defined?(:/) Closes Homebrew/homebrew#30079. --- Library/Homebrew/extend/pathname.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index aca499720..16287c23a 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -301,8 +301,12 @@ class Pathname File.symlink(src.relative_path_from(dirname), self) end - def / that - self + that.to_s + def /(other) + unless other.respond_to?(:to_str) || other.respond_to?(:to_path) + opoo "Pathname#/ called on #{inspect} with #{other.inspect} as an argument" + puts "This behavior is deprecated, please pass either a String or a Pathname" + end + self + other.to_s end unless method_defined?(:/) def ensure_writable -- cgit v1.2.3