Class: RBS::Collection::Cleaner
- Inherits:
-
Object
- Object
- RBS::Collection::Cleaner
- Defined in:
- lib/rbs/collection/cleaner.rb
Instance Attribute Summary collapse
-
#lock ⇒ Object
readonly
Returns the value of attribute lock.
Instance Method Summary collapse
- #clean ⇒ Object
-
#initialize(lockfile_path:) ⇒ Cleaner
constructor
A new instance of Cleaner.
- #needed?(gem_name, version) ⇒ Boolean
Constructor Details
Instance Attribute Details
#lock ⇒ Object (readonly)
Returns the value of attribute lock.
6 7 8 |
# File 'lib/rbs/collection/cleaner.rb', line 6 def lock @lock end |
Instance Method Details
#clean ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# 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 FileUtils.remove_entry_secure(dir.to_s) end end |
#needed?(gem_name, version) ⇒ Boolean
23 24 25 26 27 28 |
# File 'lib/rbs/collection/cleaner.rb', line 23 def needed?(gem_name, version) gem = lock.gem(gem_name) return false unless gem gem['version'] == version end |