class Grenouille::Xcode

Public Class Methods

new(developer_dir = `xcode-select -p`.chomp) click to toggle source
# File lib/grenouille/xcode.rb, line 5
def initialize(developer_dir = `xcode-select -p`.chomp)
  @developer_dir = developer_dir
end

Public Instance Methods

current_swift_version() click to toggle source
# File lib/grenouille/xcode.rb, line 13
def current_swift_version
  get_version('swift -version', 3) || get_version('swift -version', 2)
end
current_version() click to toggle source
# File lib/grenouille/xcode.rb, line 9
def current_version
  get_version('xcodebuild -version')
end
xcrun(command) click to toggle source
# File lib/grenouille/xcode.rb, line 17
def xcrun(command)
  `DEVELOPER_DIR=#{@developer_dir} xcrun #{command}`
end

Private Instance Methods

get_version(command, index = 1) click to toggle source
# File lib/grenouille/xcode.rb, line 23
def get_version(command, index = 1)
  version_string = xcrun(command).split(' ')

  if version_string.count >= index + 1 && Gem::Version.correct?(version_string[index])
    return Gem::Version.new(version_string[index])
  end

  nil
end