Class: PackageConflictOverlapResolver
- Inherits:
-
Object
- Object
- PackageConflictOverlapResolver
- Defined in:
- lib/nu/dependency_leveling/package_conflict_overlap_resolver.rb
Instance Method Summary collapse
- #analyze_proposal(proposed_package) ⇒ Object
- #highest_acceptable_version(name, requirement_one, requirement_two) ⇒ Object
-
#initialize(installed_packages, package_lister) ⇒ PackageConflictOverlapResolver
constructor
A new instance of PackageConflictOverlapResolver.
Constructor Details
#initialize(installed_packages, package_lister) ⇒ PackageConflictOverlapResolver
Returns a new instance of PackageConflictOverlapResolver.
5 6 7 8 9 |
# File 'lib/nu/dependency_leveling/package_conflict_overlap_resolver.rb', line 5 def initialize(installed_packages, package_lister) @conflict_finder = PackageConflictFinder.new(installed_packages, package_lister) @installed_packages = installed_packages @package_lister = package_lister end |
Instance Method Details
#analyze_proposal(proposed_package) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/nu/dependency_leveling/package_conflict_overlap_resolver.rb', line 11 def analyze_proposal(proposed_package) r = @conflict_finder.analyze_proposal(proposed_package) Array.new(r.conflicts).each do |conflict| hav = highest_acceptable_version(conflict[:name], conflict[:requirement_one], conflict[:requirement_two]) resolve_conflict(r,conflict,hav) if hav end if r.conflict? r.suggested_packages.uniq! r.conflicts.uniq! return r end |
#highest_acceptable_version(name, requirement_one, requirement_two) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/nu/dependency_leveling/package_conflict_overlap_resolver.rb', line 25 def highest_acceptable_version(name, requirement_one, requirement_two) candidates = @package_lister.find(name) candidates = candidates.select do |spec| requirement_one.satisfied_by?(spec.version) and requirement_two.satisfied_by?(spec.version) end return Gem::Requirement.new(candidates.sort{|a,b| a.version <=> b.version}.last.version) if candidates.length > 0 end |