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 installed xcode objects.
- .find_new_xcodes ⇒ Object
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
44 45 46 |
# File 'lib/xcselect/xcode.rb', line 44 def self.current_xcode `xcode-select -print-path`.chomp end |
.current_xcode_path ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/xcselect/xcode.rb', line 48 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 installed xcode objects
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/xcselect/xcode.rb', line 24 def self.find_all xcode_builds = `mdfind -name xcodebuild`.chomp.split #TODO: move this checking to init method xcode_builds = xcode_builds.select {|x| x =~ /\/xcodebuild$/ && !(x =~ /^\/(Volumes|usr\/bin\/)/) && File.exists?(x) } xcode_objs = xcode_builds.map {|p| Xcode.new p.sub( /\/usr\/bin.*/, '').chomp.strip } # Xcode in now in a single application, look for that and use that as a candidate xcode_objs += self.find_new_xcodes xcode_objs.sort end |
.find_new_xcodes ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/xcselect/xcode.rb', line 35 def self.find_new_xcodes # 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") } end |
Instance Method Details
#<=>(o) ⇒ Object
sort by version number and fallback to build number after
68 69 70 71 |
# File 'lib/xcselect/xcode.rb', line 68 def <=>(o) res = version.to_f <=> o.version.to_f return res == 0 ? o.build <=> build : res; end |
#eql?(o) ⇒ Boolean
58 59 60 61 |
# File 'lib/xcselect/xcode.rb', line 58 def eql?(o) return false if o.nil? return (o.folder == folder && o.version == version && o.build == build) end |
#sdks ⇒ Object
63 64 65 |
# File 'lib/xcselect/xcode.rb', line 63 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 |