Skip to content

Instantly share code, notes, and snippets.

@yagihiro
Created March 1, 2011 05:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yagihiro/848679 to your computer and use it in GitHub Desktop.
Save yagihiro/848679 to your computer and use it in GitHub Desktop.
簡易インデントツール (space 4つを tab 1つへ)
#!/usr/bin/ruby
#
# indent.rb PATH
# -> PATH.new というインデント済みのファイルが生成されます。
#
require "stringio"
out = StringIO.new
File.foreach(ARGV[0]) do |line|
out << line.gsub(" ", "\t")
end
out.rewind
names = File.split ARGV[0]
names[1] += ".new"
File.open("#{names.join('/')}", "w") do |f|
f.write out.read
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment