Sha256: 33f4f2d5af2673d2498937453db0bd424f156f4480fc990d2dfb3f5661c25b20
Contents?: true
Size: 843 Bytes
Versions: 3
Compression:
Stored size: 843 Bytes
Contents
require 'rubygems' require 'plist' module Spotlight class Query attr_reader :query_string attr_accessor :scopes def self.from_saved_search(filename) plist = Plist::parse_xml(filename) query = new(plist['RawQuery']) query.scopes = plist['SearchCriteria']['FXScopeArrayOfPaths'] query end def initialize(query_string) @query_string = query_string @scopes = [] end def execute md_query = MDQueryNative.new(query_string) md_query.set_search_scopes(scopes) md_query.execute end def to_saved_search(filename) obj = { 'RawQuery' => query_string, 'SearchCriteria' => { 'FXScopeArrayOfPaths' => scopes } } File.open(filename, 'w') do |file| file.write(obj.to_plist) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
spotlight-0.0.8 | lib/spotlight/query.rb |
spotlight-0.0.7 | lib/spotlight/query.rb |
spotlight-0.0.6 | lib/spotlight/query.rb |