Class: Gem::Molinillo::Resolver::Resolution::UnwindDetails
- Inherits:
- 
      Struct
      
        - Object
- Struct
- Gem::Molinillo::Resolver::Resolution::UnwindDetails
 
- Includes:
- Comparable
- Defined in:
- lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb,
 lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb
Overview
Details of the state to unwind to when a conflict occurs, and the cause of the unwind
Instance Attribute Summary collapse
- 
  
    
      #conflicting_requirements  ⇒ Array 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    the requirements that combined to cause the conflict. 
- 
  
    
      #requirement_tree  ⇒ Array 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    for the requirement we’re relaxing. 
- 
  
    
      #requirement_trees  ⇒ Array 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    for the conflict. 
- 
  
    
      #requirements_unwound_to_instead  ⇒ Array 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    array of unwind requirements that were chosen over this unwind. 
- 
  
    
      #state_index  ⇒ Integer 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    the index of the state to unwind to. 
- 
  
    
      #state_requirement  ⇒ Object 
    
    
  
  
  
  
    
    
  
  
  
  
  
  
    the requirement of the state we’re unwinding to. 
Instance Method Summary collapse
- 
  
    
      #<=>(other)  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    We compare UnwindDetails when choosing which state to unwind to. 
- 
  
    
      #all_requirements  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    Array of all the requirements that led to the need for this unwind. 
- 
  
    
      #reversed_requirement_tree_index  ⇒ Integer 
    
    
  
  
  
  
  
  
  
  
  
    Index of state requirement in reversed requirement tree (the conflicting requirement itself will be at position 0). 
- 
  
    
      #sub_dependencies_to_avoid  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    Array of sub-dependencies to avoid when choosing a new possibility for the state we’ve unwound to. 
- 
  
    
      #unwinding_to_primary_requirement?  ⇒ Boolean 
    
    
  
  
  
  
  
  
  
  
  
    Where the requirement of the state we’re unwinding to directly caused the conflict. 
Instance Attribute Details
#conflicting_requirements ⇒ Array
the requirements that combined to cause the conflict
| 62 63 64 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 62 def conflicting_requirements @conflicting_requirements end | 
#requirement_tree ⇒ Array
for the requirement we’re relaxing
| 62 63 64 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 62 def requirement_tree @requirement_tree end | 
#requirement_trees ⇒ Array
for the conflict
| 62 63 64 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 62 def requirement_trees @requirement_trees end | 
#requirements_unwound_to_instead ⇒ Array
array of unwind requirements that were chosen over this unwind
| 62 63 64 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 62 def requirements_unwound_to_instead @requirements_unwound_to_instead end | 
#state_index ⇒ Integer
the index of the state to unwind to
| 62 63 64 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 62 def state_index @state_index end | 
#state_requirement ⇒ Object
the requirement of the state we’re unwinding to
| 62 63 64 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 62 def state_requirement @state_requirement end | 
Instance Method Details
#<=>(other) ⇒ Integer
We compare UnwindDetails when choosing which state to unwind to. If two options have the same state_index we prefer the one most removed from a requirement that caused the conflict. Both options would unwind to the same state, but a ‘grandparent` option will filter out fewer of its possibilities after doing so - where a state is both a `parent` and a `grandparent` to requirements that have caused a conflict this is the correct behaviour.
| 83 84 85 86 87 88 89 90 91 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 83 def <=>(other) if state_index > other.state_index 1 elsif state_index == other.state_index reversed_requirement_tree_index <=> other.reversed_requirement_tree_index else -1 end end | 
#all_requirements ⇒ Array
Returns array of all the requirements that led to the need for this unwind.
| 126 127 128 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 126 def all_requirements @all_requirements ||= requirement_trees.flatten(1) end | 
#reversed_requirement_tree_index ⇒ Integer
Returns index of state requirement in reversed requirement tree (the conflicting requirement itself will be at position 0).
| 95 96 97 98 99 100 101 102 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 95 def reversed_requirement_tree_index @reversed_requirement_tree_index ||= if state_requirement requirement_tree.reverse.index(state_requirement) else 999_999 end end | 
#sub_dependencies_to_avoid ⇒ Array
Returns array of sub-dependencies to avoid when choosing a new possibility for the state we’ve unwound to. Only relevant for non-primary unwinds.
| 116 117 118 119 120 121 122 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 116 def sub_dependencies_to_avoid @requirements_to_avoid ||= requirement_trees.map do |tree| index = tree.index(state_requirement) tree[index + 1] if index end.compact end | 
#unwinding_to_primary_requirement? ⇒ Boolean
Returns where the requirement of the state we’re unwinding to directly caused the conflict. Note: in this case, it is impossible for the state we’re unwinding to be a parent of any of the other conflicting requirements (or we would have circularity).
| 109 110 111 | # File 'lib/rubygems/vendor/molinillo/lib/molinillo/resolution.rb', line 109 def unwinding_to_primary_requirement? requirement_tree.last == state_requirement end |