Module: XcodeTrashRemover::Core

Extended by:
Core
Included in:
Core
Defined in:
lib/xcode_trash_remover/core.rb

Instance Method Summary collapse

Instance Method Details

#check_volumesObject



8
9
10
11
12
13
14
15
16
# File 'lib/xcode_trash_remover/core.rb', line 8

def check_volumes
  puts 'Dir             bytes'
  puts
  puts "DerivedData     #{derived_data_size}"
  puts "Archives        #{archives_size}"
  puts "XCPGDevices     #{playground_devices_size}"
  puts "CoreSimulator   #{core_simulator_size}"
  puts
end

#remove_trashObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/xcode_trash_remover/core.rb', line 18

def remove_trash
  total = total_size
  puts "Total           #{total}"
  puts '-'
  if total.zero?
    puts 'The directories are empty. No trash files.'
    exit(0)
  end

  dirs = [
    Dir.glob("#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData/*"),
    Dir.glob("#{File.expand_path('~')}/Library/Developer/Xcode/Archives/*"),
    Dir.glob("#{File.expand_path('~')}/Library/Developer/XCPGDevices/*"),
    Dir.glob("#{File.expand_path('~')}/Library/Developer/CoreSimulator/Devices/*")
  ]

  dirs.each do |dir|
    dir.each do |subdir|
      remove_dir(subdir)
    end
  end
  puts "#{total} bytes removed!"
end