Class: Gem::Comparator::SpecComparator

Inherits:
Base
  • Object
show all
Defined in:
lib/rubygems/comparator/spec_comparator.rb

Overview

Gem::Comparator::SpecComparator can compare values from the gem verions specs

Instance Method Summary collapse

Instance Method Details

#compare(specs, report, options = {}) ⇒ Object

Compare common fields in spec



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rubygems/comparator/spec_comparator.rb', line 14

def compare(specs, report, options = {})
  info 'Checking spec parameters...'
  p = options[:param]
  b = options[:brief]

  filter_params(SPEC_PARAMS, p, b).each do |param|
    values = values_from_specs(param, specs)

    if same_values?(values) && options[:log_all]
      v = value(values[0])
      report[param].section do
        set_header "#{self.same} #{param}:"
        puts v
      end
    elsif !same_values?(values)
      report[param].set_header "#{different} #{param}:"
      values.each_with_index do |value, index|
        report[param] << \
          "#{Rainbow(specs[index].version).cyan}: #{value}"
      end
    end
  end
  report
end