diff options
| author | Jack Nagel | 2014-04-01 20:47:26 -0500 |
|---|---|---|
| committer | Jack Nagel | 2014-04-01 20:47:26 -0500 |
| commit | 1fa5da56ac19fd0a58bb024d49443e114288c4b8 (patch) | |
| tree | 0b2a43ccf0113c734a7bb9403c2bbf0f6badf468 /Library/Homebrew/os | |
| parent | f517682409f8d0ab641971530dc8fb2e726e419b (diff) | |
| download | homebrew-1fa5da56ac19fd0a58bb024d49443e114288c4b8.tar.bz2 | |
Batch up mdfind calls when possible
Diffstat (limited to 'Library/Homebrew/os')
| -rw-r--r-- | Library/Homebrew/os/mac.rb | 16 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/xcode.rb | 2 | ||||
| -rw-r--r-- | Library/Homebrew/os/mac/xquartz.rb | 2 |
3 files changed, 12 insertions, 8 deletions
diff --git a/Library/Homebrew/os/mac.rb b/Library/Homebrew/os/mac.rb index dc6d7093e..7fa95cd56 100644 --- a/Library/Homebrew/os/mac.rb +++ b/Library/Homebrew/os/mac.rb @@ -269,22 +269,26 @@ module OS EOS end - def app_with_bundle_id id - path = mdfind(id).first + def app_with_bundle_id(*ids) + path = mdfind(*ids).first Pathname.new(path) unless path.nil? or path.empty? end - def mdfind id + def mdfind(*ids) return [] unless OS.mac? - (@mdfind ||= {}).fetch(id.to_s) do |key| - @mdfind[key] = `/usr/bin/mdfind "kMDItemCFBundleIdentifier == '#{key}'"`.split("\n") + (@mdfind ||= {}).fetch(ids) do + @mdfind[ids] = `/usr/bin/mdfind "#{mdfind_query(*ids)}"`.split("\n") end end - def pkgutil_info id + def pkgutil_info(id) (@pkginfo ||= {}).fetch(id.to_s) do |key| @pkginfo[key] = `/usr/sbin/pkgutil --pkg-info "#{key}" 2>/dev/null`.strip end end + + def mdfind_query(*ids) + ids.map! { |id| "kMDItemCFBundleIdentifier == #{id}" }.join(" || ") + end end end diff --git a/Library/Homebrew/os/mac/xcode.rb b/Library/Homebrew/os/mac/xcode.rb index b64fc6edb..d89aa8d26 100644 --- a/Library/Homebrew/os/mac/xcode.rb +++ b/Library/Homebrew/os/mac/xcode.rb @@ -70,7 +70,7 @@ module OS # helper tools and installed Xcode in a non-conventional place, this # is our only option. See: http://superuser.com/questions/390757 def bundle_path - MacOS.app_with_bundle_id(V4_BUNDLE_ID) || MacOS.app_with_bundle_id(V3_BUNDLE_ID) + MacOS.app_with_bundle_id(V4_BUNDLE_ID, V3_BUNDLE_ID) end def installed? diff --git a/Library/Homebrew/os/mac/xquartz.rb b/Library/Homebrew/os/mac/xquartz.rb index f864720f9..9a2266c39 100644 --- a/Library/Homebrew/os/mac/xquartz.rb +++ b/Library/Homebrew/os/mac/xquartz.rb @@ -52,7 +52,7 @@ module OS end def bundle_path - MacOS.app_with_bundle_id(FORGE_BUNDLE_ID) || MacOS.app_with_bundle_id(APPLE_BUNDLE_ID) + MacOS.app_with_bundle_id(FORGE_BUNDLE_ID, APPLE_BUNDLE_ID) end def version_from_mdls(path) |
