Skip to content

Instantly share code, notes, and snippets.

@thisivan
Created December 11, 2009 03:45
Show Gist options
  • Save thisivan/253965 to your computer and use it in GitHub Desktop.
Save thisivan/253965 to your computer and use it in GitHub Desktop.

Append to Files using Gsub

def gsub_file(relative_destination, regexp, *args, &block)
  path = destination_path(relative_destination)
  content = File.read(path).gsub(regexp, *args, &block)
  File.open(path, 'wb') { |file| file.write(content) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment