Class: DeleteDerivedData::Search
- Inherits:
-
Object
- Object
- DeleteDerivedData::Search
- Defined in:
- lib/delete_derived_data/search.rb
Instance Attribute Summary collapse
-
#root_dir ⇒ Object
Returns the value of attribute root_dir.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Instance Method Summary collapse
- #getArchives ⇒ Object
- #getDerivedDatas ⇒ Object
-
#initialize(options = {}) ⇒ Search
constructor
A new instance of Search.
- #to_s ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Search
Returns a new instance of Search.
8 9 10 11 |
# File 'lib/delete_derived_data/search.rb', line 8 def initialize( = {}) @verbose = [:verbose] @root_dir = [:root_dir] || ENV["HOME"] end |
Instance Attribute Details
#root_dir ⇒ Object
Returns the value of attribute root_dir.
6 7 8 |
# File 'lib/delete_derived_data/search.rb', line 6 def root_dir @root_dir end |
#verbose ⇒ Object
Returns the value of attribute verbose.
6 7 8 |
# File 'lib/delete_derived_data/search.rb', line 6 def verbose @verbose end |
Instance Method Details
#getArchives ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/delete_derived_data/search.rb', line 60 def getArchives spinner = TTY::Spinner.new("[:spinner] Search Xcode Archives ...", format: :dots_2) spinner.auto_spin xcode_archives = [] data = [] xcode_archives_size = 0 data << :separator Dir["#{ENV["HOME"]}/Library/Developer/Xcode/Archives/**"].select { |d| size = Filesize.dirSize(d) xcode_archives_size = xcode_archives_size + size data << [d, Filesize.size(size)] if verbose xcode_archives << d } data << :separator data << ["Xcode Archives total size", Filesize.size(xcode_archives_size)] spinner.stop table = TTY::Table.new(["Xcode Archives", "Size"], data) puts table.render(:ascii, alignments: [:left, :right], padding: [0,1,0,1]) xcode_archives end |
#getDerivedDatas ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/delete_derived_data/search.rb', line 17 def getDerivedDatas directory_paths = get_directory_paths(root_dir) derived_paths = [] threads = [] table = TTY::Table.new(["Directory paths to be search"], directory_paths.map { |f| [f] }) puts table.render(:ascii) directory_paths.each do |folder| threads << Thread.new { begin Find.find(folder, ignore_error: true) {|path| derived_paths << path if path =~ /.*\DerivedData$/} rescue Exception => e puts e. end } end spinner = TTY::Spinner.new("[:spinner] Search Derived Data ...", format: :dots_2) spinner.auto_spin threads.each {|t| t.join} derived_size = 0 data = [:separator] derived_paths.each { |d| size = Filesize.dirSize(d) derived_size = derived_size + size data << [d, Filesize.size(size)] if verbose } data << :separator data << ["Derived Data total size", Filesize.size(derived_size)] spinner.stop table = TTY::Table.new(["DerivedData", "Size"], data) puts table.render(:ascii, alignments: [:left, :right], padding: [0,1,0,1]) derived_paths end |
#to_s ⇒ Object
13 14 15 |
# File 'lib/delete_derived_data/search.rb', line 13 def to_s "#{verbose} #{root_dir}" end |