Sha256: eeb513f2f9c3b296aaf2a3f1046d049fc623206959e2632d44ad07c0085689b1

Contents?: true

Size: 370 Bytes

Versions: 1

Compression:

Stored size: 370 Bytes

Contents

require 'tempfile'

class File
  def self.copylines(src, dst)
    tempfile = Tempfile.new(dst)

    begin
      readlines(src).each do |line|
        line = yield(line) if block_given?

        tempfile.write line
      end

      FileUtils.chmod(stat(src).mode, tempfile.path)
      FileUtils.move(tempfile.path, dst)
    ensure
      tempfile.close!
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
subshift-0.0.1.pre lib/patches/file.rb