lib/core/common.rb in buildr-0.22.0 vs lib/core/common.rb in buildr-1.0.0

- old
+ new

@@ -33,13 +33,13 @@ # # Yields to the block before writing the file, so you can chain read and write together. # For example: # write("README") { read("README").sub("${build}", Time.now) } def write(name, content = nil) - mkpath File.dirname(name) + mkpath File.dirname(name), :verbose=>false content = yield if block_given? - File.open(name.to_s, "w") { |file| file.write content.to_s } + File.open(name.to_s, "wb") { |file| file.write content.to_s } content.to_s end # :call-seq: # read(name) => string @@ -50,13 +50,14 @@ # # For example: # puts read("README") # read("README") { |text| puts text } def read(name) + contents = File.open(name.to_s) { |f| f.read } if block_given? - yield File.read(name.to_s) + yield contents else - File.read(name.to_s) + contents end end # :call-seq: # download(url_or_uri) => task