Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created March 28, 2013 14:18
Show Gist options
  • Save jimweirich/5263458 to your computer and use it in GitHub Desktop.
Save jimweirich/5263458 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# -*- ruby -*-
begin
require 'rubygems'
rescue LoadError
end
exts = ['.rb', '.rhtml', '.erb', '.builder', '.haml', '.css', '.js', '.coffee', '.yml', '.yaml' ]
if ARGV[0] =~ /^(\+|\.[a-zA-Z0-9]+)$/
if ARGV[0] == '+'
ARGV.shift
else
exts = []
end
while ARGV[0] =~ /^\.[a-zA-Z0-9]+$/
exts << ARGV.shift
end
end
ext = "{" + exts.join(',') + "}"
if ARGV.size < 1
puts "Usage: #{File.basename($0)} [.ext ...] pattern ..."
puts "(searching #{ext} files)"
exit 1
end
require 'rake'
status = 1
FileList["**/*#{ext}"].egrep(Regexp.new(ARGV.join('.*'), Regexp::IGNORECASE)) do |fn, count, line|
puts "#{fn}:#{count}:#{line}" unless line.size > 300
status = 0
end
exit(status)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment