xcode_trash_remover 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3c72775a83912269e2693ae6e92bdc9f3348b25
4
- data.tar.gz: 45f7699e65f58b13ae9c5b707a503144b519de50
3
+ metadata.gz: 43d44a018d892666abf6d4f94e8c211377157960
4
+ data.tar.gz: d9aefd7b01fb1c8b4a7b8878383721510860212e
5
5
  SHA512:
6
- metadata.gz: af045fa7f8fd3c588093194512ff2a7c8be199b347987a9b2828830a3c2f69b667103a8af8a76914cabda9822489ae7d5dbd7f4fa088dc68d1f35578c2c100ef
7
- data.tar.gz: b8870396bbebe5e4e28b79d79ad07685d18c37b8d189f23647285fc353cf433c2d4ec62bcc86af846c28ca9aae5fd41e35ee23a692662d95fbb657b9cb7c2851
6
+ metadata.gz: f19d75a95f3a2ccacc04cefaa004cc7af5647211ec4d7bbbbc21a837e686b3ecce78848f7253d9591d0b87be0bcc4e422352dc80d26d76292bc3fc825b4649d7
7
+ data.tar.gz: f2e4f1d1658cf5058bdfc7b237dfa0bfd90addf5cc3d502911f521bb883531b3851c3014b31e6bcec94cd0399cf1bb93d5020d9a80c1e559e1375aeb16628dc8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- xcode_trash_remover (2.0.0)
4
+ xcode_trash_remover (2.0.1)
5
5
  filesize (~> 0.1.1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -8,10 +8,23 @@ This is a simple script to remove Xcode's trash files that are generated under d
8
8
 
9
9
  ## Usage
10
10
 
11
- Simply run `$ xcclean` to check your directories. And run:
11
+ `$ xcclean` to check your directories.
12
12
 
13
- $ xcclean -rm
13
+ `$ xcclean -rm` to **remove** the files.
14
14
 
15
- To remove the files. You'll see something like the following:
15
+ <img src = https://raw.githubusercontent.com/FrankKair/xcode-trash-remover/master/assets/output2.png width="45%" height="45%"/>
16
+
17
+ ## Directories
18
+
19
+ - `Derived Data`: Intermediate build information.
20
+
21
+ - `Archives`: Info about the target. Used for debbuging deployd applications.
22
+
23
+ - `XCPGDevices`: Xcode Playground files.
24
+
25
+ - `CoreSimulator/Devices`: Simulators and devices. That's where Xcode stores the apps' data.
26
+
27
+ ## Warning
28
+
29
+ You should only use this program if you're sure you're not going to use the information contained in these folders.
16
30
 
17
- <img src = https://raw.githubusercontent.com/FrankKair/xcode-trash-remover/master/assets/output.png width="30%" height="30%"/>
data/assets/.DS_Store ADDED
Binary file
Binary file
data/bin/xcclean CHANGED
@@ -1,13 +1,34 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'optparse'
2
3
  require 'xcode_trash_remover'
3
4
 
4
- puts '== Xcode Trash Remover =='
5
- XcodeTrashRemover::Core.check_volumes
6
5
 
7
- input = ARGV[0]
8
- case input
9
- when '-rm'
10
- XcodeTrashRemover::Core.remove_trash
11
- else
12
- XcodeTrashRemover::Core.show_options
6
+ ARGV[0] = '--help' if ARGV.empty?
7
+ unless ARGV[0].include?('--') || ARGV[0].include?('-')
8
+ puts "invalid option: #{ARGV[0]}"
9
+ end
10
+
11
+ options = {}
12
+ opt_parser = OptionParser.new do |opt|
13
+ opt.on('--check', 'Checks the volumes') do |o|
14
+ options[:check] = o
15
+ end
16
+ opt.on('--remove', 'Removes the files from your system') do |o|
17
+ options[:remove] = o
18
+ end
19
+ end
20
+
21
+ begin
22
+ opt_parser.parse!
23
+ options.keys.each do |k|
24
+ case k
25
+ when :check
26
+ XcodeTrashRemover::Core.check_volumes
27
+ when :remove
28
+ XcodeTrashRemover::Core.check_volumes
29
+ XcodeTrashRemover::Core.remove_trash
30
+ end
31
+ end
32
+ rescue StandardError => e
33
+ puts e.to_s unless e.message == 'exit'
13
34
  end
@@ -7,41 +7,29 @@ module XcodeTrashRemover
7
7
  def check_volumes
8
8
  puts 'Dir size'
9
9
  puts
10
- puts "DerivedData #{derived_data_size.pretty}"
10
+ puts "DerivedData #{deriveddata_size.pretty}"
11
11
  puts "Archives #{archives_size.pretty}"
12
- puts "XCPGDevices #{playground_devices_size.pretty}"
13
- puts "CoreSimulator #{core_simulator_size.pretty}"
12
+ puts "XCPGDevices #{xcpgdevices_size.pretty}"
13
+ puts "CoreSimulator #{coresimulator_devices_size.pretty}"
14
14
  puts
15
15
  end
16
16
 
17
17
  def remove_trash
18
18
  total = total_size
19
- print_total_size(total)
20
19
  remove_dirs
21
- puts "#{total.pretty} removed!"
22
- end
23
20
 
24
- def show_options
25
- puts 'Run:'
26
- puts '$ xcclean -rm'
27
- puts 'To remove the files from your system.'
21
+ puts "Total #{total.pretty}"
22
+ puts '-'
23
+ puts 'The directories are empty. No trash files.' if total.zero?
24
+ puts "#{total.pretty} removed!" unless total.zero?
28
25
  end
29
26
 
30
27
  private
31
28
 
32
- def print_total_size(size)
33
- puts "Total #{size.pretty}"
34
- puts '-'
35
- if size.zero?
36
- puts 'The directories are empty. No trash files.'
37
- exit(0)
38
- end
39
- end
40
-
41
29
  def remove_dirs
42
30
  dirs = [
43
- XcodeDir.derived_data, XcodeDir.archives,
44
- XcodeDir.playground_devices, XcodeDir.core_simulator
31
+ XcodeDir.deriveddata, XcodeDir.archives,
32
+ XcodeDir.xcpgdevices, XcodeDir.coresimulator_devices
45
33
  ]
46
34
 
47
35
  dirs.each do |dir|
@@ -51,38 +39,38 @@ module XcodeTrashRemover
51
39
  end
52
40
  end
53
41
 
54
- def derived_data_size
55
- trash_size(XcodeDir.derived_data)
56
- end
57
-
58
- def archives_size
59
- trash_size(XcodeDir.archives)
60
- end
61
-
62
- def playground_devices_size
63
- trash_size(XcodeDir.playground_devices)
64
- end
42
+ dirs = %w[
43
+ deriveddata
44
+ archives
45
+ xcpgdevices
46
+ coresimulator_devices
47
+ ]
65
48
 
66
- def core_simulator_size
67
- trash_size(XcodeDir.core_simulator)
49
+ dirs.each do |dir|
50
+ define_method("#{dir}_size") do
51
+ case dir
52
+ when 'deriveddata'
53
+ trash_size(XcodeDir.deriveddata)
54
+ when 'archives'
55
+ trash_size(XcodeDir.archives)
56
+ when 'xcpgdevices'
57
+ trash_size(XcodeDir.xcpgdevices)
58
+ when 'coresimulator_devices'
59
+ trash_size(XcodeDir.coresimulator_devices)
60
+ end
61
+ end
68
62
  end
69
63
 
70
64
  def total_size
71
- total = 0
72
- total += derived_data_size
73
- total += archives_size
74
- total += playground_devices_size
75
- total += core_simulator_size
76
- total
65
+ [deriveddata_size,
66
+ archives_size,
67
+ xcpgdevices_size,
68
+ coresimulator_devices_size].reduce(:+)
77
69
  end
78
70
 
79
71
  def trash_size(dir)
80
72
  return 0 if dir.empty?
81
- size = 0
82
- dir.each do |subdir|
83
- size += SizeHelper.dir_size(subdir)
84
- end
85
- size
73
+ dir.reduce(0) { |size, subdir| size += SizeHelper.dir_size(subdir) }
86
74
  end
87
75
 
88
76
  def remove_dir(dir)
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
 
3
3
  module XcodeTrashRemover
4
4
  module SizeHelper
5
- extend self
5
+ module_function
6
6
 
7
7
  def dir_size(dir_path)
8
8
  dir_path << '/' unless dir_path.end_with?('/')
@@ -1,3 +1,3 @@
1
1
  module XcodeTrashRemover
2
- VERSION = '2.0.1'.freeze
2
+ VERSION = '2.0.2'.freeze
3
3
  end
@@ -2,20 +2,24 @@ module XcodeTrashRemover
2
2
  module XcodeDir
3
3
  extend self
4
4
 
5
- def derived_data
6
- root('Xcode/DerivedData')
7
- end
5
+ # Creates:
6
+ # deriveddata, archives
7
+ # xcpgdevices and coresimulator_devices
8
+ # methods.
8
9
 
9
- def archives
10
- root('Xcode/Archives')
11
- end
10
+ dir_names = %w[
11
+ Xcode/DerivedData
12
+ Xcode/Archives
13
+ XCPGDevices
14
+ CoreSimulator/Devices
15
+ ]
12
16
 
13
- def playground_devices
14
- root('XCPGDevices')
15
- end
17
+ dir_names.each do |dir|
18
+ trimmed_dir_name = dir.downcase.tr('/', '_').to_s.gsub('xcode_', '')
16
19
 
17
- def core_simulator
18
- root('CoreSimulator/Devices')
20
+ define_method(trimmed_dir_name) do
21
+ root(dir)
22
+ end
19
23
  end
20
24
 
21
25
  private
@@ -1,5 +1,5 @@
1
1
 
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path('lib', __dir__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'xcode_trash_remover/version'
5
5
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcode_trash_remover
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Kair
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-04 00:00:00.000000000 Z
11
+ date: 2018-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,8 @@ files:
66
66
  - LICENSE.txt
67
67
  - README.md
68
68
  - Rakefile
69
- - assets/output.png
69
+ - assets/.DS_Store
70
+ - assets/output2.png
70
71
  - bin/xcclean
71
72
  - lib/xcode_trash_remover.rb
72
73
  - lib/xcode_trash_remover/core.rb
data/assets/output.png DELETED
Binary file