All pastes #746190 Raw Edit

Something

public ruby v1 · immutable
·published 2007-10-23 00:57 UTC
rendered paste body
# lets you edit file contents and save to other file# usage:# # edit_file_contents 'file.template', 'file' do |contents|#   contents.gsub!(/alpha(.)*/, 'beta')# end# # and the modified contents will be saved in 'dst' filedef edit_file_contents src, dst  raise "No block given" if ! block_given?    contents = ""  File.open( src, 'r' ) do |file|    contents = file.read  end  yield contents    File.open( dst, 'w' ) do |file|    file.write contents  endend