Skip to content

Instantly share code, notes, and snippets.

@idesaku
Created July 15, 2009 04:01
Show Gist options
  • Save idesaku/147437 to your computer and use it in GitHub Desktop.
Save idesaku/147437 to your computer and use it in GitHub Desktop.
grepモドキ
# rake grep[key,pattern]
target = FileList.new { |f|
f.exclude "**/*.swp"
}
desc "fake grep"
task :grep, [:key, :pattern] do |t,args|
args.with_defaults :pattern => "**/*"
if args[:key].nil?
raise "no keyword."
end
puts "Context --> %s" % args
target.include args.pattern
target.egrep(Regexp.new(args.key))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment