Created
May 23, 2012 07:29
-
-
Save vrinek/2773707 to your computer and use it in GitHub Desktop.
Add encoding line to all spec files
This file contains hidden or 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
| enc = '# -*- encoding : utf-8 -*-' | |
| `git ls-files -- spec | xargs head -1 | grep -v encoding`. | |
| split("\n\n"). | |
| reject{|l| l !~ /\n/}. | |
| map{|l| l.split("\n").first}. | |
| map{|f| f[/^==> (.*) <==$/, 1]}. | |
| each{|f| | |
| system "echo '#{enc}' > tempfile && cat #{f} >> tempfile && mv tempfile #{f}" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@vrinek I mean use it in the last each block.