class RBS::Collection::Cleaner

Attributes

lock[R]

Public Class Methods

new(lockfile_path:) click to toggle source
# File rbs-2.8.2/lib/rbs/collection/cleaner.rb, line 8
def initialize(lockfile_path:)
  @lock = Config.from_path(lockfile_path)
end

Public Instance Methods

clean() click to toggle source
# File rbs-2.8.2/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) click to toggle source
# File rbs-2.8.2/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