Sha256: ad460fd1ebb7d784fb96e957f4cb224a77872ba98ced3d963c5803084da2554e

Contents?: true

Size: 622 Bytes

Versions: 26

Compression:

Stored size: 622 Bytes

Contents

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

26 entries across 26 versions & 1 rubygems

Version Path
rbs-2.6.0 lib/rbs/collection/cleaner.rb
rbs-2.5.1 lib/rbs/collection/cleaner.rb
rbs-2.5.0 lib/rbs/collection/cleaner.rb
rbs-2.4.0 lib/rbs/collection/cleaner.rb
rbs-2.3.2 lib/rbs/collection/cleaner.rb
rbs-2.3.1 lib/rbs/collection/cleaner.rb
rbs-2.3.0 lib/rbs/collection/cleaner.rb
rbs-2.2.2 lib/rbs/collection/cleaner.rb
rbs-2.2.1 lib/rbs/collection/cleaner.rb
rbs-2.2.0 lib/rbs/collection/cleaner.rb
rbs-2.1.0 lib/rbs/collection/cleaner.rb
rbs-2.0.0 lib/rbs/collection/cleaner.rb
rbs-2.0.0.pre2 lib/rbs/collection/cleaner.rb
rbs-2.0.0.pre1 lib/rbs/collection/cleaner.rb
rbs-1.8.1 lib/rbs/collection/cleaner.rb
rbs-1.8.0 lib/rbs/collection/cleaner.rb
rbs-1.7.1 lib/rbs/collection/cleaner.rb
rbs-1.7.0 lib/rbs/collection/cleaner.rb
rbs-1.7.0.beta.5 lib/rbs/collection/cleaner.rb
rbs-1.7.0.beta.4 lib/rbs/collection/cleaner.rb