aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorJack Nagel2014-06-11 16:11:53 -0500
committerJack Nagel2014-06-12 09:00:51 -0500
commit31a298dcdd2065cbaf1fe1e45df1be3d9d0a2939 (patch)
tree14f2c5a86c7819dc0cd64fdd6497c30beaba4f8b /Library/Homebrew
parent30dc218e5a749a08ebee6a81651e808e5258820a (diff)
downloadhomebrew-31a298dcdd2065cbaf1fe1e45df1be3d9d0a2939.tar.bz2
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 #30079.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/extend/pathname.rb8
1 files changed, 6 insertions, 2 deletions
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