Skip to content

Instantly share code, notes, and snippets.

@thiagofm
Created March 23, 2015 15:50
Show Gist options
  • Save thiagofm/2a44e92342abfe389d90 to your computer and use it in GitHub Desktop.
Save thiagofm/2a44e92342abfe389d90 to your computer and use it in GitHub Desktop.
enc.rb
#!/usr/bin/env ruby
Dir['**/*.rb'].each do |path|
lines = File.readlines(path)
new_lines = lines.dup
lines.each do |line|
if line =~ /^# encoding: utf-8/i || line !~ /\S/
new_lines.delete_at(new_lines.index(line))
else
break
end
end
print '.'
File.open(path, 'w') do |file|
file.write(new_lines.join)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment