Sha256: a4685e56a6c6a3fb7f4d44508193bc2f333c354c1d53b678e9867381f5448408

Contents?: true

Size: 653 Bytes

Versions: 13

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

module RBS
  module Collection
    class Cleaner
      attr_reader :lock

      def initialize(lockfile_path:)
        @lock = Config.from_path(lockfile_path)
      end

      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

      def needed?(gem_name, version)
        gem = lock.gem(gem_name)
        return false unless gem

        gem['version'] == version
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
getargv-0.3.3-universal-darwin vendor/bundle/ruby/3.3.0/gems/rbs-2.8.4/lib/rbs/collection/cleaner.rb
rbs-3.0.0.dev.2 lib/rbs/collection/cleaner.rb
rbs-2.8.4 lib/rbs/collection/cleaner.rb
rbs-2.8.3 lib/rbs/collection/cleaner.rb
rbs-3.0.0.dev.1 lib/rbs/collection/cleaner.rb
rbs-2.8.2 lib/rbs/collection/cleaner.rb
rbs-2.8.1 lib/rbs/collection/cleaner.rb
rbs-2.8.0 lib/rbs/collection/cleaner.rb
rbs-2.8.0.pre.1 lib/rbs/collection/cleaner.rb
rbs-2.7.0 lib/rbs/collection/cleaner.rb
rbs-2.7.0.pre.3 lib/rbs/collection/cleaner.rb
rbs-2.7.0.pre.2 lib/rbs/collection/cleaner.rb
rbs-2.7.0.pre.1 lib/rbs/collection/cleaner.rb