Class: Xcselect::Xcode
- Inherits:
-
Object
- Object
- Xcselect::Xcode
- Includes:
- Comparable
- Defined in:
- lib/xcselect/xcode.rb
Instance Attribute Summary collapse
-
#build ⇒ Object
Returns the value of attribute build.
-
#folder ⇒ Object
Returns the value of attribute folder.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .current_xcode ⇒ Object
- .current_xcode_path ⇒ Object
-
.find_all ⇒ Object
Get an array of all self contained .app style xcode objects.
Instance Method Summary collapse
-
#<=>(o) ⇒ Object
sort by version number and fallback to build number after.
- #eql?(o) ⇒ Boolean
-
#initialize(fld) ⇒ Xcode
constructor
A new instance of Xcode.
- #sdks ⇒ Object
- #to_s ⇒ Object
- #xcodebuild_path ⇒ Object
Constructor Details
#initialize(fld) ⇒ Xcode
Returns a new instance of Xcode.
8 9 10 11 12 13 |
# File 'lib/xcselect/xcode.rb', line 8 def initialize(fld) @folder = fld ver_output = `#{xcodebuild_path} -version` @version = ver_output.match(/Xcode (.*)$/)[1] @build = ver_output.match(/Build version (.*)$/)[1] end |
Instance Attribute Details
#build ⇒ Object
Returns the value of attribute build.
7 8 9 |
# File 'lib/xcselect/xcode.rb', line 7 def build @build end |
#folder ⇒ Object
Returns the value of attribute folder.
7 8 9 |
# File 'lib/xcselect/xcode.rb', line 7 def folder @folder end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/xcselect/xcode.rb', line 7 def version @version end |
Class Method Details
.current_xcode ⇒ Object
33 34 35 |
# File 'lib/xcselect/xcode.rb', line 33 def self.current_xcode `xcode-select -print-path`.chomp end |
.current_xcode_path ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/xcselect/xcode.rb', line 37 def self.current_xcode_path path = self.current_xcode if path =~ /(.*Xcode(.*DP.*)?.app)/ path = $1 else path += "/Applications/Xcode.app" end return path end |
.find_all ⇒ Object
Get an array of all self contained .app style xcode objects
24 25 26 27 28 29 30 31 |
# File 'lib/xcselect/xcode.rb', line 24 def self.find_all # Xcode is now in a single application, look for that and use that as a candidate newXcodes = `mdfind 'kMDItemCFBundleIdentifier = com.apple.dt.Xcode'`.chomp.split newXcodes = newXcodes.select do |x| File.exists? x + "/Contents/Developer/usr/bin/xcodebuild" end newXcodes.map {|x| Xcode.new(x + "/Contents/Developer") }.sort end |
Instance Method Details
#<=>(o) ⇒ Object
sort by version number and fallback to build number after
57 58 59 60 |
# File 'lib/xcselect/xcode.rb', line 57 def <=>(o) res = version.to_f <=> o.version.to_f return res == 0 ? o.build <=> build : res; end |
#eql?(o) ⇒ Boolean
47 48 49 50 |
# File 'lib/xcselect/xcode.rb', line 47 def eql?(o) return false if o.nil? return (o.folder == folder && o.version == version && o.build == build) end |
#sdks ⇒ Object
52 53 54 |
# File 'lib/xcselect/xcode.rb', line 52 def sdks `#{xcodebuild_path} -showsdks` end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/xcselect/xcode.rb', line 19 def to_s "Xcode: #{folder} - #{version} (#{build})" end |
#xcodebuild_path ⇒ Object
15 16 17 |
# File 'lib/xcselect/xcode.rb', line 15 def xcodebuild_path "#{folder}/usr/bin/xcodebuild" end |