Sha256: 3f54d1dc509f6bc6850042090f5a674df31a16d6ac79c15cf6ecfc93d768737b
Contents?: true
Size: 475 Bytes
Versions: 1
Compression:
Stored size: 475 Bytes
Contents
module Incr module Service class FileHelper def self.replace_string_once(filename, old_text, new_text) replace_regexp_once(filename, /#{Regexp.escape(old_text)}/, new_text) end def self.replace_regexp_once(filename, pattern, replacement_text) old_content = File.read(filename) new_content = old_content.sub(pattern, replacement_text) File.open(filename, 'w') { |file| file << new_content } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
incr-0.7.1 | lib/incr/service/file_helper.rb |