Skip to content

Instantly share code, notes, and snippets.

@fellix
Created August 26, 2013 14:23
Show Gist options
  • Save fellix/6341943 to your computer and use it in GitHub Desktop.
Save fellix/6341943 to your computer and use it in GitHub Desktop.
files = Dir.glob("app/**/*.rb")
files.concat Dir.glob("lib/**/*.rb")
files.each do |file_name|
lines = File.readlines(file_name)
if !["#encoding: utf-8\n", "# encoding: utf-8\n"].include?(lines.first)
puts "Rewriting #{file_name}"
lines = ["#encoding: utf-8\n"].concat lines
new_file = File.new(file_name, "w")
lines.each { |line| new_file.write line }
new_file.close
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment