Class: RBS::Collection::Cleaner
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/rbs/collection/cleaner.rb |
Class Method Summary
- .new(lockfile_path:) ⇒ Cleaner constructor
Instance Attribute Summary
- #lock readonly
Instance Method Summary
Constructor Details
.new(lockfile_path:) ⇒ Cleaner
Instance Attribute Details
#lock (readonly)
[ GitHub ]# File 'lib/rbs/collection/cleaner.rb', line 6
attr_reader :lock
Instance Method Details
#clean
[ GitHub ]# File 'lib/rbs/collection/cleaner.rb', line 12
def clean lock.repo_path.glob('*/*') do |dir| *_, gem_name, version = dir.to_s.split('/') gem_name or raise version or raise next if needed? gem_name, version case when dir.symlink? dir.unlink when dir.directory? FileUtils.remove_entry_secure(dir.to_s) else raise end end end
#needed?(gem_name, version) ⇒ Boolean
# File 'lib/rbs/collection/cleaner.rb', line 30
def needed?(gem_name, version) gem = lock.gem(gem_name) return false unless gem gem['version'] == version end