aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend
diff options
context:
space:
mode:
authorAdam Vandenberg2014-07-27 16:21:35 -0700
committerAdam Vandenberg2014-07-27 16:21:35 -0700
commit38e99436dd27902250c08c69d22ac5b0d057f2cc (patch)
tree7065758d99269a25608794bac640df92f5d15206 /Library/Homebrew/extend
parent1b0e164ecd634af1fad536fdab3a8b86dd350386 (diff)
downloadhomebrew-38e99436dd27902250c08c69d22ac5b0d057f2cc.tar.bz2
backport binwrite from Ruby 2.1+
Diffstat (limited to 'Library/Homebrew/extend')
-rw-r--r--Library/Homebrew/extend/pathname.rb9
1 files changed, 3 insertions, 6 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index 253380982..fd97b2a35 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -93,12 +93,9 @@ class Pathname
open("w", *open_args) { |f| f.write(content) }
end
- # Note: Ruby 2.1+ has Pathname#write and Pathname#binwrite
- def binwrite binary_content
- raise "Will not overwrite #{to_s}" if exist?
- dirname.mkpath
- File.open(self, 'wb') {|f| f.write binary_content }
- end
+ def binwrite(contents, *open_args)
+ open("wb", *open_args) { |f| f.write(contents) }
+ end unless method_defined?(:binwrite)
# NOTE always overwrites
def atomic_write content