Sha256: a23cfe527c60b5c2665028518a2f3a9fbda979792d8753df08952b3294b6819b
Contents?: true
Size: 320 Bytes
Versions: 4
Compression:
Stored size: 320 Bytes
Contents
module Incr module Service class FileHelper def self.replace_once(filename, old_text, new_text) old_content = File.read(filename) new_content = old_content.sub(/#{Regexp.escape(old_text)}/, new_text) File.open(filename, 'w') { |file| file << new_content } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
incr-0.6.0 | lib/incr/service/file_helper.rb |
incr-0.5.0 | lib/incr/service/file_helper.rb |
incr-0.4.0 | lib/incr/service/file_helper.rb |
incr-0.3.0 | lib/incr/service/file_helper.rb |