class MinitestBender::Sections::SortedOverview

Attributes

contexts_with_results[R]
io[R]

Public Class Methods

new(io, results_by_context) click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 4
def initialize(io, results_by_context)
  @io = io
  @contexts_with_results = sorted_pairs(results_by_context)
end

Public Instance Methods

print() click to toggle source

Private Instance Methods

cut_at(xs, i) click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 105
def cut_at(xs, i)
  [xs.take(i), xs.drop(i)]
end
first_difference_index(xs, ys) click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 101
def first_difference_index(xs, ys)
  xs.find_index.with_index { |x, i| x != ys[i] }
end
formatted_label() click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 46
def formatted_label
  "  #{Colorizer.colorize('SORTED OVERVIEW', :normal, :bold, :underline)}"
end
formatted_old_and_new(previous, current, separator) click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 83
def formatted_old_and_new(previous, current, separator)
  old_part, new_part = old_and_new(previous, current)

  old_part_string = old_part.join(separator)
  old_part_string << separator unless old_part_string.empty?
  new_part_string = new_part.join(separator)

  formatted_old = Colorizer.colorize(old_part_string, :normal)
  formatted_new = Colorizer.colorize(new_part_string, :normal, :bold)

  "#{formatted_old}#{formatted_new}"
end
old_and_new(previous, current) click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 96
def old_and_new(previous, current)
  cut_index = first_difference_index(previous, current) || previous.size
  cut_at(current, cut_index)
end
print_context(result_context, previous_context_path) click to toggle source
print_divider() click to toggle source
print_result(result, previous_words, sorted_siblings) click to toggle source
results() click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 42
def results
  contexts_with_results.map(&:last).flatten
end
sort_key() click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 60
def sort_key
  @sort_key ||= "#{Minitest::Bender.configuration.overview_sort_key}_sort_key".to_sym
end
sorted_pairs(results_by_context) click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 32
def sorted_pairs(results_by_context)
  results_by_context.map do |context, results|
    [context, results.sort_by(&:source_location)]
  end.sort
end
trivial?() click to toggle source
# File lib/minitest-bender/sections/sorted_overview.rb, line 38
def trivial?
  results.size < 2
end