Skip to content

Instantly share code, notes, and snippets.

@ericsaboia
Created May 4, 2011 19:41
Show Gist options
  • Save ericsaboia/955866 to your computer and use it in GitHub Desktop.
Save ericsaboia/955866 to your computer and use it in GitHub Desktop.
Puts "utf8 encoding" in all rb files of specified path
if (ARGV.size != 1)
raise ArgumentError, "you must inform a param with path of ruby files"
end
files_path = Dir["#{ARGV[0]}**/**{.rb}"]
files_path.each do |file_path|
data = File.new(file_path).read
utf8 = "# encoding: utf-8"
File.open(file_path, 'w') { |f| f.write(utf8 + "\n\n" + data) } unless data.include? utf8
end
puts "Ruby files inside #{ARGV[0]} suscefull converted to UTF8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment