Skip to content

Instantly share code, notes, and snippets.

@jimweirich
Created December 10, 2008 01:48
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 jimweirich/34185 to your computer and use it in GitHub Desktop.
Save jimweirich/34185 to your computer and use it in GitHub Desktop.
Find In Code
#!/usr/bin/env ruby
# -*- ruby -*-
begin
require 'rubygems'
rescue LoadError
end
exts = ['.rb', '.rhtml', '.erb', '.builder']
if ARGV[0] =~ /^\.[a-zA-Z0-9]+$/
exts = []
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 ..."
exit 1
end
require 'rake'
FileList["**/*#{ext}"].egrep(Regexp.new(ARGV.join('.*'), Regexp::IGNORECASE))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment