Class: XcodeInstall::Command::Uninstall

Inherits:
XcodeInstall::Command show all
Defined in:
lib/xcode/install/uninstall.rb

Instance Method Summary collapse

Methods inherited from XcodeInstall::Command

#install, #list

Constructor Details

#initialize(argv) ⇒ Uninstall

Returns a new instance of Uninstall.



11
12
13
14
15
# File 'lib/xcode/install/uninstall.rb', line 11

def initialize(argv)
  @installer = Installer.new
  @version = argv.shift_argument
  super
end

Instance Method Details

#runObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/xcode/install/uninstall.rb', line 24

def run
  installed_path = @installer.installed_versions.find { |x| x.version == @version }
  return if installed_path.nil? || installed_path.path.nil?

  `sudo rm -rf #{installed_path.path}`

  return unless @installer.symlinks_to == installed_path.path
  newest_version = @installer.installed_versions.last
  @installer.symlink(newest_version)
end

#validate!Object



17
18
19
20
21
22
# File 'lib/xcode/install/uninstall.rb', line 17

def validate!
  super
  help! 'A VERSION argument is required.' unless @version

  fail Informative, "Version #{@version} is not installed." unless @installer.installed?(@version)
end