Skip to content

Instantly share code, notes, and snippets.

@ysawa
Created October 13, 2011 00:40
Show Gist options
  • Save ysawa/1283048 to your computer and use it in GitHub Desktop.
Save ysawa/1283048 to your computer and use it in GitHub Desktop.
insert magic comment to **/*.rb
#!/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