Sha256: 7749a3886a0ed4f351563a18b50027091a1a44b36b92767b68d4704503ad9d2c

Contents?: true

Size: 398 Bytes

Versions: 3

Compression:

Stored size: 398 Bytes

Contents

module RevealCK
  module Changers
    #
    # Public: A StringReplacer knows how to replace one string in a file
    # with another.
    #
    class StringReplacer

      def self.replace!(file, args)
        old, new = args[:old], args[:new]
        lines = File.open(file).read
        lines = lines.sub old, new
        File.open(file, 'w') { |file| file << lines }
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
reveal-ck-0.2.0 lib/reveal-ck/changers/string_replacer.rb
reveal-ck-0.1.8 lib/reveal-ck/changers/string_replacer.rb
reveal-ck-0.1.7 lib/reveal-ck/changers/string_replacer.rb