Sha256: 3bfe93c4c1ab10562741af555abdcf7cd2a3b118c3ccf2339f5d838e753eec5b

Contents?: true

Size: 1.31 KB

Versions: 86

Compression:

Stored size: 1.31 KB

Contents

##
# The RequirementList is used to hold the requirements being considered
# while resolving a set of gems.
#
# The RequirementList acts like a queue where the oldest items are removed
# first.

class Gem::Resolver::RequirementList

  include Enumerable

  ##
  # Creates a new RequirementList.

  def initialize
    @exact = []
    @list = []
  end

  def initialize_copy other # :nodoc:
    @exact = @exact.dup
    @list = @list.dup
  end

  ##
  # Adds Resolver::DependencyRequest +req+ to this requirements list.

  def add(req)
    if req.requirement.exact?
      @exact.push req
    else
      @list.push req
    end
    req
  end

  ##
  # Enumerates requirements in the list

  def each # :nodoc:
    return enum_for __method__ unless block_given?

    @exact.each do |requirement|
      yield requirement
    end

    @list.each do |requirement|
      yield requirement
    end
  end

  ##
  # How many elements are in the list

  def size
    @exact.size + @list.size
  end

  ##
  # Is the list empty?

  def empty?
    @exact.empty? && @list.empty?
  end

  ##
  # Remove the oldest DependencyRequest from the list.

  def remove
    return @exact.shift unless @exact.empty?
    @list.shift
  end

  ##
  # Returns the oldest five entries from the list.

  def next5
    x = @exact[0,5]
    x + @list[0,5 - x.size]
  end
end

Version data entries

86 entries across 58 versions & 4 rubygems

Version Path
rb2exe-0.1.43 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rb2exe-0.1.40 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rb2exe-0.1.39 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rb2exe-0.1.38 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rb2exe-0.1.29 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rb2exe-0.1.14 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rb2exe-0.1.12 bin/traveling-ruby-2.2.2/lib/ruby/2.2.0/rubygems/resolver/requirement_list.rb
rubygems-update-2.5.1 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.5.0 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.2.5 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.8 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.2.4 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.7 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.6 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.2.3 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.5 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.4 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.3 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.2 lib/rubygems/resolver/requirement_list.rb
rubygems-update-2.4.1 lib/rubygems/resolver/requirement_list.rb