Class: PackageConflictFinder
- Inherits:
-
Object
- Object
- PackageConflictFinder
- Defined in:
- lib/nu/dependency_leveling/package_conflict_finder.rb
Instance Method Summary collapse
- #analyze_proposal(proposed_package) ⇒ Object
-
#initialize(installed_packages, package_lister) ⇒ PackageConflictFinder
constructor
A new instance of PackageConflictFinder.
Constructor Details
#initialize(installed_packages, package_lister) ⇒ PackageConflictFinder
Returns a new instance of PackageConflictFinder.
5 6 7 8 9 |
# File 'lib/nu/dependency_leveling/package_conflict_finder.rb', line 5 def initialize(installed_packages, package_lister) raise "package_lister must respond to find(name, version)" unless package_lister.respond_to?("find") @package_lister = package_lister @installed_packages = installed_packages end |
Instance Method Details
#analyze_proposal(proposed_package) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/nu/dependency_leveling/package_conflict_finder.rb', line 11 def analyze_proposal(proposed_package) suggested_packages = initialized_suggested_packages(proposed_package) conflicts = find_conflicts(proposed_package) conflict_found = conflicts.length > 0 conflicting_packages = conflicts.map{|hash| hash[:name]} suggested_packages = suggested_packages.delete_if{|item| conflicting_packages.include?(item[:name])} AnalysisResults.new do |r| r.conflict = conflict_found r.conflicts = conflicts.uniq r.suggested_packages = suggested_packages.uniq end end |