Sha256: 669b5ddba145d6bcac018ad22750058609305d70adf05b4d71c2c59157e3cbd6
Contents?: true
Size: 1000 Bytes
Versions: 51
Compression:
Stored size: 1000 Bytes
Contents
module Sed def self.copy(source, target, pattern, replacement) if not File.file? source $log.writer.error "File #{source} does not exists" exit 1 end File.open(source, "r:UTF-8") do |source_file| content = source_file.read content.gsub!(pattern, replacement) File.open(target, "w:UTF-8") do |target_file| target_file.write(content) target_file.close end source_file.close end end def self.patch(filename, pattern, replacement) if not File.file? filename $log.writer.error "File #{filename} does not exists" exit 1 end content = "" File.open(filename, "r:UTF-8") do |source_file| content = source_file.read content.gsub!(pattern, replacement) source_file.close end File.open(filename, "w:UTF-8") do |target_file| target_file.write(content) target_file.close end end end
Version data entries
51 entries across 51 versions & 1 rubygems