Class: Gem::Comparator::DependencyComparator
- Inherits:
-
Base
- Object
- Base
- Gem::Comparator::DependencyComparator
- Defined in:
- lib/rubygems/comparator/dependency_comparator.rb
Overview
Gem::Comparator::DependencyComparator can compare dependencies between gem's versions based on the given Gem::Specification objects
Instance Method Summary collapse
-
#compare(specs, report, options = {}) ⇒ Object
Compare dependencies in given
specs
and write the changes to thereport
.
Instance Method Details
#compare(specs, report, options = {}) ⇒ Object
Compare dependencies in given specs
and write the changes to the report
If options is set, it compares only those dependencies
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rubygems/comparator/dependency_comparator.rb', line 19 def compare(specs, report, = {}) info 'Checking dependencies...' filter_params(DEPENDENCY_PARAMS, [:param]).each do |param| all_same = true type = param.gsub('_dependency', '').to_sym specs.each_with_index do |s, index| next if index == 0 prev_deps = specs[index-1].dependencies.select { |d| d.type == type } curr_deps = specs[index].dependencies.select { |d| d.type == type } added, deleted, updated = resolve_dependencies(prev_deps, curr_deps) if (!deleted.empty? || !added.empty? || !updated.empty?) all_same = false end ver = "#{specs[index-1].version}->#{specs[index].version}" report[param][ver].section do set_header "#{Rainbow(specs[index-1].version).cyan}->#{Rainbow(s.version).cyan}:" nest('deleted').section do set_header '* Deleted:' puts deleted.map { |x| "#{x.name} #{x.requirements_list} (#{x.type})" } unless deleted.empty? end nest('added').section do set_header '* Added:' puts added.map { |x| "#{x.name} #{x.requirements_list} (#{x.type})" } unless added.empty? end nest('updated').section do set_header '* Updated:' puts updated unless updated.empty? end end end if all_same && [:log_all] report[param].set_header "#{same} #{type} dependencies:" if [:log_all] deps = specs[0].dependencies.select{ |d| d.type == type }.map{ |d| "#{d.name}: #{d.requirements_list}" } deps = '[]' if deps.empty? report[param] << deps elsif !all_same report[param].set_header "#{different} #{type} dependencies:" end end report end |