Class: Xcode
Instance Attribute Summary collapse
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
Instance Attribute Details
#signed ⇒ Object
Returns the value of attribute signed.
4
5
6
|
# File 'lib/xcode.rb', line 4
def signed
@signed
end
|
Class Method Details
.find_xcodes ⇒ Object
6
7
8
9
10
11
|
# File 'lib/xcode.rb', line 6
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
13
14
15
16
|
# File 'lib/xcode.rb', line 13
def self.from_bundle(path)
xcode = new(path)
xcode.valid? ? xcode : nil
end
|
Instance Method Details
#signed? ⇒ Boolean
25
26
27
28
29
30
31
32
|
# File 'lib/xcode.rb', line 25
def signed?
if signed.nil?
self.signed = `codesign -dv "#{path}" 2>/dev/null` &&
$CHILD_STATUS.exitstatus == 0
end
signed
end
|
#to_s ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/xcode.rb', line 45
def to_s
unless signed.nil?
codesign_status = signed ? '[Signed]' : '[Unsigned]'
end
"Xcode (#{version}) [#{uuid}]#{codesign_status}: #{path}"
end
|
#unsign! ⇒ Object
34
35
36
37
38
39
|
# File 'lib/xcode.rb', line 34
def unsign!
`#{unsign_path} "#{binary_path}"` &&
$CHILD_STATUS.exitstatus == 0 &&
File.exist?(unsigned_binary_path) &&
FileUtils.mv(unsigned_binary_path, binary_path)
end
|
#uuid ⇒ Object
41
42
43
|
# File 'lib/xcode.rb', line 41
def uuid
defaults_read('DVTPlugInCompatibilityUUID')
end
|
#valid? ⇒ Boolean
18
19
20
21
22
23
|
# File 'lib/xcode.rb', line 18
def valid?
is_app = path.end_with?('.app')
has_info = File.exist?(info_path)
is_app && has_info
end
|