Class: MacCleaner::Analyzer
- Inherits:
-
Object
- Object
- MacCleaner::Analyzer
- Defined in:
- lib/mac_cleaner/analyzer.rb
Constant Summary collapse
- MIN_LARGE_FILE_SIZE =
1GB
1_000_000_000- MIN_MEDIUM_FILE_SIZE =
100MB
100_000_000- CACHE_DIR =
File.("~/.cache/mac_cleaner")
Instance Method Summary collapse
- #analyze ⇒ Object
-
#initialize(path: "~") ⇒ Analyzer
constructor
A new instance of Analyzer.
Constructor Details
#initialize(path: "~") ⇒ Analyzer
11 12 13 14 15 16 17 18 19 |
# File 'lib/mac_cleaner/analyzer.rb', line 11 def initialize(path: "~") @path = File.(path) @path_hash = Digest::MD5.hexdigest(@path) @large_files = [] @medium_files = [] @directories = [] @aggregated_directories = [] FileUtils.mkdir_p(CACHE_DIR) end |
Instance Method Details
#analyze ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mac_cleaner/analyzer.rb', line 20 def analyze if cache_valid? puts "Loading from cache..." load_from_cache display_results return end puts "Analyzing #{@path}..." scan_large_files scan_medium_files scan_directories @aggregated_directories = aggregate_by_directory(@large_files + @medium_files) save_to_cache display_results end |