Sha256: d3fcd7617022eb3f32a2d5885618f79041d8763006ff0f8b106955103c0386bd

Contents?: true

Size: 1.6 KB

Versions: 40

Compression:

Stored size: 1.6 KB

Contents

# frozen_string_literal: true
module Bundler::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 [Set<Object>] conflicts unresolved conflicts
  ResolutionState = Struct.new(
    :name,
    :requirements,
    :activated,
    :requirement,
    :possibilities,
    :depth,
    :conflicts
  )

  class ResolutionState
    # Returns an empty resolution state
    # @return [ResolutionState] an empty state
    def self.empty
      new(nil, [], DependencyGraph.new, nil, nil, 0, Set.new)
    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
      ).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

40 entries across 40 versions & 3 rubygems

Version Path
rubygems-update-2.6.14 bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
rubygems-update-2.6.13 bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.4 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.3 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.2 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.1 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.0 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.0.pre.4 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/bundler-1.14.6/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.0.pre.3 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
rubygems-update-2.6.12 bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.0.pre.2 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.15.0.pre.1 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
rubygems-update-2.6.11 bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.14.6 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.14.5 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.14.4 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.14.3 lib/bundler/vendor/molinillo/lib/molinillo/state.rb
rubygems-update-2.6.10 bundler/lib/bundler/vendor/molinillo/lib/molinillo/state.rb
bundler-1.14.2 lib/bundler/vendor/molinillo/lib/molinillo/state.rb