Make signature of Pathname#write compatible with Ruby 2.1+

This commit is contained in:
Jack Nagel 2014-06-17 09:31:31 -05:00
parent 40f552f891
commit b2c42fc63c

View File

@ -90,10 +90,10 @@ class Pathname
# we assume this pathname object is a file obviously
alias_method :old_write, :write if method_defined?(:write)
def write content
def write(content, *open_args)
raise "Will not overwrite #{to_s}" if exist?
dirname.mkpath
File.open(self, 'w') {|f| f.write content }
open("w", *open_args) { |f| f.write(content) }
end
# NOTE always overwrites