Class: Xcode

Inherits:
Bundle show all
Defined in:
lib/xcode.rb

Instance Attribute Summary

Attributes inherited from Bundle

#path

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Bundle

#defaults_read, #defaults_write, #info_path, #initialize, #version

Constructor Details

This class inherits a constructor from Bundle

Class Method Details

.find_xcodesObject



4
5
6
7
8
9
# File 'lib/xcode.rb', line 4

def self.find_xcodes
  output = `mdfind kMDItemCFBundleIdentifier = "com.apple.dt.Xcode"`
  output.lines.collect do |xcode_path|
    Xcode.from_bundle(xcode_path)
  end.compact.keep_if(&:valid?)
end

.from_bundle(path) ⇒ Object



11
12
13
14
# File 'lib/xcode.rb', line 11

def self.from_bundle(path)
  xcode = new(path)
  xcode.valid? ? xcode : nil
end

Instance Method Details

#to_sObject



27
28
29
# File 'lib/xcode.rb', line 27

def to_s
  "Xcode (#{version}) [#{uuid}]: #{path}"
end

#uuidObject



23
24
25
# File 'lib/xcode.rb', line 23

def uuid
  defaults_read('DVTPlugInCompatibilityUUID')
end

#valid?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
# File 'lib/xcode.rb', line 16

def valid?
  is_app = path.end_with?('.app')
  has_info = File.exist?(info_path)

  is_app && has_info
end