Skip to content

Instantly share code, notes, and snippets.

@alup
Forked from vrinek/gist:2773707
Created May 23, 2012 08:13
Show Gist options
  • Select an option

  • Save alup/2773820 to your computer and use it in GitHub Desktop.

Select an option

Save alup/2773820 to your computer and use it in GitHub Desktop.
Add encoding line to all spec files
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