4 # find . -type f | grep -v log/ | grep -v lib/ | xargs grep -in KEYWORD
7 SCRIPT_DIR
= File
.dirname(File
.expand_path(__FILE__
))
8 SCRIPT_NAME
= $0.split('/')[-1]
15 STDERR.puts
"SYNOPSIS:"
16 STDERR.puts
" #{SCRIPT_NAME} \e[4mKEYWORD\e[24m"
18 STDERR.puts
"DESCRIPTION:"
19 STDERR.puts
" Show occurrences of KEYWORD in relative files of the project."
25 `find -type f`.each
do |file_name
|
30 when /^\.\/doc\
//, /^\.\/vendor\
//
31 # Ignore the Vendors and Documentation files!
33 when /\.$/, /\.git/, /~$/
36 when /^\.\/lib\
/dict\/words
/, /^\
.\
/log\
//
42 next if `file -i -b #{file_name}` =~
/^image/
45 File
.open(file_name
).each_with_index
do |line_text
, line_number
|
46 if line_text
.downcase
=~
/#{ARGV[0].downcase}/
47 puts file_name
.rjust(75, '=') + '=' * 5 unless found
49 print
"#{line_number.to_s.rjust(5)}: "
50 if line_text
.size
< 72
53 puts line_text
[0..69] + '...'