Class: XcodeInstall::InstalledXcode
- Inherits:
-
Object
- Object
- XcodeInstall::InstalledXcode
- Defined in:
- lib/xcode/install.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #approve_license ⇒ Object
- #get_version(xcode_path) ⇒ Object
-
#initialize(path) ⇒ InstalledXcode
constructor
A new instance of InstalledXcode.
Constructor Details
#initialize(path) ⇒ InstalledXcode
Returns a new instance of InstalledXcode.
272 273 274 275 |
# File 'lib/xcode/install.rb', line 272 def initialize(path) @path = Pathname.new(path) @version = get_version(path) end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
269 270 271 |
# File 'lib/xcode/install.rb', line 269 def path @path end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
270 271 272 |
# File 'lib/xcode/install.rb', line 270 def version @version end |
Instance Method Details
#approve_license ⇒ Object
277 278 279 280 281 282 283 284 |
# File 'lib/xcode/install.rb', line 277 def approve_license license_path = "#{@path}/Contents/Resources/English.lproj/License.rtf" license_id = IO.read(license_path).match(/^EA\d{4}/) license_plist_path = '/Library/Preferences/com.apple.dt.Xcode.plist' `sudo rm -rf #{license_plist_path}` `sudo /usr/libexec/PlistBuddy -c "add :IDELastGMLicenseAgreedTo string #{license_id}" #{license_plist_path}` `sudo /usr/libexec/PlistBuddy -c "add :IDEXcodeVersionForAgreedToGMLicense string #{@version}" #{license_plist_path}` end |
#get_version(xcode_path) ⇒ Object
288 289 290 291 292 |
# File 'lib/xcode/install.rb', line 288 def get_version(xcode_path) output = `DEVELOPER_DIR='' "#{xcode_path}/Contents/Developer/usr/bin/xcodebuild" -version` return '0.0' if output.nil? # ¯\_(ツ)_/¯ output.split("\n").first.split(' ')[1] end |