Make signature of Pathname#write compatible with Ruby 2.1+
This commit is contained in:
parent
40f552f891
commit
b2c42fc63c
@ -90,10 +90,10 @@ class Pathname
|
|||||||
|
|
||||||
# we assume this pathname object is a file obviously
|
# we assume this pathname object is a file obviously
|
||||||
alias_method :old_write, :write if method_defined?(:write)
|
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?
|
raise "Will not overwrite #{to_s}" if exist?
|
||||||
dirname.mkpath
|
dirname.mkpath
|
||||||
File.open(self, 'w') {|f| f.write content }
|
open("w", *open_args) { |f| f.write(content) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# NOTE always overwrites
|
# NOTE always overwrites
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user