Sha256: aeef785e4cfc8aa41f11eab191e6bc77590b03e409d1ae91eae278925f2fd5b6

Contents?: true

Size: 833 Bytes

Versions: 3

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

require "forwardable"

module Bundler
  module Alive
    # Collection of GemStatus
    class GemStatusCollection
      extend Forwardable
      delegate each: :gems

      def initialize(gems = {})
        @gems = gems
        freeze
      end

      def add(name, gem_status)
        gems[name] = gem_status

        self.class.new(gems)
      end

      def get_unchecked(name)
        return nil unless gems.key?(name)

        gem_status = gems[name]
        return nil if gem_status.unknown?

        gem_status
      end

      def to_h
        hash = {}
        gems.each do |k, v|
          hash[k] = v.to_h
        end
        hash
      end

      def need_to_report_gems
        gems.find_all { |_name, gem| !!!gem.alive }
      end

      private

      attr_reader :gems
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bundler-alive-0.1.2 lib/bundler/alive/gem_status_collection.rb
bundler-alive-0.1.1 lib/bundler/alive/gem_status_collection.rb
bundler-alive-0.1.0 lib/bundler/alive/gem_status_collection.rb