Sha256: 2ab9c0bc18df29d7b845c5f83c2ba4605999ae161aba417960dc5cd4de8534c3
Contents?: true
Size: 544 Bytes
Versions: 1
Compression:
Stored size: 544 Bytes
Contents
require 'tempfile' module Extensions module File def copylines(src, dst) tempfile = Tempfile.new(dst) begin open(src).each_line do |line| if block_given? new_line = yield(line) line = new_line unless new_line.nil? end tempfile.write line end FileUtils.chmod(stat(src).mode, tempfile.path) FileUtils.move(tempfile.path, dst) ensure tempfile.close! end end end end File.singleton_class.prepend Extensions::File
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
subshift-0.0.2 | lib/extensions/file.rb |