Sha256: 6bc89bebd9df89f269b7c148bba393477d030f023b1070bde48c6c183535d54e

Contents?: true

Size: 1.79 KB

Versions: 92

Compression:

Stored size: 1.79 KB

Contents

# frozen_string_literal: true

module Gem::Resolver::Molinillo
  # A state that a {Resolution} can be in
  # @attr [String] name the name of the current requirement
  # @attr [Array<Object>] requirements currently unsatisfied requirements
  # @attr [DependencyGraph] activated the graph of activated dependencies
  # @attr [Object] requirement the current requirement
  # @attr [Object] possibilities the possibilities to satisfy the current requirement
  # @attr [Integer] depth the depth of the resolution
  # @attr [Hash] conflicts unresolved conflicts, indexed by dependency name
  # @attr [Array<UnwindDetails>] unused_unwind_options unwinds for previous conflicts that weren't explored
  ResolutionState = Struct.new(
    :name,
    :requirements,
    :activated,
    :requirement,
    :possibilities,
    :depth,
    :conflicts,
    :unused_unwind_options
  )

  class ResolutionState
    # Returns an empty resolution state
    # @return [ResolutionState] an empty state
    def self.empty
      new(nil, [], DependencyGraph.new, nil, nil, 0, {}, [])
    end
  end

  # A state that encapsulates a set of {#requirements} with an {Array} of
  # possibilities
  class DependencyState < ResolutionState
    # Removes a possibility from `self`
    # @return [PossibilityState] a state with a single possibility,
    #  the possibility that was removed from `self`
    def pop_possibility_state
      PossibilityState.new(
        name,
        requirements.dup,
        activated,
        requirement,
        [possibilities.pop],
        depth + 1,
        conflicts.dup,
        unused_unwind_options.dup
      ).tap do |state|
        state.activated.tag(state)
      end
    end
  end

  # A state that encapsulates a single possibility to fulfill the given
  # {#requirement}
  class PossibilityState < ResolutionState
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
rubygems-update-3.2.31 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.30 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.29 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.28 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.27 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.26 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.25 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.24 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.23 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.22 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.21 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.20 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.19 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.18 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.17 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.16 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.15 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.14 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.13 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb
rubygems-update-3.2.12 lib/rubygems/resolver/molinillo/lib/molinillo/state.rb