Skip to content

Instantly share code, notes, and snippets.

@outoftime
Created July 17, 2009 21:12
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 outoftime/149278 to your computer and use it in GitHub Desktop.
Save outoftime/149278 to your computer and use it in GitHub Desktop.
Count lines of Ruby code agnostic to the newline style
#!/usr/bin/env ruby
require 'rubygems'
require 'parse_tree'
require 'ruby2ruby'
count = 0
for file in ARGV
file_count = Ruby2Ruby.translate(IO.read(file), nil).count("\n")
count += file_count
puts sprintf("%5d %s", file_count, file)
end
puts sprintf("%5d Total", count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment