Sha256: f2c40a6da4df77f7530c7bd3866163959b528d377dbdb150e9f1df88f8010361
Contents?: true
Size: 465 Bytes
Versions: 1
Compression:
Stored size: 465 Bytes
Contents
module Incr module Service class FileHelper def self.replace_string_once(filename, old_text, new_text) replace_regexp_once(/#{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.0 | lib/incr/service/file_helper.rb |