Created
October 13, 2011 00:40
-
-
Save ysawa/1283048 to your computer and use it in GitHub Desktop.
insert magic comment to **/*.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# -*- coding: utf-8 -*- | |
Dir['**/*.rb'].each do |f| | |
File.open(f, 'r+') do |io| | |
buf = io.readlines | |
unless /coding:/ =~ buf[0] | |
io.rewind | |
buf.unshift "# -*- coding: utf-8 -*-\n\n" | |
io.write buf.join | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment