Created
December 10, 2015 18:11
-
-
Save 007lva/8d0c74be9ea3f0c349c2 to your computer and use it in GitHub Desktop.
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
class String | |
def starts_with?(prefix) | |
prefix.respond_to?(:to_str) && self[0, prefix.length] == prefix | |
end | |
end | |
def delete_lines_from_file(filename) | |
line_arr = File.readlines(filename) | |
line_arr.delete_at(0) | |
line_arr.delete_at(0) if line_arr.first == "\n" | |
File.open(filename, "w") do |f| | |
line_arr.each{|line| f.puts(line)} | |
end | |
end | |
def remove_encoding_head(filename) | |
if File.new(filename).gets.strip == '# coding: UTF-8' | |
delete_lines_from_file(filename) | |
end | |
end | |
ruby_files = Dir.glob('/home/lvargas/projects/emergia/**/*.rb').select{ |e| File.file?(e) } | |
ruby_files.each do |filename| | |
remove_encoding_head(filename) | |
end | |
p 'Remove enconding head has finished' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment