Skip to content

Instantly share code, notes, and snippets.

View taylorfinnell's full-sized avatar

Taylor Finnell taylorfinnell

View GitHub Profile
@segphault
segphault / spottest.rb
Created February 4, 2012 23:50
Querying spotlight with MacRuby
def performSearch(pred, &cb)
search = NSMetadataQuery.alloc.init
search.predicate = pred
search.searchScopes = [File.expand_path("~")]
NSNotificationCenter.defaultCenter.addObserverForName(
"NSMetadataQueryDidFinishGatheringNotification", object:nil, queue:nil,
usingBlock: Proc.new {|n| n.object.results.each {|r| cb.call(r) } })
search.startQuery